29.4 Source Code Extraction

Except for the files mentioned in the clean target (in particular except GPL, README, and ChangeLog), we can generate any code from a corresponding .nw file.

The Makefile appears as an extra target in order to maintain the necessary tabulators in a Makefile.

Note the redefinition of CODEFILES in src/Makefile.nw and test/Makefile.nw.

The variable CODEFILES is only connected to the generated of the code files. The variable ASFILES does not depend on CODEFILES. However, CODEFILES depends on ASFILES.

436source code extraction 436  (427)  437b
CODEFILES=$(FILES)
code:
        # @echo CODE:: $(CODEFILES)
        $(MAKE) $(CODEFILES)
        $(SUBMAKE)

Defines:
code, used in chunks 21, 95b, 233, 304, 305a, 356, 366, 382, 395, 435, 460, 461, 479c, 480b, 485, 486, and 540b.
CODEFILES, used in chunks 437b, 468b, 470, 548, and 549.

Uses FILES 355a and SUBMAKE 435.

Due to a bug in Noweb 2.10c we need to run the .nw files through the filter tools/nwescape.pl.nw.

437anecessary programs 352+   (350 427)  434b
$(TOOLS)/nwescape.pl: $(TOOLS)/nwescape.pl.nw
        $(NOTANGLE) $< > $@
export NWESCAPE=$(PERL) $(TOOLS)/nwescape.pl

Defines:
NWESCAPE, used in chunks 369, 370, 376, 437b, 468b, and 548.
nwescape.pl, used in chunks 369, 370, 376, 437b, 460, 468b, and 548.

Uses NOTANGLE 352, PERL 431b, and TOOLS 428b.

Makefiles should be generated from the .nw source by passing the -t8 option to NOTANGLE, because Makefiles must contain tabs (ASCII 09) in rules and by default NOTANGLE replaces tabs by spaces. We introduce here a general rule which generates a file from its corresponding .nw file. Furthermore, we assume that any Makefile in ALLPROSE starts with the letters Makefile. For such patterns we set a pattern-specific variable NOTANGLETABS. By default NOTANGLETABS is empty for non-Makefiles.

There are already rules in Makefile.nw for the targets Makefile.def and Makefile.inc. We exclude them here in order to avoid needless warnings from MAKE.

437bsource code extraction 436+   (427)  436
Makefile Makefile%: NOTANGLETABS=-t8
$(filter-out Makefile.def Makefile.inc, $(CODEFILES)): \
    % : %.nw $(TOOLS)/nwescape.pl
        $(NWESCAPE) $< | $(NOTANGLE) $(NOTANGLETABS) > $@

Defines:
NOTANGLETABS, never used.

Uses CODEFILES 436, NOTANGLE 352, NWESCAPE 437a, nwescape.pl 437a, and TOOLS 428b.