1 # file: .../compiler/makefile
3 # makefile for ASN.1 '88 parser
5 # compiles the snacc ASN.1 compiler
10 # $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/makefile,v 1.1.1.1 2001/05/18 23:14:08 mb Exp $
12 # Revision 1.1.1.1 2001/05/18 23:14:08 mb
13 # Move from private repository to open source repository
15 # Revision 1.2 2000/12/22 01:11:42 dmitch
16 # include ../makehead.static to workaround broken autoconf.
18 # Revision 1.1.1.1 1999/03/16 18:06:38 aram
19 # Originals from SMIME Free Library.
21 # Revision 1.12 1997/09/03 12:50:33 wan
22 # Shifted parse and lex
24 # Revision 1.11 1997/03/03 11:58:33 wan
25 # Final pre-delivery stuff (I hope).
27 # Revision 1.10 1997/02/28 13:39:52 wan
28 # Modifications collected for new version 1.3: Bug fixes, tk4.2.
30 # Revision 1.9 1997/02/16 18:02:49 rj
31 # snacc is needed to generate the distfiles
33 # Revision 1.8 1997/02/16 12:34:47 rj
34 # let make clobber remove the link to install-sh that make made
35 # let make clean remove more created files
37 # Revision 1.7 1997/01/02 08:47:20 rj
38 # an option to snacc added (when compiling the tbl.asn1 file)
40 # Revision 1.6 1995/07/25 18:09:18 rj
41 # the compiler is compiled from two files, tbl.h and tbl.c, it generates itself.
42 # for bootstrapping purposes, initial versions are supplied with the distribution.
44 # `cd && make' instead of `cd; make'.
46 # create installation directories only if they do not exist already.
48 # the compiler is compiled from two files, tbl.h and tbl.c, it generates itself.
49 # for bootstrapping purposes, initial versions are supplied with the distribution.
51 # changed `_' to `-' in file names.
53 # Revision 1.5 1995/02/20 11:53:57 rj
54 # distribute install-sh.
56 # Revision 1.4 1995/02/13 15:06:52 rj
57 # augment CPPFLAGS, not overwrite.
58 # CFLAGS moved to ../makehead.
60 # Revision 1.3 1994/10/08 03:47:23 rj
61 # added bootstrapping functionality for asn-useful.[ch].
63 # Revision 1.2 1994/09/01 00:08:49 rj
64 # gnu autoconf stuff added, DISTFILES, install phony target.
66 # Revision 1.1 1994/08/28 09:47:52 rj
67 # first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
71 include ../makehead.static
75 ASN1_SRC_DIR = $(TOP)/asn1specs
76 USEFUL_TYPES = $(ASN1_SRC_DIR)/asn-useful.asn1
79 BACKEND_DIR = back-ends
80 C_BACKEND_DIR = $(BACKEND_DIR)/c-gen
81 C++_BACKEND_DIR = $(BACKEND_DIR)/c++-gen
82 IDL_BACKEND_DIR = $(BACKEND_DIR)/idl-gen
84 ASN1_LIB_DIR = ../c-lib
85 ASN1_INC_DIR = $(ASN1_LIB_DIR)/inc
86 ASN1_BOOT_DIR = $(ASN1_LIB_DIR)/boot
87 ASN1_LIB = $(ASN1_LIB_DIR)/libasn1cCebuf.a
90 # -DYYDEBUG use for yacc/lex debug info
91 # -DDEBUG use to get general debug info
93 DEFS = -DCOMPILER -DUSE_NIBBLE_MEMORY=0 -DUSE_EXP_BUF
94 INCLUDES = -I$(CORE_DIR) -I$(ASN1_INC_DIR) -I$(ASN1_BOOT_DIR) -I$(BACKEND_DIR) -I$(TOP)
95 CPPFLAGS += $(DEFS) $(INCLUDES)
97 compilerFLAGS = $(DEFS) -I../compiler/$(CORE_DIR)
100 $(CORE_DIR)/lex-asn1.l
102 $(CORE_DIR)/lex-asn1.c
105 $(CORE_DIR)/parse-asn1.y
107 $(CORE_DIR)/parse-asn1.h
109 $(CORE_DIR)/parse-asn1.c
112 $(CORE_DIR)/asn1module.h \
113 $(CORE_DIR)/define.h \
114 $(CORE_DIR)/dependency.h \
115 $(CORE_DIR)/do-macros.h \
116 $(CORE_DIR)/err-chk.h \
117 $(CORE_DIR)/exports.h \
118 $(CORE_DIR)/gen-tbls.h \
119 $(CORE_DIR)/lex-stuff.h \
120 $(CORE_DIR)/lib-types.h \
121 $(CORE_DIR)/link-types.h \
122 $(CORE_DIR)/link-values.h \
125 $(CORE_DIR)/normalize.h \
127 $(CORE_DIR)/parser.h \
128 $(CORE_DIR)/print.h \
129 $(CORE_DIR)/recursive.h \
130 $(CORE_DIR)/snacc-util.h \
132 $(CORE_DIR)/val-parser.h \
134 $(BACKEND_DIR)/str-util.h \
135 $(BACKEND_DIR)/tag-util.h \
136 $(BACKEND_DIR)/cond.h \
138 $(C_BACKEND_DIR)/kwd.h \
139 $(C_BACKEND_DIR)/gen-any.h \
140 $(C_BACKEND_DIR)/gen-code.h \
141 $(C_BACKEND_DIR)/gen-dec.h \
142 $(C_BACKEND_DIR)/gen-enc.h \
143 $(C_BACKEND_DIR)/gen-free.h \
144 $(C_BACKEND_DIR)/gen-print.h \
145 $(C_BACKEND_DIR)/gen-type.h \
146 $(C_BACKEND_DIR)/gen-vals.h \
147 $(C_BACKEND_DIR)/rules.h \
148 $(C_BACKEND_DIR)/type-info.h \
149 $(C_BACKEND_DIR)/util.h \
151 $(C++_BACKEND_DIR)/kwd.h \
152 $(C++_BACKEND_DIR)/rules.h \
153 $(C++_BACKEND_DIR)/types.h \
154 $(C++_BACKEND_DIR)/gen-any.h \
155 $(C++_BACKEND_DIR)/gen-code.h \
156 $(C++_BACKEND_DIR)/gen-vals.h \
158 $(IDL_BACKEND_DIR)/rules.h \
159 $(IDL_BACKEND_DIR)/types.h \
160 $(IDL_BACKEND_DIR)/gen-any.h \
161 $(IDL_BACKEND_DIR)/gen-code.h \
162 $(IDL_BACKEND_DIR)/gen-vals.h
169 $(CORE_DIR)/define.c \
170 $(CORE_DIR)/dependency.c \
171 $(CORE_DIR)/do-macros.c \
172 $(CORE_DIR)/err-chk.c \
173 $(CORE_DIR)/exports.c \
174 $(CORE_DIR)/gen-tbls.c \
175 $(CORE_DIR)/lib-types.c \
176 $(CORE_DIR)/link-types.c \
177 $(CORE_DIR)/link-values.c \
180 $(CORE_DIR)/normalize.c \
182 $(CORE_DIR)/print.c \
183 $(CORE_DIR)/recursive.c \
184 $(CORE_DIR)/snacc.c \
185 $(CORE_DIR)/snacc-util.c \
186 $(CORE_DIR)/val-parser.c \
188 $(BACKEND_DIR)/str-util.c \
189 $(BACKEND_DIR)/tag-util.c \
190 $(BACKEND_DIR)/cond.c \
192 $(C_BACKEND_DIR)/type-info.c \
193 $(C_BACKEND_DIR)/util.c \
194 $(C_BACKEND_DIR)/rules.c \
195 $(C_BACKEND_DIR)/gen-code.c \
196 $(C_BACKEND_DIR)/gen-type.c \
197 $(C_BACKEND_DIR)/gen-enc.c \
198 $(C_BACKEND_DIR)/gen-dec.c \
199 $(C_BACKEND_DIR)/gen-vals.c \
200 $(C_BACKEND_DIR)/gen-free.c \
201 $(C_BACKEND_DIR)/gen-print.c \
202 $(C_BACKEND_DIR)/gen-any.c \
203 $(C_BACKEND_DIR)/kwd.c \
205 $(C++_BACKEND_DIR)/kwd.c \
206 $(C++_BACKEND_DIR)/types.c \
207 $(C++_BACKEND_DIR)/rules.c \
208 $(C++_BACKEND_DIR)/gen-code.c \
209 $(C++_BACKEND_DIR)/gen-vals.c \
210 $(C++_BACKEND_DIR)/gen-any.c \
212 $(IDL_BACKEND_DIR)/rules.c \
213 $(IDL_BACKEND_DIR)/types.c \
214 $(IDL_BACKEND_DIR)/gen-any.c \
215 $(IDL_BACKEND_DIR)/gen-code.c \
216 $(IDL_BACKEND_DIR)/gen-vals.c
223 $(CORE_DIR)/parse-asn1.o \
224 $(CORE_DIR)/lex-asn1.o \
226 $(CORE_DIR)/link-types.o \
227 $(CORE_DIR)/exports.o \
228 $(CORE_DIR)/snacc-util.o \
229 $(CORE_DIR)/dependency.o \
230 $(CORE_DIR)/lib-types.o \
233 $(CORE_DIR)/print.o \
234 $(CORE_DIR)/do-macros.o \
236 $(CORE_DIR)/link-values.o \
237 $(CORE_DIR)/normalize.o \
238 $(CORE_DIR)/val-parser.o \
239 $(CORE_DIR)/err-chk.o \
240 $(CORE_DIR)/define.o \
241 $(CORE_DIR)/recursive.o \
242 $(CORE_DIR)/snacc.o \
244 $(CORE_DIR)/gen-tbls.o \
246 $(BACKEND_DIR)/str-util.o \
247 $(BACKEND_DIR)/tag-util.o \
248 $(BACKEND_DIR)/cond.o \
250 $(C_BACKEND_DIR)/type-info.o \
251 $(C_BACKEND_DIR)/util.o \
252 $(C_BACKEND_DIR)/rules.o \
253 $(C_BACKEND_DIR)/gen-code.o \
254 $(C_BACKEND_DIR)/gen-type.o \
255 $(C_BACKEND_DIR)/gen-enc.o \
256 $(C_BACKEND_DIR)/gen-dec.o \
257 $(C_BACKEND_DIR)/gen-vals.o \
258 $(C_BACKEND_DIR)/gen-free.o \
259 $(C_BACKEND_DIR)/gen-print.o \
260 $(C_BACKEND_DIR)/gen-any.o \
261 $(C_BACKEND_DIR)/kwd.o \
263 $(C++_BACKEND_DIR)/kwd.o \
264 $(C++_BACKEND_DIR)/types.o \
265 $(C++_BACKEND_DIR)/rules.o \
266 $(C++_BACKEND_DIR)/gen-code.o \
267 $(C++_BACKEND_DIR)/gen-vals.o \
268 $(C++_BACKEND_DIR)/gen-any.o \
270 $(IDL_BACKEND_DIR)/rules.o \
271 $(IDL_BACKEND_DIR)/types.o \
272 $(IDL_BACKEND_DIR)/gen-any.o \
273 $(IDL_BACKEND_DIR)/gen-code.o \
274 $(IDL_BACKEND_DIR)/gen-vals.o
287 # ----------------------------------------------------------------------
294 snacc: $(OFILES) $(ASN1_LIB)
296 $(CC) $(LDFLAGS) -o snacc $(OFILES) $(ASN1_LIB) $(LEXLIB) $(LIBS)
298 # compiling with the generated file currently doesn't work!
299 # otherwise, one could use the bootstrapping mechanism like for asn-useful.[ch] and tbl.[ch], below
300 # $(CORE_DIR)/asn1module.h: $(ASN1_SRC_DIR)/asn1module.asn1
301 # ./snacc -t -u $(USEFUL_TYPES) $(ASN1_SRC_DIR)/asn1module.asn1
302 # # this file is empty, anyway:
304 # mv asn1module.h $(CORE_DIR)
308 $(RM) $(CORE_DIR)/tbl.h $(CORE_DIR)/tbl.c
309 if [ -f snacc ]; then\
313 ln boot/tbl.h boot/tbl.c .;\
318 # `../compiler/snacc' instead of `snacc' or `./snacc' to trick make(1) into believing that both are different files to avoid infinitre recursion:
319 stamp-tbl: ../compiler/snacc $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1 makefile
323 ./snacc -c -t -e -u $(USEFUL_TYPES) $(ASN1_SRC_DIR)/tbl.asn1
324 # the dates in the two files will differ, so the files really differ if diff prints more than 4 lines of output:
325 @-if [ -f tbl.h.prev ]; then\
326 if [ `diff tbl.h.prev tbl.h | wc -l` -gt 4 ]; then\
329 echo "tbl.h hasn't changed";\
330 mv tbl.h.prev tbl.h;\
333 @-if [ -f tbl.c.prev ]; then\
334 if [ `diff tbl.c.prev tbl.c | wc -l` -gt 4 ]; then\
337 echo "tbl.c hasn't changed";\
338 mv tbl.c.prev tbl.c;\
344 boot/tbl.c: stamp-tbl
345 $(RM) boot/tbl.h boot/tbl.c
346 cp -p tbl.h tbl.c boot
348 # the default rules work for .y.c, but often lack the .h
349 $(CORE_DIR)/parse-asn1.h \
350 $(CORE_DIR)/parse-asn1.c: $(CORE_DIR)/parse-asn1.y
352 @echo "expect 61 shift/reduce and 2 reduce/reduce conflicts"
353 $(YACC) -d $(CORE_DIR)/parse-asn1.y
354 mv y.tab.h $(CORE_DIR)/parse-asn1.h
355 mv y.tab.c $(CORE_DIR)/parse-asn1.c
358 # cd $(ASN1_LIB_DIR) && $(MAKE) Cebuf-lib compilerFLAGS="$(compilerFLAGS)"
359 # since different make versions handle the above line different, we use the more portable passing thru the environment:
360 cd $(ASN1_LIB_DIR) && compilerFLAGS="$(compilerFLAGS)" $(MAKE) Cebuf-lib
363 ln $(TOP)/install-sh $@
365 install:: snacc install-sh $(bindir)
368 $(TOP)/mkinstalldirs $@
371 $(INSTALL_PROGRAM) snacc $(bindir)/
374 $(RM) $(OFILES) $(LCFILES) $(YHFILES) $(YCFILES)
375 $(RM) *.o y.tab.c y.tab.h lex.yy.c y.output .emacs* *~ *.orig *.prev *.bak yacc.tmp yacc.acts yacc.debug
376 $(RM) stamp-tbl tbl.h tbl.h.prev tbl.c tbl.c.prev
382 depend:: $(CORE_DIR)/tbl.h $(CORE_DIR)/tbl.c
384 gen-distfiles:: snacc