# HG changeset patch # User David A. Holland # Date 1655092935 14400 # Node ID bb115deb6fb262b42dd24687f13dd6c44cf3cbc0 # Parent db7ff952e01eabe097ef918a83da140c900c44fb Improve agfiles rule. (1) It didn't depend on $(AGCL) and it absolutely should have. (2) allow AGFORCE=1 to make it rebuild whether or not it looks out of date. (3) Document this. diff -r db7ff952e01e -r bb115deb6fb2 doc/devel/make.txt --- a/doc/devel/make.txt Tue May 31 02:06:45 2022 -0400 +++ b/doc/devel/make.txt Mon Jun 13 00:02:15 2022 -0400 @@ -19,6 +19,7 @@ SAFE=1 Compile with "safe" AnaGram (see below) UNSAFE=1 Compile with "unsafe" AnaGram (see below) + AGFORCE=1 Force the agfiles target to rebuild. If you add a file to the build, rerun "make rules" in the affected build directories. If you add a whole directory, you need to rerun the @@ -34,6 +35,12 @@ away the depend files (depend.mk and *.u or *.d) to keep make from complaining that it doesn't exist. +Note that the 'agfiles' target will only rebuild the AnaGram output if +it appears to be out of date, unless you specify AGFORCE=1. If you +aren't certain whether it really rebuilt, check the date stamp in the +output header file. + + Bootstrapping notes: AnaGram is partly written using itself. This creates the potential for @@ -46,7 +53,9 @@ If you *are* developing, the following precautions are taken: - By default, the build runs $(TOP)/bin/agcl, which you should - update by hand as you see fit. + update by hand as you see fit. Note: update it from the copy + the build produces in anagram/run, not the one in anagram/agcl. + The latter doesn't have the checksums in it and won't run. - If you set SAFE (e.g., make SAFE=1) the build system will run $(TOP)/bin/safe-agcl instead, the idea being that you can be @@ -67,10 +76,10 @@ executable. Also note that if you are developing you should always configure with ---enable-maintainer-mode, and this *requires* $(TOP)/bin/agcl to exist -in order to test-compile the examples. This also creates a minor -bootstrap problem: if you don't already have an agcl to place in -$(TOP)/bin, you have to compile one. The easiest way is as follows: +--enable-maintainer-mode, and this *requires* $(TOP)/bin/agcl to +exist. This also creates a minor bootstrap problem: if you don't +already have an agcl to place in $(TOP)/bin, you have to compile +one. The easiest way is as follows: path-to-source/configure native make rules @@ -81,3 +90,13 @@ make rules make +And finally, note that the 'agfiles' target depends make-style, that +is, by timestamp, on the agcl executable selected. If reverting to an +older version, including via SAFE=1, it is a good idea to also +AGFORCE=1 on the make command line, or run the 'agclean' target +first. (There is also no such dependency when maintainer mode is not +enabled, because that would preclude building from scratch.) + +The premise is that changes to the sources are much more common than +material changes to the output that require rebuilding the parsers +used in AnaGram itself. diff -r db7ff952e01e -r bb115deb6fb2 mk/agfile-rules.sh --- a/mk/agfile-rules.sh Tue May 31 02:06:45 2022 -0400 +++ b/mk/agfile-rules.sh Mon Jun 13 00:02:15 2022 -0400 @@ -1,15 +1,22 @@ #!/bin/sh # agfile-rules.sh - generate make rules for AG files -# usage: agfile-rules.sh here|srcdir "syns" "output-extension" > rules.mk +# usage: +# agfile-rules.sh where syns ext maint > rules.mk +# -if [ $# != 3 ]; then - echo "$0: usage: $0 here|srcdir 'syns' 'output-extension'" 1>&2 +if [ $# != 4 ]; then + echo "$0: usage: $0 where syns ext maint" 1>&2 + echo " where: here | srcdir" 1>&2 + echo " syns: list of .syn files" 1>&2 + echo " ext: output extension, e.g. '.c'" 1>&2 + echo " maint: maintainer | nonmaintainer" 1>&2 exit 1 fi WHERE="$1" SYNS="$2" EXT="$3" +MAINT="$4" case "$WHERE" in here|srcdir) ;; @@ -23,6 +30,11 @@ exit 0 fi +echo 'agforce: ;' +echo 'DOAGFORCE=' +echo 'DOAGFORCE0=' +echo 'DOAGFORCE1=agforce' + for S in $SYNS; do echo $S | awk ' { @@ -31,6 +43,7 @@ sub("\\.syn$", "", base); cout=base ext; hout=base ".h"; + synsrc="$(SRCDIR)/" syn; if (where == "srcdir") { dcout = "$(SRCDIR)/" cout; @@ -41,8 +54,17 @@ dhout = hout; } + if (maint == "maintainer") { + tool = " $(AGCL)"; + } + else { + tool = ""; + } + + force = "$(DOAGFORCE$(AGFORCE))" + printf "agfiles: %s %s\n", dcout, dhout; - printf "%s %s: $(SRCDIR)/%s\n", dcout, dhout, syn; + printf "%s %s: %s %s %s\n", dcout, dhout, synsrc, tool, force; printf "\t@echo \" [AGCL] %-12s $(AGCLQUAL)\"\n", syn; printf "\t@$(AGCL) $(SRCDIR)/%s\n", syn; @@ -51,7 +73,7 @@ printf "\t@mv %s %s\n", hout, dhout; } } - ' "ext=$EXT" "where=$WHERE" + ' "ext=$EXT" "where=$WHERE" "maint=$MAINT" done echo $SYNS | tr ' ' '\n' | sed 's/.syn$//' | awk ' diff -r db7ff952e01e -r bb115deb6fb2 mk/hostprog.mk --- a/mk/hostprog.mk Tue May 31 02:06:45 2022 -0400 +++ b/mk/hostprog.mk Mon Jun 13 00:02:15 2022 -0400 @@ -36,7 +36,7 @@ rules: @$(TOP)/mk/hostprog-rules.sh '$(SRCS)' > rules.mk @$(TOP)/mk/agfile-rules.sh $(AGFILEDEST) '$(SYNS)' '$(SYNOUTPUTEXT)' \ - >> rules.mk + $(MAINTAINER) >> rules.mk # @echo ' [RULES]' depend: diff -r db7ff952e01e -r bb115deb6fb2 mk/lib.mk --- a/mk/lib.mk Tue May 31 02:06:45 2022 -0400 +++ b/mk/lib.mk Mon Jun 13 00:02:15 2022 -0400 @@ -51,7 +51,7 @@ @$(TOP)/mk/include-defs.sh '$(INCDIRS)' > rules.mk @$(TOP)/mk/compile-rules.sh '$(SRCS)' '$(RCFILES)' >> rules.mk @$(TOP)/mk/agfile-rules.sh $(AGFILEDEST) '$(SYNS)' '$(SYNOUTPUTEXT)' \ - >> rules.mk + $(MAINTAINER) >> rules.mk # @echo ' [RULES]' depend: diff -r db7ff952e01e -r bb115deb6fb2 mk/prog.mk --- a/mk/prog.mk Tue May 31 02:06:45 2022 -0400 +++ b/mk/prog.mk Mon Jun 13 00:02:15 2022 -0400 @@ -40,7 +40,7 @@ @$(TOP)/mk/include-defs.sh '$(INCDIRS)' > rules.mk @$(TOP)/mk/compile-rules.sh '$(SRCS)' '$(RCFILES)' >> rules.mk @$(TOP)/mk/agfile-rules.sh $(AGFILEDEST) '$(SYNS)' '$(SYNOUTPUTEXT)' \ - >> rules.mk + $(MAINTAINER) >> rules.mk # @echo ' [RULES]' depend: diff -r db7ff952e01e -r bb115deb6fb2 mk/progs.mk --- a/mk/progs.mk Tue May 31 02:06:45 2022 -0400 +++ b/mk/progs.mk Mon Jun 13 00:02:15 2022 -0400 @@ -32,7 +32,7 @@ @$(TOP)/mk/progs-rules.sh '$(SRCS)' >> rules.mk @$(TOP)/mk/compile-rules.sh '$(SRCS)' '' >> rules.mk @$(TOP)/mk/agfile-rules.sh $(AGFILEDEST) '$(SYNS)' '$(SYNOUTPUTEXT)' \ - >> rules.mk + $(MAINTAINER) >> rules.mk # @echo ' [RULES]' depend: