]>
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 | |
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 | ||
4cccc6ad | 47 | CHECK = 0 ### set to 1 |
885824d3 | 48 | |
49 | ### | |
50 | ### source files | |
51 | ### | |
52 | ||
53 | include Makefile.sources | |
54 | ||
55 | ### | |
56 | ### top level | |
57 | ### | |
58 | ||
59 | all : dorelease | |
60 | ||
61 | quick: lclint | |
62 | ||
63 | lclint : $(OBJ) | |
64 | @echo '// ' | |
65 | @echo '// Linking:' | |
66 | @echo '// ' | |
67 | $(CC) -o lclint $(OBJ) $(LINKFLAGS) | |
68 | ||
69 | ### | |
70 | ### grammars | |
71 | ### | |
72 | ||
73 | ### | |
74 | ### -p xx flag to bison renames yyparse ==> xxparse, xxlex ==> xxlex | |
75 | ### this is probably NOT compatible with yacc. | |
76 | ### | |
77 | ||
78 | signature.c : signature.c.der signature.y | |
79 | ifdef BISON | |
80 | @$(BISON) $(YFLAGS) -p lsl signature.y | |
81 | @$(CAT) bison.head signature.tab.c > signature.c | |
82 | @$(MV) Headers/signature_gen.h Headers/signature_gen.bak | |
83 | @$(CAT) bison.head signature.tab.h > Headers/signature_gen.h | |
84 | else | |
85 | $(CP) signature.c.der signature.c | |
86 | endif | |
87 | ||
88 | cgrammar.c : cgrammar.c.der cgrammar.y | |
89 | ifdef BISON | |
90 | $(BISON) $(YFLAGS) cgrammar.y | |
91 | @echo '// Expect 119 shift/reduce conflicts and 114 reduce/reduce conflicts.' | |
92 | @echo '// (see cgrammar.y for explanation)' | |
93 | @$(CAT) bison.head cgrammar.tab.c > cgrammar.c | |
94 | @$(MV) Headers/cgrammar_tokens.h Headers/cgrammar_tokens.bak | |
95 | @$(CAT) bison.head cgrammar.tab.h > Headers/cgrammar_tokens.h | |
96 | else | |
97 | $(CP) cgrammar.c.der cgrammar.c | |
98 | endif | |
99 | ||
100 | ### llgrammar2.h is necessary so +singleinclude may be used | |
101 | ||
102 | llgrammar.c : llgrammar.c.der llgrammar.y | |
103 | ifdef BISON | |
104 | $(BISON) $(YFLAGS) -p yl llgrammar.y | |
105 | @echo '// Expect 2 shift/reduce conflicts.' | |
106 | @$(CAT) bison.head llgrammar.tab.c > llgrammar.c | |
107 | @$(MV) Headers/llgrammar_gen2.h Headers/llgrammar_gen2.bak | |
108 | @$(CAT) bison.head llgrammar.tab.h > Headers/llgrammar_gen2.h | |
109 | @$(MV) Headers/llgrammar_gen.h Headers/llgrammar_gen.bak | |
110 | @$(CAT) bison.head llgrammar.tab.h > Headers/llgrammar_gen.h | |
111 | else | |
112 | $(CP) llgrammar.c.der llgrammar.c | |
113 | endif | |
114 | ||
115 | cscanner.c : cscanner.c.der cscanner.l | |
116 | ifdef FLEX | |
117 | $(FLEX) $(LFLAGS) cscanner.l | |
118 | $(CAT) flex.head lex.yy.c > cscanner.c | |
119 | else | |
120 | $(CP) cscanner.c.der cscanner.c | |
121 | endif | |
122 | ||
123 | ### | |
124 | ### compile without warnings | |
125 | ### | |
126 | ||
127 | signature.o : signature.c | |
128 | $(CC) $(CPPFLAGS) -c $*.c | |
129 | ||
130 | cgrammar.o : cgrammar.c | |
131 | $(CC) $(CPPFLAGS) -c $*.c | |
132 | ||
133 | llgrammar.o : llgrammar.c | |
134 | $(CC) $(CPPFLAGS) -c $*.c | |
135 | ||
136 | cscanner.o : cscanner.c | |
137 | $(CC) $(CPPFLAGS) -c $*.c | |
138 | ||
139 | ### | |
140 | ### header files dependant on grammars | |
141 | ### | |
142 | ||
143 | Headers/signature2.h : signature.c | |
144 | Headers/cgrammar2.h : cgrammar.c | |
145 | Headers/llgrammar.h : llgrammar.c | |
146 | ||
147 | ### | |
148 | ### defaults | |
149 | ### | |
150 | ||
151 | ### Flags for checking a single file | |
152 | SINGLEFLAGS = +neverinclude -supcounts +partial -showsummary -load lclint.lcd | |
153 | ||
154 | .c.check: lclint.lcd lclint | |
155 | $(LCLINT) $(LINTFLAGS) $(SINGLEFLAGS) $*.c | |
156 | ||
157 | .c.o: | |
158 | ifeq ($(CHECK), 1) | |
159 | $(LCLINT) $(LINTFLAGS) $(SINGLEFLAGS) $*.c | |
160 | endif | |
161 | @echo '// Compiling '$*.c' / compiled: '`$(OFILES)`' (of 120 files)' | |
162 | @$(CC) $(CFLAGS) -c $*.c | |
163 | ||
164 | ### | |
165 | ### alternatives (tests, releases, backups, etc.) | |
166 | ### | |
167 | ||
168 | ### -e option makes environment variables take precedence | |
169 | ||
170 | .PHONY : test quicktest opt up | |
171 | ||
172 | opt : | |
173 | ifneq (,$(findstring csh, $(SHELL))) | |
174 | setenv CC '$(CCOPT)' ; $(MAKE) -e lclint | |
175 | else | |
176 | CC="$(CCOPT)" ; export CC ; $(MAKE) -e lclint | |
177 | endif | |
178 | ||
179 | updateversion: | |
180 | @$(MV) Headers/herald.h Headers/herald.last | |
181 | @echo '/* herald.h - created automatically by gmake updateversion */' > Headers/herald.h | |
182 | @echo '/*@constant observer char *LCL_VERSION;@*/' >> Headers/herald.h | |
183 | @echo '# define LCL_VERSION "LCLint '`cat $(VERSION_NUMBER)`' --- '`cat DATE`'"' \ | |
184 | >> Headers/herald.h | |
185 | @echo '/*@constant observer char *LCL_PARSE_VERSION;@*/' >> Headers/herald.h | |
186 | @echo '# define LCL_PARSE_VERSION "LCLint '`cat $(VERSION_NUMBER)`'"' \ | |
187 | >> Headers/herald.h | |
188 | @echo '/*@constant observer char *LCL_COMPILE;@*/' >> Headers/herald.h | |
189 | @echo '# define LCL_COMPILE "Compiled using '$(CC)' on '`uname -a`' by '`whoami`'"' >> Headers/herald.h | |
190 | ||
191 | localconstants: | |
192 | @$(MV) Headers/local_constants.h Headers/local_constants.last | |
193 | @echo '/* local_constants.h - created automatically by gmake localconstants */' \ | |
194 | > Headers/local_constants.h | |
195 | ifndef SYSTEM_LIBDIR | |
196 | @echo '*** Fatal Error: SYSTEM_LIBDIR not defined.' | |
197 | else | |
198 | @echo '/*@constant observer char *SYSTEM_LIBDIR;@*/' >> Headers/local_constants.h | |
199 | @echo '# define SYSTEM_LIBDIR $(SYSTEM_LIBDIR)' >> Headers/local_constants.h | |
200 | ifndef DEFAULT_LARCHPATH | |
201 | @echo '*** Fatal Error: DEFAULT_LARCHPATH not defined.' | |
202 | else | |
203 | @echo '/*@constant observer char *DEFAULT_LARCHPATH;@*/' >> Headers/local_constants.h | |
204 | @echo '# define DEFAULT_LARCHPATH $(DEFAULT_LARCHPATH)' >> Headers/local_constants.h | |
205 | ifndef DEFAULT_LCLIMPORTDIR | |
206 | @echo '*** Fatal Error: DEFAULT_LARCHPATH not defined.' | |
207 | else | |
208 | @echo '/*@constant observer char *DEFAULT_LCLIMPORTDIR;@*/' >> Headers/local_constants.h | |
209 | @echo '# define DEFAULT_LCLIMPORTDIR $(DEFAULT_LCLIMPORTDIR)' >> Headers/local_constants.h | |
210 | endif | |
211 | endif | |
212 | endif | |
213 | ||
214 | dorelease: | |
215 | @echo '// ' | |
216 | @echo '// Making LCLint' | |
217 | @echo '// Version '`cat $(VERSION_NUMBER)` | |
218 | @echo '// ' | |
219 | @echo '// Compiler: '$(CCOPT) | |
220 | ifdef BISON | |
221 | @echo '// Bison: '$(BISON) | |
222 | else | |
223 | @echo '// Use derived bison files' | |
224 | endif | |
225 | ifdef FLEX | |
226 | @echo '// Flex: '$(FLEX) | |
227 | else | |
228 | @echo '// Use derived flex files' | |
229 | endif | |
230 | @echo '// Default cpp command: '$(DEFAULT_CPPCMD) | |
231 | @echo '// System include directory: '$(SYSTEM_LIBDIR) | |
232 | @echo '// Default Larch path: '$(DEFAULT_LARCHPATH) | |
233 | @echo '// Default imports directory: '$(DEFAULT_LCLIMPORTDIR) | |
234 | @echo '// ' | |
235 | @echo '// Updating version information' | |
236 | @$(MAKE) -e updateversion | |
237 | @echo '// Updating local constants' | |
4cccc6ad | 238 | ### @$(MAKE) -e localconstants |
885824d3 | 239 | @echo '// ' |
240 | @echo '// Compiling:' | |
241 | @echo '// ' | |
242 | @$(MAKE) -e opt | |
243 | @echo '// Done Release '`cat $(VERSION_NUMBER)` | |
244 | ||
245 | ### | |
246 | ### cleaning | |
247 | ### | |
248 | ### Standard entries to remove files from the directories | |
249 | ### up --- remove .o files and grammar derivatives | |
250 | ### tidy --- eliminate unwanted files | |
251 | ### clean --- delete derived files, except for spec-derived files | |
252 | ### pristine --- delete all derived files | |
253 | ### | |
254 | ||
255 | .PHONY .IGNORE : up tidy clean pristine | |
256 | ||
257 | pristine: clean | |
258 | -$(RM) -f *.lcs *.lslo | |
259 | ||
260 | clean: tidy | |
261 | -$(RM) core lclint | |
262 | -$(RM) *.out *.output *.bib *.dvi *.idx *.log *.o *.toc | |
263 | -$(RM) cgrammar.c cscanner.c | |
264 | -$(RM) test* Headers/*~ Headers/#* | |
265 | ||
266 | tidy: | |
267 | -$(RM) ,* .,* *.CKP *.BAK .emacs_[0-9]* core a.out *.*~ | |
268 | ||
269 | up: | |
270 | -$(RM) cgrammar.c llgrammar.c signature.c cscanner.c | |
271 | -$(RM) *.o | |
272 | ||
273 | ### | |
274 | ### dependancies | |
275 | ### | |
276 | ||
277 | depend: | |
278 | $(MAKEDEPEND) $(CINCLUDES) $(CFLAGS) -f Makefile.depend $(SRC) $(GRAMS) | |
279 | ||
280 | ### | |
281 | ### analysing dependancies takes a long time and doesn't work terribly | |
282 | ### well, so the are NOT included here. NOTE carefully, this means if a | |
283 | ### header file is changed manual recompilation may be necessary. | |
284 | ### | |
285 | ||
286 | ### include Makefile.depend | |
287 | ||
288 | ### | |
289 | ### LCLint checking | |
290 | ### | |
291 | ||
292 | ### | |
293 | ### A library is used for the specifications | |
294 | ### | |
295 | ||
296 | $(CHECKS): lclint.lcd | |
297 | ||
298 | ### | |
299 | ### other flags are in .lclintrc file | |
300 | ### | |
301 | ||
302 | lint: | |
303 | $(LCLINT) -f lclint.lclintrc $(CPPFLAGS) +singleinclude $(ALLSRC) -dump lclint | |
304 | ||
305 | ||
306 | ||
307 |