summaryrefslogtreecommitdiff
path: root/support/splint/examples/ld/Makefile
blob: 8d876e55c99f780c3c21955e3d5939b94c7d033e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright 2012-2024, Alexander Shibakov
# This file is part of SPLinT
#
# SPLinT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SPLinT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SPLinT.  If not, see <http://www.gnu.org/licenses/>.

# this Makefile uses a flat directory structure for demonstration
# purposes; the main directory (../..) contains a slightly more
# modular organization.

PARSER = ldp
LEXER = ldl
MANUAL = ldman

LD_CORE_PREREQS = ${SPLINT_XTEXSTYLES} ${SPLINT_XTABLES}
LD_DOC_PREREQS_STATIC = ldunion.sty ldtexlex.sty ldint.sty ltokenset.sty lstokenset.sty
LD_DOC_PREREQS_GEN = ldptab.tex ldltab.tex ld_small_tab.tex ld_small_dfa.tex ${PARSER}.tok ldsetup.sty
LD_DOC_PREREQS_XREF = ${LD_CORE_PREREQS} %.sty ${LD_DOC_PREREQS_STATIC} %.tex ${LD_DOC_PREREQS_GEN} %.scn %.idx
LD_DOC_PREREQS_XREF += ldfrontmatter.sty

include ../../makefile.inc
include ${SPLINT_ROOT}makefile.loc

# rules specific to this example

ptabout:	${SPLINT_ROOT}cweb/mkeparser.c ${PARSER}.c
		${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<

ldptab.tex:	ptabout
		$< --optimize-actions --optimize-tables $@

ltabout:	${SPLINT_ROOT}cweb/mkscanner.c ldl_states.h ${LEXER}.c
		${CC} -DLEXER_FILE=\"../examples/ld/$(lastword $^)\" -o $@ $<

ldltab.tex:	ltabout
		$< --optimize-actions --optimize-tables $@

${LEXER}.c:	${LEXER}.l
		${FLEX} -o $@ $<

${PARSER}.yy :	ldgram.x
		@${CTANGLE} $<

${LEXER}.ll:	ldlex.x
		@${CTANGLE} $<

${MANUAL}.stx \
ldsetup.stx:	${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x ldexample_l.hx ldexample_t.hx alphas.hx
		@${CTANGLE} $<

# term name parser for ld grammar

ldsmallp_out:	${SPLINT_ROOT}cweb/mkeparser.c ld_small_parser.c
		${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<

ldsmalll_out:	${SPLINT_ROOT}cweb/mkscanner.c ld_small_lexer.c
		${CC} -DLEXER_FILE=\"../examples/ld/$(lastword $^)\" -o $@ $<

ld_small_tab.tex:	ldsmallp_out
			$< --optimize-actions --optimize-tables $@

ld_small_dfa.tex:	ldsmalll_out
			$< --optimize-actions --optimize-tables $@

ld_small_parser.yy \
ld_small_lexer.ll:	ldnp.x
			@${CTANGLE} $<

# numeric parser for ld grammar

ldnump_out:	${SPLINT_ROOT}cweb/mkeparser.c ld_num_parser.c
		${CC} ${BISON_STATE} -DPARSER_FILE=\"../examples/ld/$(lastword $^)\" -DYYPARSE_PARAMETERS= -o $@ $<

ldnuml_out:	${SPLINT_ROOT}cweb/mkscanner.c ld_num_lexer.c
		${CC} -DLEXER_FILE=\"../examples/ld/$(lastword $^)\" -o $@ $<

ld_num_tab.tex:	ldnump_out
			$< --optimize-actions --optimize-tables $@

ld_num_dfa.tex:	ldnuml_out
			$< --optimize-actions --optimize-tables $@

ld_num_parser.yy \
ld_num_lexer.ll:	ldnump.x
			@${CTANGLE} $<

ldexample_%.hx:	ldexample.hw
		echo $(patsubst ldexample_%.hx, "@G(%)", $@) >> $(patsubst %.hx, %.hy, $@)
		cat $< >> $(patsubst %.hx, %.hy, $@)
		echo "@g" >> $(patsubst %.hx, %.hy, $@)
		${BRACK} $(patsubst %.hx, %.hy, $@) $@

alphas.hx:
		${MISCCW} --alpha-list --alpha-length=1 $@

${MANUAL}.tex:	${MANUAL}.x ldgram.x ldlex.x ldlexo.x ldgramo.x ldnp.x ldexample_l.hx ldexample_t.hx alphas.hx
		@echo "Preparing the ${MANUAL}.tex file ..."
		-${CWEAVE} $<

${MANUAL}.sty \
ldsetup.sty:%.sty:	%.stx
			${UNLINE} $< $@

${MANUAL}.gdx: %.gdx:	${LD_DOC_PREREQS_XREF} ${PARSER}.tok
			@echo "Making the bison and TeX indices ..."
			${TEX} $*.tex

%.gdy:		%.gdx

${MANUAL}.gdy: %.gdy:	%.gdx
			${BINDX} --fine $^ $@

${MANUAL}.pdf: %.pdf:	${LD_DOC_PREREQS_XREF} %.gdy %.aux
			${PDFTEX} $*.tex && touch $*.gdy && touch $*.pdf

${PARSER}.tok:	ldgram.tex ${MANUAL}.sty ${LD_CORE_PREREQS}
		${TEX} ${MODEBOOTSTRAP} \\input $<

ldl_states.h:	ldlex.tex ${MANUAL}.sty ${LD_CORE_PREREQS}
		${TEX} ${MODEBOOTSTRAP} \\input $<

ldgram.tex ldlex.tex: \
%.tex:		%.x
		@echo "Building ldgram.tex and ldlex.tex."
		-${CWEAVE} -x $*.x

docs:		${MANUAL}.pdf

install:	docs
		@cp ${LD_DOC_PREREQS_STATIC} ${SPLINT_INSTALL_DIR}/tex/
		@cp ${LD_DOC_PREREQS_GEN} ${SPLINT_INSTALL_DIR}/cweb/

uninstall:	
		@rm -f $(patsubst %, ${SPLINT_INSTALL_DIR}/tex/%, ${LD_DOC_PREREQS_STATIC})
		@rm -f $(patsubst %, ${SPLINT_INSTALL_DIR}/cweb/%, ${LD_DOC_PREREQS_GEN})

mostlyclean:	clean_temp
		-rm -f ptabout ltabout ldsmalll_out ldsmallp_out ldnump_out ldnuml_out ${MANUAL}.c

clean:		clean_core
		-rm -f ptabout ltabout ldsmalll_out ldsmallp_out ldnump_out ldnuml_out *.stx \
		ldman.sty ldsetup.sty

distclean:	clean
		cd ${SPLINT_ROOT} && ${MAKE} clean