summaryrefslogtreecommitdiff
path: root/support/splint/cweb/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'support/splint/cweb/Makefile')
-rw-r--r--support/splint/cweb/Makefile131
1 files changed, 72 insertions, 59 deletions
diff --git a/support/splint/cweb/Makefile b/support/splint/cweb/Makefile
index 1c3b4d6bc3..f80b6b5886 100644
--- a/support/splint/cweb/Makefile
+++ b/support/splint/cweb/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2012-2020, Alexander Shibakov
+# Copyright 2012-2024, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
@@ -13,17 +13,30 @@
#
# You should have received a copy of the GNU General Public License
# along with SPLinT. If not, see <http://www.gnu.org/licenses/>.
+docs: splint.pdf
include ../makefile.inc
-all: ${SPLINT_PTABLES} ${SPLINT_LTABLES}
+tables: ${SPLINT_PTABLES} ${SPLINT_LTABLES}
-b%out: mkeparser.c b%.c
- ${CC} ${BISON_STATE} -DPARSER_FILE=\"$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
+bdout bbout bgout \
+bfout:b%out: mkeparser.c b%.c
+ ${CC} ${BISON_STATE} -DPARSER_FILE=\"$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
-b%.yy: bo.x
+bd.yy bg.yy \
+bb.yy bf.yy:b%.yy: bo.u bo.m
${CTANGLE} $<
+bd.yx bg.yx \
+bb.yx bf.yx:%.yx: %.yy
+ ${BRACK} --replace-only --bison-link=bo.m $*.yy $*.yx
+
+bd.y bg.y \
+bb.y bf.y:%.y: %.yx
+ cp -f $^ $@
+
+byytab.tex gyytab.tex \
+dyytab.tex fyytab.tex:\
%yytab.tex: b%out
${SPLINT_DRIVER_DIR}/$< --optimize-actions $@
@@ -33,15 +46,13 @@ ltab.tex: ltout
ltout: mkscanner.c lo_states.h lo.c
${CC} -DLEXER_FILE=\"$(lastword $^)\" -o $@ $<
-ssffo.ll lo.ll: \
-%.ll: %.x
+lo.ll: %.ll: %.x
${CTANGLE} $< && rm $(patsubst %.x, %.c, $^)
fil.ll: so.x
${CTANGLE} $< && rm $(patsubst %.x, %.c, $^)
-fip.yy rep.yy rap.yy \
-ddp.yy: fo.x
+fip.yy rep.yy rap.yy ddp.yy: fo.x
${CTANGLE} $< && rm $(patsubst %.x, %.c, $^)
# flex parser
@@ -52,19 +63,21 @@ fil.c: fil.l
fil_out: mkscanner.c fil_states.h fil.c
${CC} -DLEXER_FILE=\"$(lastword $^)\" -o $@ $<
-fil_states.h: so.tex lstab.tex byytab.tex
- ${PDFTEX} $<
-
filtab.tex: fil_out
${SPLINT_DRIVER_DIR}/$< --optimize-actions --optimize-tables $@
-fip.c rep.c rap.c \
-ddp.c:%.c: %.y
+# state parsing for the \flex\ input scanner
+
+fil_states.h: so.tex ssfstab.tex ddptab.tex ${SPLINT_ROOT}tex/grabstates.sty
+ @echo "Generating state list for the flex lexer ..."
+ @${PDFTEX} $<
+
+fip.c rep.c rap.c ddp.c:%.c: %.y
${BISON} -o $@ $<
fip_out rap_out \
-ddp_out rep_out:%_out: mkeparser.c %.c
- ${CC} ${BISON_STATE} -DPARSER_FILE=\"$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
+ddp_out rep_out:%_out: mkeparser.c %.c
+ ${CC} ${BISON_STATE} -DPARSER_FILE=\"$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
fiptab.tex raptab.tex \
ddptab.tex reptab.tex:%tab.tex: %_out
@@ -74,10 +87,11 @@ so.tex: so.x
${CWEAVE} $<
fo.tex: fo.x
- ${CWEAVE} $<
+ -${CWEAVE} $<
-fo.tok: fo.tex ltab.tex byytab.tex
- ${TEX} ${MODEBOOTSTRAP} \\input $<
+fo.tok: fo.tex ltab.tex dyytab.tex bo.tok
+ @echo "Generating token equivalences for flex input parser ..."
+ @${TEX} ${MODEBOOTSTRAP} \\input $<
lo.c: lo.l
${FLEX} -o $@ $<
@@ -86,10 +100,24 @@ mkscanner.c mkeparser.c: \
%.c: %.w
${CTANGLE} $<
+# bootstrap flex parser
+
+ssfs.ll: so.x
+ ${CTANGLE} $< && rm $(patsubst %.x, %.c, $^)
+
+ssfs.c: ssfs.l
+ ${FLEX} -o $@ $<
+
+ssfs_out: mkscanner.c ssfs.c
+ ${CC} -DLEXER_FILE=\"$(lastword $^)\" -o $@ $<
+
+ssfstab.tex: ssfs_out
+ ${SPLINT_DRIVER_DIR}/$< --optimize-actions --optimize-tables $@
+
# name parser
-smallp_out: mkeparser.c small_parser.c
- ${CC} ${BISON_STATE} -DPARSER_FILE=\"$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
+smallp_out: mkeparser.c small_parser.c
+ ${CC} ${BISON_STATE} -DPARSER_FILE=\"$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<
smalll_out: mkscanner.c small_lexer.c
${CC} -DLEXER_FILE=\"$(lastword $^)\" -o $@ $<
@@ -105,71 +133,56 @@ small_lexer.ll: np.x
@${CTANGLE} $<
bo.tex: bo.x
- -${CWEAVE} -x $<
+ -${CWEAVE} -x $< 1>/dev/null
splint.tex \
splint.idx \
splint.scn: splint.x bo.x lo.x fo.x so.x np.x common.w bs.w \
fk.w philosophy.w checklists.w references.w alphas.hx
- -${CWEAVE} $<
+ -${CWEAVE} $< 1>/dev/null
alphas.hx:
- ${MISCCW} --alpha-list --alpha-length=1 $@
-
-ssffo.tex \
-ssffo.idx ssffo.scn: ssffo.x
- ${CWEAVE} $<
+ @${MISCCW} --alpha-list --alpha-length=1 $@
bo.tok: bo.tex ltab.tex byytab.tex
- ${TEX} ${MODEBOOTSTRAP} \\input $<
-
-ssffo.pdf: %.pdf: ${SPLINT_DOC_PREREQS_XREF}
- ${PDFTEX} $*.tex
-
-ssffo.dvi: %.dvi: ${SPLINT_DOC_PREREQS_XREF}
- ${TEX} $*.tex
+ @echo "Making token equivalence tables for the bison parser ..."
+ @${TEX} ${MODEBOOTSTRAP} \\input $< #1>/dev/null
-splint.gdx: %.gdx: ${SPLINT_DOC_PREREQS_XREF}
+splint.gdx splint.aux: ${SPLINT_DOC_PREREQS_XREF}
@echo "Making the bison and TeX indices ..."
- ${PDFTEX} $*.tex
+ @${PDFTEX} splint.tex #1>/dev/null
+
+# remove the implicit rule before building the main index
%.gdy: %.gdx
splint.gdy: splint.gdx
${BINDX} --fine $^ $@
-splint.xxr: %.xxr: ${SPLINT_DOC_PREREQS_XREF}
- @echo "Generating the cross references ..."
- ${PDFTEX} $*.tex
-
-splint.pdf: %.pdf: ${SPLINT_DOC_PREREQS_XREF} %.gdy %.xxr
- ${PDFTEX} \\input $*.tex && touch $*.gdy && touch $*.pdf
+splint.pdf: %.pdf: ${SPLINT_DOC_PREREQS_XREF} %.gdy %.aux
+ @echo "Generating SPLinT documentation (splint.pdf) ..."
+ while test "`diff --new-file splint.pdf /tmp/splint.pdf`"; do \
+ echo "Files differ" && mv splint.pdf /tmp/; \
+ ${PDFTEX} \\input $*.tex && touch $*.gdy && touch $*.pdf; \
+ done
splint.dvi: %.dvi: ${SPLINT_DOC_PREREQS_XREF} %.gdy
- ${TEX} $*.tex && touch $*.gdy && touch $*.dvi && rm $*.xxr && rm $*.ftn
-
-${SPLINT_ROOT}tex/btokenset.sty: # stupid make weirdness
- @
+ @${TEX} $*.tex && touch $*.gdy && touch $*.dvi && rm $*.ftn
# state parsing
-lstabout: mkscanner.c ssffo.c
- ${CC} -DLEXER_FILE=\"$(lastword $^)\" -o $@ $<
-
-lstab.tex: lstabout
- ${SPLINT_DRIVER_DIR}/$< --optimize-actions $@
-
lo.tex: lo.x
${CWEAVE} $<
-lo_states.h: lo.tex lstab.tex byytab.tex
- ${PDFTEX} $<
+lo_states.h: lo.tex ssfstab.tex ddptab.tex ${SPLINT_ROOT}tex/grabstates.sty
+ @echo "Generating state list for the bison lexer ..."
+ @${PDFTEX} $<
# clean will erase all automatically generated files in the current directory
clean: clean_core
- -rm -f ctablesout b?out ltout smallp_out \
- smalll_out lstabout fil_out fip_out rep_out rap_out ddp_out
+ -rm -f ctablesout b?out ltout smallp_out /tmp/splint.pdf \
+ smalll_out ssfs_out fil_out fip_out rep_out rap_out ddp_out
include ${SPLINT_ROOT}makefile.loc
@@ -178,9 +191,9 @@ include ${SPLINT_ROOT}makefile.loc
# of bo.tok, lo.tex, eventually leading to remaking of splint.pdf;
# the special target below tells make to treat bg.yy as if it were not an intermediate file
-.PRECIOUS: %.yy bo.tok fo.tok %.ll b%.y splint.gdx splint.xxr
+.PRECIOUS: %.yy bo.tok fo.tok %.ll b%.y splint.gdx
# the files below appear as targets but are really intermediaries for other files
-.INTERMEDIATE: smallp_out smalll_out lstabout ltout fil_out \
+.INTERMEDIATE: smallp_out smalll_out ssfs_out ltout fil_out \
fip_out rep_out rap_out ddp_out splint.gdx