blob: 3f606c3c087c78dde7e8a5fdf59c513e7e3f9a95 (
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
# makefile for program ltx2x --- LaTeX to X autotagger
# November 1999
#
##################### Change the following for your setup
# The compiler
CC = gcc
# We use flex (or equivalent, but not lex) to generate the lexer
LEX = flex
# and the options
LEXFLAGS = -v
# We use bison (or equivalent) to generate the parser
YACC = bison
# and the options
YACCFLAGS = -y -d -v
# Libraries to be used
LIBS = -ly -ll -lm
# The root directory for the installation (e.g., /usr/local )
ROOTDIR = /opt/GNU/gnu
# Where to place the running code (e.g. /usr/local/bin )
BINDIR = ${ROOTDIR}/bin
# Where to place the manpage (e.g., /usr/local/man/man1 )
MANEXT = 1
MANDIR = ${ROOTDIR}/man/man${MANEXT}
# Just in case you want to change the name of the binary
# (and then you should also change the man page and documentation).
# So, do not change this.
PROG = ltx2x
# Where to place the user documentation (e.g., /usr/local/doc/ltx2x )
DOCDIR = ${ROOTDIR}/doc/${PROG}
# Where to place the example command tables (e.g., /usr/local/lib/config/ltx2x )
CTDIR = ${ROOTDIR}/lib/config/${PROG}
# The code checking program
LINT = lint
# Code checking program options
LINTOPTS = -achqux
# Assume getopt is present on the system
GETOPTC =
GETOPTO =
GETOPTH =
# If you do not have getopt already on your system, uncomment the next three linws
# GETOPTC = getopt.c
# GETOPTO = getopt.o
# GETOPTO = getopt.h
# The file copy command (copy but do not delete original)
COPY = cp
# The file move command (move and delete original)
MOVE = mv
# The file delete command
DELETE = rm
# The make directory (hierarchy) command
MAKEDIR = mkdirhier
# The stream editor command
SED = sed
# Command to write to the terminal (stdout)
ECHO = echo
################### You should not have to change anything after this
################### but read on just in case
# The source modules
L2XSRCS = l2xytab.c l2xlexyy.c l2xlib.c l2xacts.c l2xusrlb.c srchenv.c \
${GETOPTC}
INTSRCS = l2xirtne.c l2xistd.c l2xidecl.c l2xistmt.c l2xiexpr.c l2xiscan.c \
l2xisymt.c l2xierr.c l2xiidbg.c l2xistup.c l2xixutl.c l2xixstm.c \
l2xixxpr.c l2xixstd.c l2xidbug.c l2xisdcl.c l2xirexp.c listsetc.c
# The object modules
L2XOBJS = l2xytab.o l2xlexyy.o l2xlib.o l2xacts.o l2xusrlb.o srchenv.o \
${GETOPTO}
INTOBJS = l2xirtne.o l2xistd.o l2xidecl.o l2xistmt.o l2xiexpr.o l2xiscan.o \
l2xisymt.o l2xierr.o l2xiidbg.o l2xistup.o l2xixutl.o l2xixstm.o \
l2xixxpr.o l2xixstd.o l2xidbug.o l2xisdcl.o l2xirexp.o listsetc.o
OBJS = ${L2XOBJS} ${INTOBJS}
# Link object code together into PROG
ltx2x : ${OBJS}
${CC} -o ${PROG} ${OBJS} ${LIBS}
# Compile C source code into object code
getopt.o : getopt.c getopt.h
${CC} -c getopt.c
l2xytab.o : l2xytab.c l2xlib.h l2xusrlb.h l2xacts.h strtypes.h l2xcom.h
${CC} -c l2xytab.c
l2xlexyy.o : l2xlexyy.c l2xytab.h l2xlib.h l2xusrlb.h l2xcom.h
${CC} -c l2xlexyy.c
l2xlib.o : l2xlib.c l2xytab.h strtypes.h l2xcom.h ${GETOPTH}
${CC} -c l2xlib.c
l2xusrlb.o : l2xusrlb.c l2xlib.h l2xytab.h strtypes.h l2xcom.h
${CC} -c l2xusrlb.c
l2xacts.o : l2xacts.c l2xusrlb.h l2xlib.h l2xytab.h strtypes.h l2xcom.h
${CC} -c l2xacts.c
srchenv.o : srchenv.c srchenv.h
${CC} -c srchenv.c
# Generate C code for parsing
l2xytab.c l2xytab.h: l2x.y
@ ${ECHO} "Expect 10 shift/reduce conflicts to be reported"
${YACC} ${YACCFLAGS} l2x.y
${MOVE} y.tab.c l2xytab.c
${MOVE} y.tab.h l2xytab.h
# Generate C code for lexing
l2xlexyy.c : l2x.l
${LEX} ${LEXFLAGS} l2x.l
${MOVE} lex.yy.c l2xlexyy.c
# stuff for interpreter modules
# compiler flags for analyze and execute programs
ANLFLAG = -Danalyze
RUNFLAG = -Dtrace
# interpreter commons
SOMEH = l2xicmon.h l2xierr.h l2xiscan.h l2xisymt.h licomsym.h l2xiidbg.h
MOSTH= ${SOMEH} l2xiprse.h
ALLH = ${MOSTH} l2xicpr.h l2xiexec.h
# interpreter setup
l2xistup.o : l2xistup.c ${ALLH}
${CC} -c ${ANLFLAG} ${RUNFLAG} l2xistup.c
# The parser module
l2xirtne.o : l2xirtne.c ${ALLH}
${CC} -c ${ANLFLAG} l2xirtne.c
l2xistd.o : l2xistd.c ${MOSTH}
${CC} -c l2xistd.c
l2xidecl.o : l2xidecl.c ${MOSTH} l2xicpr.h
${CC} -c ${ANLFLAG} l2xidecl.c
l2xistmt.o : l2xistmt.c ${ALLH}
${CC} -c ${ANLFLAG} l2xistmt.c
l2xiexpr.o : l2xiexpr.c ${MOSTH} l2xicpr.h
${CC} -c ${ANLFLAG} l2xiexpr.c
# scanner module
l2xiscan.o : l2xiscan.c ${SOME} l2xicpr.h
${CC} -c ${ANLFLAG} l2xiscan.c
# symbol table module
l2xisymt.o : l2xisymt.c l2xicmon.h l2xierr.h l2xisymt.h licomsym.h l2xiidbg.h
${CC} -c l2xisymt.c
# executor module
l2xixutl.o : l2xixutl.c ${MOSTH} l2xiexec.h listsetc.h
${CC} -c ${RUNFLAG} l2xixutl.c
l2xixstm.o : l2xixstm.c ${MOSTH} l2xiexec.h listsetc.h
${CC} -c ${RUNFLAG} l2xixstm.c
l2xixxpr.o : l2xixxpr.c ${MOSTH} l2xiexec.h listsetc.h
${CC} -c ${RUNFLAG} l2xixxpr.c
l2xixstd.o : l2xixstd.c ${MOSTH} l2xiexec.h listsetc.h
${CC} -c ${RUNFLAG} l2xixstd.c
l2xidbug.o : l2xidbug.c ${SOMEH} l2xiexec.h listsetc.h
${CC} -c ${RUNFLAG} l2xidbug.c
# error and miscellaneous module
l2xisdcl.o : l2xisdcl.c ${SOMEH}
${CC} -c ${ANLFLAG} ${RUNFLAG} l2xisdcl.c
l2xiidbg.o : l2xiidbg.c ${SOMEH} l2xiexec.h
${CC} -c l2xiidbg.c
l2xirexp.o : l2xirexp.c l2xirexp.h
${CC} -c l2xirexp.c
listsetc.o : listsetc.c listsetc.h
${CC} -c listsetc.c
# Checking the sources
# Original ltx2x
checkl2x :
${LINT} ${LINTOPTS} -o l2x.lint ${L2XSRCS}
# Interpreter
checkinterp :
${LINT} ${LINTOPTS} -o interp.lint ${INTSRCS}
# The lot!
checkall :
${LINT} ${LINTOPTS} -o ltx2x.lint ${L2XSRCS} ${INTSRCS}
# only call make install if BINDIR has been set
install : ltx2x
${MAKEDIR} ${BINDIR}
${COPY} ${PROG} ${BINDIR}
# Edit the file man to replace DOCUMENTDIR by the actual directory
# where the user manual is to be placed, and CTDIR by the location
# of the example command table files.
# Then copy the manpage to the proper place
manpage :
${SED} 's!DOCUMENTDIR!${DOCDIR}!; s!CTDIR!${CTDIR}!' man > tman
${MAKEDIR} ${MANDIR}
${COPY} tman ${MANDIR}/${PROG}.${MANEXT}
# Copy the user manuals to the proper place
doc :
${MAKEDIR} ${DOCDIR}
${COPY} ltx2x.tex ${DOCDIR}/${PROG}.tex
${COPY} ltx2x.ps ${DOCDIR}/${PROG}.ps
${COPY} ltx2x.txt ${DOCDIR}/${PROG}.txt
${COPY} ltx2x.html ${DOCDIR}/${PROG}.html
# Copy the example command tables to their final location
ctables :
${MAKEDIR} ${CTDIR}
${COPY} ltx2x.ct ${CTDIR}/ltx2x.ct
${COPY} detex.ct ${CTDIR}/detex.ct
${COPY} remcom.ct ${CTDIR}/remcom.ct
${COPY} l2h.ct ${CTDIR}/l2h.ct
${COPY} bye.ct ${CTDIR}/bye.ct
# Do almost everything except clean up
all : ltx2x install manpage doc ctables
# call make clean to remove the compiled program, the object files,
# info from YACC, and the edited version of the manpage
clean :
- ${DELETE} ${PROG}
- ${DELETE} *.o
- ${DELETE} y.output
- ${DELETE} tman
#### For the printct program (best to do this after the ltx2x program)
# compile the printct program
# printct : printct.o getopt.o srchenv.o
# ${CC} -o printct printct.o getopt.o srchenv.o
printct : printct.o srchenv.o ${GETOPTO}
${CC} -o printct printct.o srchenv.o ${GETOPTO}
printct.o : printct.c strtypes.h l2xcom.h ${GETOPTH}
${CC} -c printct.c
# call make installprintct to move the printct binary to its final location
installprintct :
${COPY} printct ${BINDIR}
# call make cleanprintct to remove the compiled program and its object file
cleanprintct :
- ${DELETE} printct
- ${DELETE} printct.o
- ${DELETE} srchenv.o
- ${DELETE} getopt.o
testlist : testlist.o listsetc.o
${CC} -o testlist testlist.o listsetc.o -lm
testlist.o : testlist.c listsetc.h
${CC} -c testlist.c
|