1########################################################################
2#
3# Copyright (c) 2009, Secure Endpoints Inc.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# - Redistributions of source code must retain the above copyright
11#   notice, this list of conditions and the following disclaimer.
12#
13# - Redistributions in binary form must reproduce the above copyright
14#   notice, this list of conditions and the following disclaimer in
15#   the documentation and/or other materials provided with the
16#   distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30#
31
32RELDIR=lib\asn1
33
34intcflags=-I$(SRCDIR) -I$(OBJ) -DROKEN_RENAME
35
36!include ../../windows/NTMakefile.w32
37
38gen_files_krb5                = $(OBJ)\asn1_krb5_asn1.x
39
40gen_files_cms                 = $(OBJ)\asn1_cms_asn1.x
41
42gen_files_rfc2459   = $(OBJ)\asn1_rfc2459_asn1.x
43
44gen_files_pkinit    = $(OBJ)\asn1_pkinit_asn1.x
45
46gen_files_pkcs12    = $(OBJ)\asn1_pkcs12_asn1.x
47
48gen_files_pkcs8               = $(OBJ)\asn1_pkcs8_asn1.x
49
50gen_files_pkcs9               = $(OBJ)\asn1_pkcs9_asn1.x
51
52gen_files_test                = $(OBJ)\asn1_test_asn1.x
53
54gen_files_digest    = $(OBJ)\asn1_digest_asn1.x
55
56gen_files_kx509               = $(OBJ)\asn1_kx509_asn1.x
57
58ASN1_BINARIES =                                                           \
59          $(LIBEXECDIR)\asn1_compile.exe
60
61$(BINDIR)\asn1_compile.exe:                                     \
62          $(OBJ)\asn1parse.obj                                            \
63          $(OBJ)\gen.obj                                                  \
64          $(OBJ)\gen_copy.obj                                   \
65          $(OBJ)\gen_decode.obj                                           \
66          $(OBJ)\gen_encode.obj                                           \
67          $(OBJ)\gen_free.obj                                   \
68          $(OBJ)\gen_glue.obj                                   \
69          $(OBJ)\gen_length.obj                                           \
70          $(OBJ)\gen_seq.obj                                    \
71          $(OBJ)\gen_template.obj                                         \
72          $(OBJ)\hash.obj                                                 \
73          $(OBJ)\lex.obj                                                  \
74          $(OBJ)\main.obj                                                 \
75          $(OBJ)\symbol.obj                                     \
76          $(OBJ)\asn1_compile-version.res
77          $(EXECONLINK) $(LIBROKEN) $(LIBVERS)
78          $(EXEPREP_NOHEIM)
79
80$(OBJ)\lex.c: lex.l $(OBJ)\asn1parse.h
81          $(LEX) -o$@ lex.l
82
83$(OBJ)\lex.obj: $(OBJ)\lex.c
84          $(C2OBJ) -DYY_NO_UNISTD_H
85
86$(OBJ)\asn1parse.c $(OBJ)\asn1parse.h: asn1parse.y
87          $(YACC) -o $(OBJ)\asn1parse.c --defines=$(OBJ)\asn1parse.h $**
88
89$(OBJ)\asn1_err.c $(OBJ)\asn1_err.h: asn1_err.et
90          cd $(OBJ)
91          $(BINDIR)\compile_et.exe $(SRCDIR)\asn1_err.et
92          cd $(SRCDIR)
93
94$(BINDIR)\asn1_print.exe: $(OBJ)\asn1_print.obj $(LIBHEIMDAL)
95          $(EXECONLINK) $(LIBVERS) $(LIBROKEN) $(LIBCOMERR)
96          $(EXEPREP)
97
98$(BINDIR)\asn1_gen.exe: $(OBJ)\asn1_gen.obj $(LIBHEIMDAL)
99          $(EXECONLINK) $(LIBVERS) $(LIBROKEN)
100          $(EXEPREP)
101
102LIBASN1_OBJS=       \
103          $(OBJ)\der.obj                          \
104          $(OBJ)\der_get.obj            \
105          $(OBJ)\der_put.obj            \
106          $(OBJ)\der_free.obj           \
107          $(OBJ)\der_length.obj                   \
108          $(OBJ)\der_copy.obj           \
109          $(OBJ)\der_cmp.obj            \
110          $(OBJ)\der_format.obj                   \
111          $(OBJ)\extra.obj              \
112          $(OBJ)\timegm.obj             \
113          $(gen_files_rfc2459:.x=.obj)  \
114          $(gen_files_cms:.x=.obj)      \
115          $(gen_files_krb5:.x=.obj)               \
116          $(gen_files_pkinit:.x=.obj)   \
117          $(gen_files_pkcs8:.x=.obj)    \
118          $(gen_files_pkcs9:.x=.obj)    \
119          $(gen_files_pkcs12:.x=.obj)   \
120          $(gen_files_digest:.x=.obj)   \
121          $(gen_files_kx509:.x=.obj)    \
122          $(OBJ)\asn1_err.obj
123
124$(LIBASN1): $(LIBASN1_OBJS)
125          $(LIBCON_C) -out:$@ @<<
126$(**: =
127)
128<<
129
130clean::
131          -$(RM) $(LIBASN1)
132
133#
134# Generate list of exports
135#
136# This target is only used during development to generate a list of
137# symbols that are exported from all the object files in LIBASN1_OBJS.
138#
139exports-list.txt: $(LIBASN1_OBJS)
140          $(PERL) ..\..\cf\w32-list-externs-from-objs.pl -q -u @<< > $@
141$(**: =
142)
143<<
144
145$(gen_files_krb5:.x=.c)           : $$(@R).x
146
147$(gen_files_pkinit:.x=.c)   : $$(@R).x
148
149$(gen_files_pkcs8:.x=.c)    : $$(@R).x
150
151$(gen_files_pkcs9:.x=.c)    : $$(@R).x
152
153$(gen_files_pkcs12:.x=.c)   : $$(@R).x
154
155$(gen_files_digest:.x=.c)   : $$(@R).x
156
157$(gen_files_kx509:.x=.c)    : $$(@R).x
158
159$(gen_files_rfc2459:.x=.c)  : $$(@R).x
160
161$(gen_files_cms:.x=.c)            : $$(@R).x
162
163$(gen_files_test:.x=.c)           : $$(@R).x
164
165$(gen_files_krb5) $(OBJ)\krb5_asn1.hx: $(BINDIR)\asn1_compile.exe krb5.asn1 krb5.opt
166          cd $(OBJ)
167          $(BINDIR)\asn1_compile.exe \
168                    --one-code-file     \
169                    --option-file=$(SRCDIR)\krb5.opt \
170                    $(SRCDIR)\krb5.asn1 krb5_asn1 \
171          || ($(RM) $(OBJ)\krb5_asn1.h ; exit /b 1)
172          cd $(SRCDIR)
173
174$(gen_files_pkinit) $(OBJ)\pkinit_asn1.hx: $(BINDIR)\asn1_compile.exe pkinit.asn1
175          cd $(OBJ)
176          $(BINDIR)\asn1_compile.exe --one-code-file $(SRCDIR)\pkinit.asn1 pkinit_asn1 \
177          || ($(RM) $(OBJ)\pkinit_asn1.h ; exit /b 1)
178          cd $(SRCDIR)
179
180$(gen_files_pkcs8) $(OBJ)\pkcs8_asn1.hx: $(BINDIR)\asn1_compile.exe pkcs8.asn1
181          cd $(OBJ)
182          $(BINDIR)\asn1_compile.exe --one-code-file $(SRCDIR)\pkcs8.asn1 pkcs8_asn1 \
183          || ($(RM) $(OBJ)\pkcs8_asn1.h ; exit /b 1)
184          cd $(SRCDIR)
185
186$(gen_files_pkcs9) $(OBJ)\pkcs9_asn1.hx: $(BINDIR)\asn1_compile.exe pkcs9.asn1
187          cd $(OBJ)
188          $(BINDIR)\asn1_compile.exe --one-code-file $(SRCDIR)\pkcs9.asn1 pkcs9_asn1 \
189          || ($(RM) $(OBJ)\pkcs9_asn1.h ; exit /b 1)
190          cd $(SRCDIR)
191
192$(gen_files_pkcs12) $(OBJ)\pkcs12_asn1.hx: $(BINDIR)\asn1_compile.exe pkcs12.asn1
193          cd $(OBJ)
194          $(BINDIR)\asn1_compile.exe --one-code-file $(SRCDIR)\pkcs12.asn1 pkcs12_asn1 \
195          || ($(RM) $(OBJ)\pkcs12_asn1.h ; exit /b 1)
196          cd $(SRCDIR)
197
198$(gen_files_digest) $(OBJ)\digest_asn1.hx: $(BINDIR)\asn1_compile.exe digest.asn1
199          cd $(OBJ)
200          $(BINDIR)\asn1_compile.exe --one-code-file $(SRCDIR)\digest.asn1 digest_asn1 \
201          || ($(RM) $(OBJ)\digest_asn1.h ; exit /b 1)
202          cd $(SRCDIR)
203
204$(gen_files_kx509) $(OBJ)\kx509_asn1.hx: $(BINDIR)\asn1_compile.exe kx509.asn1
205          cd $(OBJ)
206          $(BINDIR)\asn1_compile.exe --one-code-file $(SRCDIR)\kx509.asn1 kx509_asn1 \
207          || ($(RM) $(OBJ)\kx509_asn1.h ; exit /b 1)
208          cd $(SRCDIR)
209
210$(gen_files_rfc2459) $(OBJ)\rfc2459_asn1.hx: $(BINDIR)\asn1_compile.exe rfc2459.asn1
211          cd $(OBJ)
212          $(BINDIR)\asn1_compile.exe \
213                    --one-code-file \
214                    --preserve-binary=TBSCertificate \
215                    --preserve-binary=TBSCRLCertList \
216                    --preserve-binary=Name \
217                    --sequence=GeneralNames \
218                    --sequence=Extensions \
219                    --sequence=CRLDistributionPoints \
220                    $(SRCDIR)\rfc2459.asn1 rfc2459_asn1 \
221          || ($(RM) $(OBJ)\rfc2459_asn1.h ; exit /b 1)
222          cd $(SRCDIR)
223
224$(gen_files_cms) $(OBJ)\cms_asn1.hx: $(BINDIR)\asn1_compile.exe cms.asn1 cms.opt
225          cd $(OBJ)
226          $(BINDIR)\asn1_compile.exe \
227                    --one-code-file --option-file=$(SRCDIR)\cms.opt \
228                    $(SRCDIR)\cms.asn1 cms_asn1 \
229          || ($(RM) $(OBJ)\cms_asn1.h ; exit /b 1)
230          cd $(SRCDIR)
231
232$(gen_files_test) $(OBJ)\test_asn1.hx: $(BINDIR)\asn1_compile.exe test.asn1
233          cd $(OBJ)
234          $(BINDIR)\asn1_compile.exe \
235                    --one-code-file --sequence=TESTSeqOf \
236                    $(SRCDIR)\test.asn1 test_asn1 \
237          || ($(RM) $(OBJ)\test_asn1.h ; exit /b 1)
238          cd $(SRCDIR)
239
240INCFILES=                         \
241          $(INCDIR)\der.h                   \
242          $(INCDIR)\heim_asn1.h             \
243          $(INCDIR)\der-protos.h            \
244          $(INCDIR)\der-private.h           \
245          $(INCDIR)\asn1-common.h           \
246          $(INCDIR)\asn1-template.h   \
247          $(OBJ)\asn1_err.h
248
249$(INCDIR)\der-protos.h: $(OBJ)\der-protos.h
250
251GENINCFILES=                                \
252          $(INCDIR)\asn1_err.h              \
253          $(INCDIR)\cms_asn1.h              \
254          $(INCDIR)\digest_asn1.h           \
255          $(INCDIR)\krb5_asn1.h             \
256          $(INCDIR)\kx509_asn1.h            \
257          $(INCDIR)\pkcs12_asn1.h           \
258          $(INCDIR)\pkcs8_asn1.h            \
259          $(INCDIR)\pkcs9_asn1.h            \
260          $(INCDIR)\pkinit_asn1.h           \
261          $(INCDIR)\rfc2459_asn1.h    \
262          $(OBJ)\krb5_asn1-priv.h           \
263          $(OBJ)\pkinit_asn1-priv.h   \
264          $(OBJ)\cms_asn1-priv.h            \
265          $(OBJ)\rfc2459_asn1-priv.h  \
266          $(OBJ)\pkcs8_asn1-priv.h    \
267          $(OBJ)\pkcs9_asn1-priv.h    \
268          $(OBJ)\pkcs12_asn1-priv.h   \
269          $(OBJ)\digest_asn1-priv.h   \
270          $(OBJ)\kx509_asn1-priv.h    \
271          $(OBJ)\test_asn1.h      \
272          $(OBJ)\test_asn1-priv.h
273
274libasn1_SOURCES=    \
275          der_locl.h          \
276          der.c               \
277          der.h               \
278          der_get.c \
279          der_put.c \
280          der_free.c          \
281          der_length.c        \
282          der_copy.c          \
283          der_cmp.c \
284          der_format.c        \
285          heim_asn1.h         \
286          extra.c             \
287          timegm.c
288
289$(OBJ)\der-protos.h: $(libasn1_SOURCES)
290          $(PERL) ..\..\cf\make-proto.pl -q -P remove -o $(OBJ)\der-protos.h $(libasn1_SOURCES) || $(RM) $(OBJ)\der-protos.h
291
292$(OBJ)\der-private.h: $(libasn1_SOURCES)
293          $(PERL) ..\..\cf\make-proto.pl -q -P remove -p $(OBJ)\der-private.h $(libasn1_SOURCES) || $(RM) $(OBJ)\der-private.h
294
295clean::
296          -$(RM) $(INCDIR)\der-protos.h
297
298all:: $(INCFILES) $(GENINCFILES) $(ASN1_BINARIES) $(LIBASN1)
299
300all-tools:: $(LIBEXECDIR)\asn1_print.exe $(BINDIR)\asn1_gen.exe
301
302clean::
303          -$(RM) $(INCFILES)
304          -$(RM) $(GENINCFILES)
305          -$(RM) $(ASN1_BINARIES:.exe=.*)
306          -$(RM) $(LIBASN1)
307          -$(RM) $(LIBEXECDIR)\asn1_print.*
308          -$(RM) $(LIBEXECDIR)\asn1_gen.*
309
310TEST_BINARIES=\
311          $(OBJ)\check-der.exe          \
312          $(OBJ)\check-gen.exe          \
313          $(OBJ)\check-timegm.exe \
314          $(OBJ)\check-ber.exe          \
315          $(OBJ)\check-template.exe \
316
317test-binaries: $(TEST_BINARIES)
318
319test-run:
320          cd $(OBJ)
321          -check-der.exe
322          -check-gen.exe
323          -check-timegm.exe
324          -check-ber.exe
325          -check-template.exe
326          cd $(SRC)
327
328test:: test-binaries test-run
329
330clean::
331          -$(RM) $(TEST_BINARIES:.exe=*)
332
333$(OBJ)\check-ber.exe: $(OBJ)\check-ber.obj \
334                    $(LIBHEIMDAL) $(LIBROKEN)
335          $(EXECONLINK)
336          $(EXEPREP_NODIST)
337
338$(OBJ)\check-der.exe: $(OBJ)\check-der.obj $(OBJ)\check-common.obj \
339                    $(LIBHEIMDAL) $(LIBROKEN)
340          $(EXECONLINK)
341          $(EXEPREP_NODIST)
342
343$(OBJ)\check-gen.exe: $(OBJ)\check-gen.obj $(OBJ)\check-common.obj \
344                    $(LIBHEIMDAL) $(LIBROKEN) $(gen_files_test:.x=.obj)
345          $(EXECONLINK)
346          $(EXEPREP_NODIST)
347
348$(OBJ)\check-timegm.exe: $(OBJ)\check-timegm.obj \
349                    $(LIBHEIMDAL) $(LIBROKEN)
350          $(EXECONLINK)
351          $(EXEPREP_NODIST)
352
353$(OBJ)\check-template.exe: $(OBJ)\check-template.obj $(OBJ)\check-common.obj \
354                    $(LIBHEIMDAL) $(LIBROKEN) $(gen_files_test:.x=.obj)
355          $(EXECONLINK)
356          $(EXEPREP_NODIST)
357