]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | ################################################## |
2 | ### | |
3 | ### Makefile for LCLint | |
4 | ### | |
5 | ### designed for use with gmake (GNU make) | |
6 | ### | |
7 | ### original version based on LCL Makefile | |
8 | ### completely revised December 1993 | |
9 | ### revised for 1.4a, November 1994 | |
10 | ### revised for 2.0, February 1996 | |
11 | ### revised for 2.2, August 1996 | |
12 | ### | |
13 | ### This file should not need to be edited. | |
14 | ### | |
15 | ### Compilers and tools set using the top-level Makefile override settings | |
16 | ### in this file when make is run from the top directory. | |
17 | ### | |
18 | ### Commands: | |
19 | ### | |
20 | ### make all | |
21 | ### builds a release version of lclint from scratch using optimizations | |
22 | ### | |
23 | ### make quick | |
24 | ### builds a local version of lclint (no optimizations) | |
25 | ### (does not remake files) | |
26 | ### | |
27 | ### make test | |
28 | ### runs the test suite | |
29 | ### (must have installed test suite from lclint.test.tar.Z) | |
30 | ### | |
31 | ||
32 | .SUFFIXES : .h .c .o .l .check | |
33 | .PHONY : all dorerelease retest rerelease homeversion test | |
34 | .IGNORE : dorerelease retest rerelease | |
35 | ||
36 | ### | |
37 | ### system information (compilers, flags, directories, etc.) | |
38 | ### | |
39 | ||
40 | include Makefile.sys | |
41 | ||
42 | ### | |
43 | ### check files before compiling | |
44 | ### (can't be 1 unless you have lclint already!) | |
45 | ### | |
46 | ||
47 | CHECK = 0 | |
48 | LCLINT = lclint | |
49 | ||
50 | ### | |
51 | ### source files | |
52 | ### | |
53 | ||
54 | include Makefile.sources | |
55 | ||
56 | ### | |
57 | ### top level | |
58 | ### | |
59 | ||
60 | all : quick | |
61 | ||
62 | release: | |
63 | time ${MAKE} -e dorelease | |
64 | ||
65 | quick: lclint | |
66 | ||
67 | lclint : $(OBJ) | |
68 | @echo '// ' | |
69 | @echo '// Linking:' | |
70 | @echo '// ' | |
71 | $(CC) -o lclint $(OBJ) $(LINKFLAGS) | |
72 | ||
73 | ### | |
74 | ### grammars | |
75 | ### | |
76 | ||
77 | ### | |
78 | ### -p xx flag to bison renames yyparse ==> xxparse, xxlex ==> xxlex | |
79 | ### this is probably NOT compatible with yacc. | |
80 | ### | |
81 | ||
82 | signature.c : signature.c.der signature.y | |
83 | ifdef BISON | |
84 | @$(BISON) $(YFLAGS) -p lsl signature.y | |
85 | @$(CAT) bison.head signature.tab.c bison.reset > signature.c | |
86 | @$(MV) Headers/signature_gen.h Headers/signature_gen.bak | |
87 | @$(CAT) bison.head signature.tab.h bison.reset > Headers/signature_gen.h | |
88 | else | |
89 | $(CP) signature.c.der signature.c | |
90 | endif | |
91 | ||
92 | cgrammar.c : cgrammar.c.der cgrammar.y | |
93 | ifdef BISON | |
94 | $(BISON) $(YFLAGS) cgrammar.y | |
95 | @echo '// Expect 119 shift/reduce conflicts and 114 reduce/reduce conflicts.' | |
96 | @echo '// (see cgrammar.y for explanation)' | |
97 | @$(CAT) bison.head cgrammar.tab.c bison.reset > cgrammar.c | |
98 | @$(MV) Headers/cgrammar_tokens.h Headers/cgrammar_tokens.bak | |
99 | @$(CAT) bison.head cgrammar.tab.h bison.reset > Headers/cgrammar_tokens.h | |
100 | else | |
101 | $(CP) cgrammar.c.der cgrammar.c | |
102 | endif | |
103 | ||
104 | ### llgrammar2.h is necessary so +singleinclude may be used | |
105 | ||
106 | llgrammar.c : llgrammar.c.der llgrammar.y | |
107 | ifdef BISON | |
108 | $(BISON) $(YFLAGS) -p yl llgrammar.y | |
109 | @echo '// Expect 2 shift/reduce conflicts.' | |
110 | @$(CAT) bison.head llgrammar.tab.c bison.reset > llgrammar.c | |
111 | @$(MV) Headers/llgrammar_gen2.h Headers/llgrammar_gen2.bak | |
112 | @$(CAT) bison.head llgrammar.tab.h bison.reset > Headers/llgrammar_gen2.h | |
113 | @$(MV) Headers/llgrammar_gen.h Headers/llgrammar_gen.bak | |
114 | @$(CAT) bison.head llgrammar.tab.h bison.reset > Headers/llgrammar_gen.h | |
115 | else | |
116 | $(CP) llgrammar.c.der llgrammar.c | |
117 | endif | |
118 | ||
119 | cscanner.c : cscanner.c.der cscanner.l | |
120 | ifdef FLEX | |
121 | $(FLEX) $(LFLAGS) cscanner.l | |
122 | $(CAT) flex.head lex.yy.c flex.reset > cscanner.c | |
123 | else | |
124 | $(CP) cscanner.c.der cscanner.c | |
125 | endif | |
126 | ||
127 | ### | |
128 | ### compile without warnings | |
129 | ### | |
130 | ||
131 | signature.o : signature.c | |
132 | $(CC) $(CPPFLAGS) -c $*.c | |
133 | ||
134 | cgrammar.o : cgrammar.c | |
135 | $(CC) $(CPPFLAGS) -c $*.c | |
136 | ||
137 | llgrammar.o : llgrammar.c | |
138 | $(CC) $(CPPFLAGS) -c $*.c | |
139 | ||
140 | cscanner.o : cscanner.c | |
141 | $(CC) $(CPPFLAGS) -c $*.c | |
142 | ||
143 | ### | |
144 | ### header files dependant on grammars | |
145 | ### | |
146 | ||
147 | Headers/signature2.h : signature.c | |
148 | Headers/cgrammar2.h : cgrammar.c | |
149 | Headers/llgrammar.h : llgrammar.c | |
150 | ||
151 | ### | |
152 | ### defaults | |
153 | ### | |
154 | ||
155 | ### Flags for checking a single file | |
156 | SINGLEFLAGS = +neverinclude -supcounts +partial -showsummary -load lclint.lcd | |
157 | ||
158 | .c.check: lclint.lcd lclint | |
159 | $(LCLINT) $(LINTFLAGS) $(SINGLEFLAGS) $*.c | |
160 | ||
161 | .c.o: | |
162 | ifeq ($(CHECK), 1) | |
163 | $(LCLINT) $(LINTFLAGS) $(SINGLEFLAGS) $*.c | |
164 | endif | |
165 | @echo '// Compiling '$*.c' / compiled: '`$(OFILES)`' (of 120 files)' | |
166 | @$(CC) $(CFLAGS) -c $*.c | |
167 | ||
168 | ### | |
169 | ### alternatives (tests, releases, backups, etc.) | |
170 | ### | |
171 | ||
172 | ### -e option makes environment variables take precedence | |
173 | ||
174 | .PHONY : test quicktest opt up tags | |
175 | ||
176 | tags: | |
177 | etags ${SRC} Headers/*.h | |
178 | ||
179 | alltags: | |
180 | etags ${SRC} *.l *.y Headers/*.h *.i *.def | |
181 | ||
182 | opt : | |
183 | ifneq (,$(findstring csh, $(SHELL))) | |
184 | setenv CC '$(CCOPT)' ; $(MAKE) -e lclint | |
185 | else | |
186 | CC="$(CCOPT)" ; export CC ; $(MAKE) -e lclint | |
187 | endif | |
188 | ||
189 | updateversion: | |
190 | @$(MV) Headers/herald.h Headers/herald.last | |
191 | @echo '/* herald.h - created automatically by gmake updateversion */' > Headers/herald.h | |
192 | @echo '/*@constant observer char *LCL_VERSION;@*/' >> Headers/herald.h | |
193 | @echo '# define LCL_VERSION "LCLint '`cat $(VERSION_NUMBER)`' --- '`cat DATE`'"' \ | |
194 | >> Headers/herald.h | |
195 | @echo '/*@constant observer char *LCL_PARSE_VERSION;@*/' >> Headers/herald.h | |
196 | @echo '# define LCL_PARSE_VERSION "LCLint '`cat $(VERSION_NUMBER)`'"' \ | |
197 | >> Headers/herald.h | |
198 | @echo '/*@constant observer char *LCL_COMPILE;@*/' >> Headers/herald.h | |
199 | @echo '# define LCL_COMPILE "Compiled using '$(CC)' on '`uname -a`' by '`whoami`'"' >> Headers/herald.h | |
200 | ||
201 | localconstants: | |
202 | ifdef SYSTEM_LIBDIR | |
203 | ifdef DEFAULT_LARCHPATH | |
204 | ifdef DEFAULT_LCLIMPORTDIR | |
205 | @$(MV) Headers/local_constants.h Headers/local_constants.last | |
206 | @echo '/* local_constants.h - created automatically by gmake localconstants */' \ | |
207 | > Headers/local_constants.h | |
208 | @echo '/*@constant observer char *SYSTEM_LIBDIR;@*/' >> Headers/local_constants.h | |
209 | @echo '# define SYSTEM_LIBDIR "$(SYSTEM_LIBDIR)"' >> Headers/local_constants.h | |
210 | @echo '/*@constant observer char *DEFAULT_LARCHPATH;@*/' >> Headers/local_constants.h | |
211 | @echo '# define DEFAULT_LARCHPATH "$(DEFAULT_LARCHPATH)"' >> Headers/local_constants.h | |
212 | @echo '/*@constant observer char *DEFAULT_LCLIMPORTDIR;@*/' >> Headers/local_constants.h | |
213 | @echo '# define DEFAULT_LCLIMPORTDIR "$(DEFAULT_LCLIMPORTDIR)"' >> Headers/local_constants.h | |
214 | else | |
215 | @echo 'DEFAULT_LCLIMPORTDIR not defined. Not remaking local_constants.h.' | |
216 | endif | |
217 | else | |
218 | @echo 'DEFAULT_LARCHPATH not defined. Not remaking local_constants.h.' | |
219 | endif | |
220 | else | |
221 | @echo 'SYSTEM_LIBDIR not defined. Not remaking local_constants.h.' | |
222 | endif | |
223 | ||
224 | dorelease: | |
225 | @echo '// ' | |
226 | @echo '// Making LCLint' | |
227 | @echo '// Version '`cat $(VERSION_NUMBER)` | |
228 | @echo '// ' | |
229 | @echo '// Compiler: '$(CCOPT) | |
230 | ifdef BISON | |
231 | @echo '// Bison: '$(BISON) | |
232 | else | |
233 | @echo '// Use derived bison files' | |
234 | endif | |
235 | ifdef FLEX | |
236 | @echo '// Flex: '$(FLEX) | |
237 | else | |
238 | @echo '// Use derived flex files' | |
239 | endif | |
240 | @echo '// Default cpp command: '$(DEFAULT_CPPCMD) | |
241 | @echo '// System include directory: '$(SYSTEM_LIBDIR) | |
242 | @echo '// Default Larch path: '$(DEFAULT_LARCHPATH) | |
243 | @echo '// Default imports directory: '$(DEFAULT_LCLIMPORTDIR) | |
244 | @echo '// ' | |
245 | @echo '// Updating version information' | |
246 | @$(MAKE) -e updateversion | |
247 | @echo '// Updating local constants' | |
248 | @$(MAKE) -e localconstants | |
249 | @echo '// ' | |
250 | @echo '// Compiling:' | |
251 | @echo '// ' | |
252 | @$(MAKE) -e opt | |
253 | @echo '// Done Release '`cat $(VERSION_NUMBER)` | |
254 | ||
255 | flags: flags.def | |
256 | grep "FLG_" flags.def > Headers/flag_codes.gen | |
257 | ||
258 | llmain.c: Headers/herald.h | |
259 | ||
260 | ### | |
261 | ### cleaning | |
262 | ### | |
263 | ### Standard entries to remove files from the directories | |
264 | ### up --- remove .o files and grammar derivatives | |
265 | ### tidy --- eliminate unwanted files | |
266 | ### clean --- delete derived files, except for spec-derived files | |
267 | ### pristine --- delete all derived files | |
268 | ### | |
269 | ||
270 | .PHONY .IGNORE : up tidy clean pristine | |
271 | ||
272 | pristine: clean | |
273 | -$(RM) -f *.lcs *.lslo | |
274 | ||
275 | remake: | |
276 | ${MAKE} clean; ${MAKE} updateversion; ${MAKE} | |
277 | ||
278 | clean: tidy | |
279 | -$(RM) core lclint | |
280 | -$(RM) *.out *.output *.bib *.dvi *.idx *.log *.o *.toc | |
281 | -$(RM) cgrammar.c cscanner.c | |
282 | -$(RM) test* Headers/*~ Headers/#* | |
283 | ||
284 | tidy: | |
285 | -$(RM) ,* .,* *.CKP *.BAK .emacs_[0-9]* core a.out *.*~ | |
286 | ||
287 | up: | |
288 | -$(RM) cgrammar.c llgrammar.c signature.c cscanner.c | |
289 | -$(RM) *.o | |
290 | ||
291 | ### | |
292 | ### testing | |
293 | ### | |
294 | ||
295 | test: | |
296 | cd ../test; ${MAKE} -e test | |
297 | ||
298 | ### | |
299 | ### dependancies | |
300 | ### | |
301 | ||
302 | depend: | |
303 | $(MAKEDEPEND) $(CINCLUDES) $(CFLAGS) -f Makefile.depend $(SRC) $(GRAMS) | |
304 | ||
305 | ### | |
306 | ### analysing dependancies takes a long time and doesn't work terribly | |
307 | ### well, so the are NOT included here. NOTE carefully, this means if a | |
308 | ### header file is changed manual recompilation may be necessary. | |
309 | ### | |
310 | ||
311 | ### include Makefile.depend | |
312 | ||
313 | ### | |
314 | ### LCLint checking | |
315 | ### | |
316 | ||
317 | ### | |
318 | ### A library is used for the specifications | |
319 | ### | |
320 | ||
321 | $(CHECKS): lclint.lcd | |
322 | ||
323 | ### | |
324 | ### other flags are in .lclintrc file | |
325 | ### | |
326 | ||
327 | lint: | |
328 | ${LCLINT} -f lclint.lclintrc $(CPPFLAGS) +singleinclude $(ALLSRC) -dump lclint | |
329 | ||
330 | ctype.c: ctbase.i | |
331 | ctype.o: ctbase.i |