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.

435submake 435  (427)
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 436, 438, and 439.

Uses code 436, CPIF 353b, DIRS 355a, NOTANGLE 352, PERL 431b, projectname 127, PROJECTROOT 350, and TOOLS 428b.