29.3 Recursive Execution of Make
We recurse into subdirectories by calling MAKE in each directory that appears in
the variable DIRS. The variable DIRS is assumed to contain just the next level
subdirectories, i. e., there should be no / character in the value of DIRS. Otherwise
the SUBMAKE code will not work. We do not assume that the subdirectories already
contain a Makefile. It should, however, be possible to generate in each subdirectory
a Makefile from Makefile.nw. Since the following SUBMAKE should also work
when included in a Makefile in some deep subdirectory, we have to make sure
that the variable PROJECTROOT points to the root of the project’s tree.
431⟨submake 431⟩≡ (422)
SUBMAKE=$(MAKE) CMD=$@ $(TOOLS).code $(DIRS:%=%.dir)
#Note that SUBMAKE="" in the following target means not to recurse
#into subdirectories.
$(TOOLS).code:
$(NOTANGLE) -t8 $(TOOLS)/Makefile.nw > $(TOOLS)/Makefile
cd $(TOOLS) && $(MAKE) SUBMAKE="" code
echo "" > $@
%.dir:
$(PERL) $(TOOLS)/asfiles.pl $(PROJECTROOT) $(projectname) $* \
|$(CPIF) $*/Makefile.asfiles
$(NOTANGLE) -t8 $*/Makefile.nw |$(CPIF) $*/Makefile
cd $* && $(MAKE) $(CMD)
Defines:
SUBMAKE, used in chunks 432, 434, and 435.
Uses code 432, CPIF 349b, DIRS 351a, NOTANGLE 348, PERL 427b, projectname 124,
PROJECTROOT 346, and TOOLS 423b.