# -*- makefile -*- 
#
# Make subdirectories
#

# Required macros:

# SUBDIRS = a list of directories to make in

!include $(CONFIG)/make/initial

SEP=---------------------------------------------------------------------------
DPT=.

default install uninstall clean distclean backup fixmakefile objects init:
	@for %%d in ( $(SUBDIRS) ) do @echo ------------------------------------------------------------------------------ & echo Running $(MAKE) $@ $(OPT) in %%d & pushd %%d & $(MAKE) -nologo $@ $(OPT) SURE=$(SURE) & popd

build:
	@echo "Creating Makefile in $(dir)"
	@mkdir -p $(dir)
	@sed -e "s@source = .*\$$@source = `pwd`@" Makefile > $(dir)/mft
	@$(MV) $(dir)/mft $(dir)/Makefile
	@echo "" >> $(dir)/Makefile
	@for dir in $(SUBDIRS);\
	do \
	  echo $(SEP);\
	  (cd $$dir; echo "running '$(MAKE) $@ dir=$(dir)/$$dir $(OPT)' in"; \
	   this=`pwd`; this=`basename $$this`;\
	   echo $(DPT)/$$this; echo "";\
	   $(MAKE) $@ dir=$(dir)/$$dir $(OPT) DPT=$(DPT)/$$this CONFIG=$(CONFIG);\
	  )\
	done

ntbuild:
	@echo "Creating NT Makefile in $(dir)"
	@mkdir -p $(dir)
	@sed   -e "s@^include @!include @" Makefile > $(dir)/mft
	@$(MV) $(dir)/mft $(dir)/Makefile
	@for dir in $(SUBDIRS);\
	do \
	  echo $(SEP);\
	  (cd $$dir; echo "running '$(MAKE) $@ dir=$(dir)/$$dir $(OPT)' in"; \
	   this=`pwd`; this=`basename $$this`;\
	   echo $(DPT)/$$this; echo "";\
	   $(MAKE) $@ dir=$(dir)/$$dir $(OPT) DPT=$(DPT)/$$this CONFIG=$(CONFIG);\
	  )\
	done

fixconfig:
	@echo "Updating CONFIG entry"
	@sed -e "s@CONFIG = .*\$$@CONFIG = $(CONFIG)@" Makefile > mft
	@$(MV) mft Makefile
	@for dir in $(SUBDIRS);\
	do \
	  echo $(SEP);\
	  (cd $$dir; echo "running '$(MAKE) $@ $(OPT)' in"; \
	   this=`pwd`; this=`basename $$this`;\
	   echo "$(DPT)/$$this"; echo "";\
	   $(MAKE) $@ $(OPT) DPT=$(DPT)/$$this CONFIG=../$(CONFIG);\
	  )\
	done
