]> andersk Git - splint.git/blob - src/Makefile
e3485c7cacb0aa91d39ef37a995d072a17cf95ae
[splint.git] / src / Makefile
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
47 CHECK = 0 ### set to 1
48
49 LCLINT = //tmp/lclint-2.5q/bin/lclint
50 #LCLINT = ../bin/lclint
51
52 ###
53 ### source files
54 ###
55
56 include Makefile.sources
57
58 ###
59 ### top level
60 ### 
61
62 all : dorelease
63
64 quick: lclint
65
66 lclint : $(OBJ) 
67         @echo '// '
68         @echo '//  Linking:'
69         @echo '// '
70         $(CC) -o lclint $(OBJ) $(LINKFLAGS)
71
72 object: $(OBJ)
73
74 ###
75 ### grammars
76 ###
77
78 ###
79 ### -p xx flag to bison renames yyparse ==> xxparse, xxlex ==> xxlex
80 ### this is probably NOT compatible with yacc.
81 ###
82
83 signature.c : signature.c.der signature.y
84 ifdef BISON
85         @$(BISON) $(YFLAGS) -p lsl signature.y
86         @$(CAT) bison.head signature.tab.c > signature.c
87         -@$(MV) Headers/signature_gen.h Headers/signature_gen.bak
88         @$(CAT) bison.head signature.tab.h > Headers/signature_gen.h
89 else
90         $(CP) signature.c.der signature.c
91 endif
92
93 cgrammar.c : cgrammar.c.der cgrammar.y
94 ifdef BISON
95         $(BISON) $(YFLAGS) cgrammar.y
96         @echo '//           Expect 119 shift/reduce conflicts and 114 reduce/reduce conflicts.'
97         @echo '//           (see cgrammar.y for explanation)'
98         @$(CAT) bison.head cgrammar.tab.c > cgrammar.c
99         -@$(MV) Headers/cgrammar_tokens.h Headers/cgrammar_tokens.bak
100         @$(CAT) bison.head cgrammar.tab.h > Headers/cgrammar_tokens.h
101 else
102         $(CP) cgrammar.c.der cgrammar.c
103 endif
104
105 ### llgrammar2.h is necessary so +singleinclude may be used
106
107 llgrammar.c  : llgrammar.c.der llgrammar.y
108 ifdef BISON
109         $(BISON) $(YFLAGS) -p yl llgrammar.y
110         @echo '//            Expect 2 shift/reduce conflicts.'
111         @$(CAT) bison.head llgrammar.tab.c > llgrammar.c
112         -@$(MV) Headers/llgrammar_gen2.h Headers/llgrammar_gen2.bak
113         @$(CAT) bison.head llgrammar.tab.h > Headers/llgrammar_gen2.h
114         -@$(MV) Headers/llgrammar_gen.h Headers/llgrammar_gen.bak
115         @$(CAT) bison.head llgrammar.tab.h > Headers/llgrammar_gen.h
116 else
117         $(CP) llgrammar.c.der llgrammar.c
118 endif
119
120 cscanner.c : cscanner.c.der cscanner.l
121 ifdef FLEX                              
122         $(FLEX) $(LFLAGS) cscanner.l 
123         $(CAT) flex.head lex.yy.c > cscanner.c
124 else
125         $(CP) cscanner.c.der cscanner.c
126 endif
127
128 ###
129 ### compile without warnings
130 ### 
131
132 signature.o : signature.c
133         $(CC) $(CPPFLAGS) -c $*.c
134
135 cgrammar.o : cgrammar.c
136         $(CC) $(CPPFLAGS) -c $*.c
137
138 llgrammar.o : llgrammar.c
139         $(CC) $(CPPFLAGS) -c $*.c
140
141 cscanner.o : cscanner.c
142         $(CC) $(CPPFLAGS) -c $*.c
143
144 ###
145 ### header files dependant on grammars
146 ###
147
148 Headers/signature2.h : signature.c
149 Headers/cgrammar2.h : cgrammar.c
150 Headers/cgrammar_tokens.h : cgrammar.c
151 Headers/llgrammar.h : llgrammar.c
152
153 ###
154 ### defaults
155 ###
156
157 ### Flags for checking a single file
158 SINGLEFLAGS = +neverinclude -supcounts +partial -showsummary -load lclint.lcd
159
160 .c.check: lclint.lcd lclint
161         $(LCLINT) $(LINTFLAGS) $(SINGLEFLAGS) $*.c
162
163 lcllib.c: Headers/llgrammar.h
164 clabstract.c: Headers/cgrammar_tokens.h 
165 scan.c: Headers/signature2.h 
166
167 .c.o:
168 ifeq ($(CHECK), 1)
169         $(LCLINT) $(LINTFLAGS) $(SINGLEFLAGS) $*.c
170 endif
171         @echo '//  Compiling '$*.c' / compiled: '`$(OFILES)`'  (of 120 files)'
172         @$(CC) $(CFLAGS) -c $*.c
173
174 ###
175 ### alternatives (tests, releases, backups, etc.)
176 ###
177
178 ### -e option makes environment variables take precedence
179
180 .PHONY : test quicktest opt up 
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         @$(MV) Headers/local_constants.h Headers/local_constants.last
203         @echo '/* local_constants.h - created automatically by gmake localconstants */' \
204                 > Headers/local_constants.h
205 ifndef SYSTEM_LIBDIR
206         @echo '*** Fatal Error: SYSTEM_LIBDIR not defined.'
207 else
208         @echo '/*@constant observer char *SYSTEM_LIBDIR;@*/' >> Headers/local_constants.h
209         @echo '# define SYSTEM_LIBDIR $(SYSTEM_LIBDIR)' >> Headers/local_constants.h
210 ifndef DEFAULT_LARCHPATH
211         @echo '*** Fatal Error: DEFAULT_LARCHPATH not defined.'
212 else
213         @echo '/*@constant observer char *DEFAULT_LARCHPATH;@*/' >> Headers/local_constants.h
214         @echo '# define DEFAULT_LARCHPATH $(DEFAULT_LARCHPATH)' >> Headers/local_constants.h
215 ifndef DEFAULT_LCLIMPORTDIR
216         @echo '*** Fatal Error: DEFAULT_LARCHPATH not defined.'
217 else
218         @echo '/*@constant observer char *DEFAULT_LCLIMPORTDIR;@*/' >> Headers/local_constants.h
219         @echo '# define DEFAULT_LCLIMPORTDIR $(DEFAULT_LCLIMPORTDIR)' >> Headers/local_constants.h
220 endif
221 endif
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 'Making tags'
246         ./maketags
247         @echo '// '
248         @echo '//  Updating version information'
249         @$(MAKE) -e updateversion
250         @echo '//  Updating local constants'
251 ###     @$(MAKE) -e localconstants
252         @echo '// '
253         @echo '//  Compiling:'
254         @echo '// '
255         @$(MAKE) -e opt
256         @echo '//  Done Release '`cat $(VERSION_NUMBER)`
257
258
259 Headers/flag_codes.h: flags
260
261 flags: flags.def
262         grep "FLG_" flags.def > Headers/flag_codes.gen
263
264 ###
265 ### cleaning
266 ###
267 ### Standard entries to remove files from the directories
268 ###    up       --- remove .o files and grammar derivatives
269 ###    tidy     --- eliminate unwanted files
270 ###    clean    --- delete derived files, except for spec-derived files
271 ###    pristine --- delete all derived files
272 ###
273
274 .PHONY .IGNORE : up tidy clean pristine
275
276 pristine: clean
277         -$(RM) -f *.lcs *.lslo
278         -$(RM)  signature.c signature.tab.c  signature.tab.h
279         -$(RM)  llgrammar.c llgrammar.tab.c llgrammar.tab.h
280         -$(RM)  Headers/cgrammar_tokens.h
281         -$(RM)  lex.yy.c
282         -$(RM)  cgrammar.tab.h
283         -$(RM)  Headers/*_gen.h* Headers/*_gen2.h*
284
285 clean: tidy
286         -$(RM) core lclint 
287         -$(RM) *.out *.output *.bib *.dvi *.idx *.log *.o *.toc
288         -$(RM) cgrammar.c cscanner.c
289         -$(RM) test* Headers/*~ Headers/#* 
290
291 tidy:
292         -$(RM) ,* .,* *.CKP *.BAK .emacs_[0-9]* core a.out *.*~
293
294 up: 
295         -$(RM) cgrammar.c llgrammar.c signature.c cscanner.c 
296         -$(RM) *.o
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) +forcehints +singleinclude -nestcomments -fcnuse -allimponly -modglobsnomods -uniondef -exportlocal -exportheader -abstract -namechecks -protoparammatch -boolops $(ALLSRC) -dump  lclint
329
330 lint: 
331         $(LCLINT) -f lclint.lclintrc $(CPPFLAGS) +forcehints +singleinclude -nestcomments -fcnuse -uniondef +allimponly -branchstate -exportlocal -exportheader -abstract -namechecks -protoparammatch -temptrans -boolops $(ALLSRC) -dump  lclint
332
333
334 myall:
335         -$(RM) -f ../bin/lclint; \
336         gmake -C ..
337
338
This page took 1.261479 seconds and 3 git commands to generate.