ifndef PCOSDK
	PCOSDK = /opt/pco/pco.sdk
endif

ifeq "$(strip $(filter debug,$(MAKECMDGOALS)))" "debug"
  PREDEFS := -g -O0 -fno-inline -D_DEBUG
  OUTDIR   = $(CURDIR)/bin64_debug
  DEB = debug
else
  PREDEFS := -O2
  OUTDIR   = $(CURDIR)/bin64
  DEB = 
endif

OUTDIRD  = $(CURDIR)/bin64_debug

#to add filefunctions using libtiff
#uncomment next line
#export FILEFUNC=1

TARGET  = simple_open
TARGET += grab_while_camera_running
TARGET += read_from_camera_camram
TARGETS = $(addprefix $(OUTDIR)/,$(TARGET))

all: dirs
	@for SAMPLE in $(TARGET) ; do cd $(CURDIR)/$$SAMPLE && $(MAKE) $(DEB); done

debug: dirs
	@for SAMPLE in $(TARGET) ; do cd $(CURDIR)/$$SAMPLE && $(MAKE) $(DEB); done

clean:
	@for SAMPLE in $(TARGET) ; do echo -n $@ ; cd $(CURDIR)/$$SAMPLE && $(MAKE) $@ ; done

dirs:
	@if [ ! -d $(OUTDIR) ]; then \
	echo create directory $(OUTDIR); \
	mkdir $(OUTDIR); \
	fi
