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.

432source code extraction 432  (422)  433b
CODEFILES=$(FILES)
code:
        # @echo CODE:: $(CODEFILES)
        $(MAKE) $(CODEFILES)
        $(SUBMAKE)

Defines:
code, used in chunks 21, 95b, 229, 300, 301a, 352, 362, 377, 390, 431, 456, 457, 475c, 476b, 481, 482, and 537b.
CODEFILES, used in chunks 433b, 464b, 466, 546, and 547.

Uses FILES 351a and SUBMAKE 431.

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

433anecessary programs 348+   (346 422)  430b
$(TOOLS)/nwescape.pl: $(TOOLS)/nwescape.pl.nw
        $(NOTANGLE) $< > $@
export NWESCAPE=$(PERL) $(TOOLS)/nwescape.pl

Defines:
NWESCAPE, used in chunks 365, 366, 371, 433b, 464b, and 546.
nwescape.pl, used in chunks 365, 366, 371, 433b, 456, 464b, and 546.

Uses NOTANGLE 348, PERL 427b, and TOOLS 423b.

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.

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

Defines:
NOTANGLETABS, never used.

Uses CODEFILES 432, NOTANGLE 348, NWESCAPE 433a, nwescape.pl 433a, and TOOLS 423b.