CAMDIR = $(CURDIR)/pco.camera
SAMPLES = SimpleExample SimpleExample_FIFO MultiCameraExample ColorConvertExample #ImageViewer  # continue sample list (space separated)

SAMPLE_PATHS = $(addprefix $(CURDIR)/samples/, $(SAMPLES))

ifeq "$(strip $(filter debug,$(MAKECMDGOALS)))" "debug"
     DEB = debug
else
     DEB =
endif

ifeq "$(strip $(filter debug_console,$(MAKECMDGOALS)))" "debug_console"
     DEB = debug
endif

all: camera
	@for SAMPLE in $(SAMPLE_PATHS) ; do basename $$SAMPLE: ; cd $$SAMPLE && $(MAKE) ; done

debug: camera
	@for SAMPLE in $(SAMPLE_PATHS) ; do basename $$SAMPLE: ; cd $$SAMPLE && $(MAKE) $(DEB); done

clean:
	@echo $@ pco.camera:
	@cd $(CAMDIR) && $(MAKE) $@
	@for SAMPLE in $(SAMPLE_PATHS) ; do echo -n $@\  && basename $$SAMPLE: ; cd $$SAMPLE && $(MAKE) $@ ; done

camera:
	@echo pco.$@:
	@echo $(DEB)
	@cd $(CAMDIR) && $(MAKE) $(DEB)

# specific sample
%: camera $(CURDIR)/samples/%/Makefile
	@echo $@:
	@if [ -e $(CURDIR)/samples/$@/ ] ; then cd $(CURDIR)/samples/$@/ && $(MAKE) $(DEB); fi
