1########################################################################
2#
3# Copyright (c) 2009-2017, 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\hx509
33intcflags=-I$(OBJ)
34localcflags=-DASN1_LIB
35
36!include ../../windows/NTMakefile.w32
37
38gen_files_ocsp = $(OBJ)\asn1_ocsp_asn1.x
39
40gen_files_pkcs10 = $(OBJ)\asn1_pkcs10_asn1.x
41
42gen_files_crmf = $(OBJ)\asn1_crmf_asn1.x
43
44libhx509_la_OBJS =                      \
45          $(OBJ)\ca.obj                           \
46          $(OBJ)\cert.obj                         \
47          $(OBJ)\cms.obj                          \
48          $(OBJ)\collector.obj                    \
49          $(OBJ)\crypto.obj             \
50          $(OBJ)\crypto-ec.obj                    \
51          $(OBJ)\error.obj              \
52          $(OBJ)\env.obj                          \
53          $(OBJ)\file.obj                         \
54          $(OBJ)\hx509_err.obj                    \
55          $(OBJ)\sel.obj                          \
56          $(OBJ)\sel-gram.obj           \
57          $(OBJ)\sel-lex.obj            \
58          $(OBJ)\keyset.obj             \
59          $(OBJ)\ks_dir.obj             \
60          $(OBJ)\ks_file.obj            \
61          $(OBJ)\ks_mem.obj             \
62          $(OBJ)\ks_null.obj            \
63          $(OBJ)\ks_p11.obj             \
64          $(OBJ)\ks_p12.obj             \
65          $(OBJ)\ks_keychain.obj                  \
66          $(OBJ)\lock.obj                         \
67          $(OBJ)\name.obj                         \
68          $(OBJ)\peer.obj                         \
69          $(OBJ)\print.obj              \
70          $(OBJ)\softp11.obj            \
71          $(OBJ)\req.obj                          \
72          $(OBJ)\revoke.obj             \
73          $(gen_files_ocsp:.x=.obj)     \
74          $(gen_files_pkcs10:.x=.obj)
75
76$(LIBHX509): $(libhx509_la_OBJS)
77          $(LIBCON)
78
79dist_libhx509_la_SOURCES =    \
80          $(SRCDIR)\ca.c                \
81          $(SRCDIR)\cert.c    \
82          $(SRCDIR)\cms.c               \
83          $(SRCDIR)\collector.c         \
84          $(SRCDIR)\crypto.c  \
85          $(SRCDIR)\crypto-ec.c         \
86          $(SRCDIR)\doxygen.c \
87          $(SRCDIR)\error.c   \
88          $(SRCDIR)\env.c               \
89          $(SRCDIR)\file.c    \
90          $(SRCDIR)\hx509.h   \
91          $(SRCDIR)\hx_locl.h \
92          $(SRCDIR)\sel.c               \
93          $(SRCDIR)\sel.h               \
94          $(SRCDIR)\sel-gram.y          \
95          $(SRCDIR)\sel-lex.l \
96          $(SRCDIR)\keyset.c  \
97          $(SRCDIR)\ks_dir.c  \
98          $(SRCDIR)\ks_file.c \
99          $(SRCDIR)\ks_mem.c  \
100          $(SRCDIR)\ks_null.c \
101          $(SRCDIR)\ks_p11.c  \
102          $(SRCDIR)\ks_p12.c  \
103          $(SRCDIR)\ks_keychain.c \
104          $(SRCDIR)\lock.c    \
105          $(SRCDIR)\name.c    \
106          $(SRCDIR)\peer.c    \
107          $(SRCDIR)\print.c   \
108          $(SRCDIR)\softp11.c \
109          $(SRCDIR)\ref\pkcs11.h        \
110          $(SRCDIR)\req.c               \
111          $(SRCDIR)\revoke.c
112
113asn1_compile=$(BINDIR)\asn1_compile.exe
114
115$(gen_files_ocsp:.x=.c): $$(@R).x
116
117$(gen_files_pkcs10:.x=.c): $$(@R).x
118
119$(gen_files_crmf:.x=.c): $$(@R).x
120
121$(gen_files_ocsp) $(OBJ)\ocsp_asn1.hx: $(asn1_compile) ocsp.asn1
122          cd $(OBJ)
123          $(asn1_compile) --one-code-file \
124                    --preserve-binary=OCSPTBSRequest \
125                    --preserve-binary=OCSPResponseData \
126                    $(SRCDIR)\ocsp.asn1 ocsp_asn1 \
127          || ( $(RM) -f $(gen_files_ocsp) $(OBJ)\ocsp_asn1.h ; exit /b 1 )
128          cd $(SRCDIR)
129
130$(gen_files_pkcs10) $(OBJ)\pkcs10_asn1.hx: $(asn1_compile) pkcs10.asn1
131          cd $(OBJ)
132          $(asn1_compile) --one-code-file \
133                    --preserve-binary=CertificationRequestInfo \
134                    $(SRCDIR)\pkcs10.asn1 pkcs10_asn1 \
135          || ( $(RM) -f $(gen_files_pkcs10) $(OBJ)\pkcs10_asn1.h ; exit /b 1 )
136          cd $(SRCDIR)
137
138$(gen_files_crmf) $(OBJ)\crmf_asn1.hx: $(asn1_compile) crmf.asn1
139          cd $(OBJ)
140          $(asn1_compile) --one-code-file $(SRCDIR)\crmf.asn1 crmf_asn1 \
141          || ( $(RM) -f $(gen_files_crmf) $(OBJ)\crmf_asn1.h ; exit /b 1 )
142          cd $(SRCDIR)
143
144INCFILES=                         \
145          $(INCDIR)\hx509.h       \
146          $(INCDIR)\hx509-protos.h    \
147          $(INCDIR)\hx509-private.h   \
148          $(INCDIR)\hx509_err.h             \
149          $(INCDIR)\ocsp_asn1.h             \
150          $(INCDIR)\pkcs10_asn1.h           \
151          $(INCDIR)\crmf_asn1.h             \
152          $(OBJ)\ocsp_asn1-priv.h           \
153          $(OBJ)\pkcs10_asn1-priv.h   \
154          $(OBJ)\crmf_asn1-priv.h
155
156hxtool.c: $(OBJ)\hxtool-commands.h
157
158SLC=$(BINDIR)\slc.exe
159
160$(OBJ)\hxtool-commands.c $(OBJ)\hxtool-commands.h: hxtool-commands.in $(SLC)
161          cd $(OBJ)
162          $(CP) $(SRCDIR)\hxtool-commands.in $(OBJ)\hxtool-commands.in
163          $(SLC) hxtool-commands.in
164          cd $(SRCDIR)
165
166$(BINDIR)\hxtool.exe: $(OBJ)\tool\hxtool.obj $(OBJ)\tool\hxtool-commands.obj $(LIBHEIMDAL) $(OBJ)\hxtool-version.res
167          $(EXECONLINK) $(LIBHEIMDAL) $(LIBROKEN) $(LIBSL) $(LIBVERS) $(LIBCOMERR) $(LIB_openssl_crypto)
168          $(EXEPREP)
169
170$(OBJ)\hx509-protos.h:
171          cd $(OBJ)
172          $(PERL) $(SRCDIR)\..\..\cf\make-proto.pl -R "^(_|^C)" -E HX509_LIB -q -P remove -o hx509-protos.h $(dist_libhx509_la_SOURCES) || $(RM) -f hx509-protos.h
173          cd $(SRCDIR)
174
175$(OBJ)\hx509-private.h:
176          cd $(OBJ)
177          $(PERL) $(SRCDIR)\..\..\cf\make-proto.pl -q -P remove -p hx509-private.h $(dist_libhx509_la_SOURCES) || $(RM) -f hx509-private.h
178          cd $(SRCDIR)
179
180$(OBJ)\hx509_err.c $(OBJ)\hx509_err.h: hx509_err.et
181          cd $(OBJ)
182          $(BINDIR)\compile_et.exe $(SRCDIR)\hx509_err.et
183          cd $(SRCDIR)
184
185$(OBJ)\sel-gram.obj: $(OBJ)\sel-gram.c
186          $(C2OBJ) -I$(SRCDIR)
187
188$(OBJ)\sel-lex.obj: $(OBJ)\sel-lex.c
189          $(C2OBJ) -I$(SRCDIR) -I$(OBJ) -DYY_NO_UNISTD_H
190
191$(OBJ)\sel-gram.c: sel-gram.y
192          $(YACC) -o $@ --defines=$(OBJ)\sel-gram.h sel-gram.y
193
194$(OBJ)\sel-lex.c: sel-lex.l
195          $(LEX) -P_hx509_sel_yy -o$@ sel-lex.l
196
197all:: $(INCFILES) $(LIBHX509)
198
199prep:: mktooldir
200
201mktooldir:
202!  if !exist($(OBJ)\tool)
203          $(MKDIR) $(OBJ)\tool
204!  endif
205
206all-tools:: $(BINDIR)\hxtool.exe
207
208clean::
209          -$(RM) $(BINDIR)\hxtool.*
210          -$(RM) $(OBJ)\tool\*.*
211
212{}.c{$(OBJ)\tool}.obj::
213          $(C2OBJ_C) /Fd$(OBJ)\tool\ /Fo$(OBJ)\tool\ $(MPOPT) /UASN1_LIB $<
214
215{$(OBJ)}.c{$(OBJ)\tool}.obj::
216          $(C2OBJ_C) /Fd$(OBJ)\tool\ /Fo$(OBJ)\tool\ $(MPOPT) /UASN1_LIB $<
217
218