ifndef PCOREC
	PCOREC = /opt/pco/pco.recorder
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

TARGET  = ColorConvertExample
TARGET += MultiCameraExample
TARGET += SimpleCamRamExample
TARGET += SimpleExample
TARGET += SimpleExample_FIFO
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
