#
# $Id$
#

ifeq ($(PM),) # Only traverse directories if not compiling a specific module

ifeq ($(DIRS),) # Empty directory list

DIR_RULE = @echo Done

else

ifeq ($(SHLVL),) # COMMAND.COM

# We have to use script to overcome the DOS limit of max 128 characters
# NOTE: The empty line directly before 'endef' HAVE TO exist!
# It causes that every commands will be separated by LF
define dir_mk
$(DIR_MAKE) -C $(file) $@

endef

DIR_LIST := $(subst /,\,$(DIRS))
DIR_MAKE := $(subst /,\,$(MK))
DIR_RULE = $(foreach file, $(DIR_LIST), $(dir_mk))

else  # bash
DIR_LIST = $(subst \,/,$(DIRS))
DIR_RULE =\
	for d in $(DIR_LIST); do \
	  if [ -d $$d ]; then \
	    $(MAKE) -C $$d $@; \
	  fi \
	done

endif # ! COMMAND.COM

endif # ! Empty directory list

endif # ! compiling a specific program module
