# Productions:
#	ALL: Put here so it will be the default production.
#	dirs: make in the subdirectories
#	recursive: recursively execute a command.  Call with
#			$(MAKE) COMMAND=[command to execute] recursive

.PHONY: ALL dirs recursive

# If the "DIRS" variable is set by the file itself (as opposed to being
# passed in the environment from a higher make), then do sub-level makes.
ALL: all

dirs:
ifeq "$(origin DIRS)" "file"
	@for i in $(DIRS); do		\
		echo "Making $$i..";	\
		$(MAKE) -C $$i;		\
		if [ $$? -eq 0 ]; then    \
		echo "done with $$i.";	\
		else \
		exit 1;\
		fi;\
	done
endif

recursive: $(COMMAND)
ifeq "$(origin DIRS)" "file"
	@for i in $(DIRS); do			\
		echo "Making $(COMMAND) in $$i..";  \
		$(MAKE) -C $$i recursive;	\
		echo "done with $$i.";		\
	done
endif

ifdef ARCH
arch:
	-mkdir $(ARCH)
endif
