Propagate BUILDENV into subdirectories.
[openssl.git] / crypto / Makefile
1 #
2 # SSLeay/crypto/Makefile
3 #
4
5 DIR=            crypto
6 TOP=            ..
7 CC=             cc
8 INCLUDE=        -I. -I$(TOP) -I../include
9 # INCLUDES targets sudbirs!
10 INCLUDES=       -I.. -I../.. -I../../include
11 CFLAG=          -g
12 MAKEDEPPROG=    makedepend
13 MAKEDEPEND=     $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
14 MAKEFILE=       Makefile
15 RM=             rm -f
16 AR=             ar r
17
18 PEX_LIBS=
19 EX_LIBS=
20  
21 CFLAGS= $(INCLUDE) $(CFLAG)
22 ASFLAGS= $(INCLUDE) $(ASFLAG)
23 AFLAGS=$(ASFLAGS)
24
25 LIBS=
26
27 SDIRS=  objects \
28         md2 md4 md5 sha mdc2 hmac ripemd \
29         des rc2 rc4 rc5 idea bf cast \
30         bn ec rsa dsa ecdsa ecdh dh dso engine aes \
31         buffer bio stack lhash rand err \
32         evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
33         store pqueue
34
35 GENERAL=Makefile README crypto-lib.com install.com
36
37 LIB= $(TOP)/libcrypto.a
38 SHARED_LIB= libcrypto$(SHLIB_EXT)
39 LIBSRC= cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c o_time.c o_str.c o_dir.c
40 LIBOBJ= cryptlib.o mem.o mem_clr.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o o_str.o o_dir.o $(CPUID_OBJ)
41
42 SRC= $(LIBSRC)
43
44 EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h symhacks.h \
45         ossl_typ.h
46 HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h $(EXHEADER)
47
48 ALL=    $(GENERAL) $(SRC) $(HEADER)
49
50 top:
51         @(cd ..; $(MAKE) DIRS=$(DIR) all)
52
53 all: shared
54
55 BUILDENV=       PLATFORM='${PLATFORM}' PROCESSOR='${PROCESSOR}' \
56                 CC='${CC}' CFLAG='${CFLAG}'                     \
57                 AS='${CC}' ASFLAG='${CFLAG} -c'                 \
58                 AR='${AR}' PERL='${PERL}' RANLIB='${RANLIB}'    \
59                 SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/lib'           \
60                 INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}'   \
61                 MAKEDEPEND='$$(TOP)/util/domd $$(TOP) -MD $(MAKEDEPPROG)'\
62                 DEPFLAG='-DOPENSSL_NO_DEPRECATED ${DEPFLAG}'    \
63                 MAKEDEPPROG='${MAKEDEPPROG}'                    \
64                 LDFLAGS="$(LDFLAGS)" SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
65                 KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}'   \
66                 EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}'       \
67                 SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' \
68                 PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}'     \
69                 CPUID_OBJ='${CPUID_OBJ}'                        \
70                 BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}'         \
71                 AES_ASM_OBJ='${AES_ASM_OBJ}'                    \
72                 BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}'       \
73                 RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}'       \
74                 SHA1_ASM_OBJ='${SHA1_ASM_OBJ}'                  \
75                 MD5_ASM_OBJ='${MD5_ASM_OBJ}'                    \
76                 RMD160_ASM_OBJ='${RMD160_ASM_OBJ}'              \
77                 THIS=$${THIS:-$@}
78
79 buildinf.h: ../Makefile
80         ( echo "#ifndef MK1MF_BUILD"; \
81         echo '  /* auto-generated by crypto/Makefile for crypto/cversion.c */'; \
82         echo '  #define CFLAGS "$(CC) $(CFLAG)"'; \
83         echo '  #define PLATFORM "$(PLATFORM)"'; \
84         echo "  #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \
85         echo '#endif' ) >buildinf.h
86
87 x86cpuid-elf.s: x86cpuid.pl perlasm/x86asm.pl
88         $(PERL) x86cpuid.pl elf $(CFLAGS) $(PROCESSOR) > $@
89 x86cpuid-cof.s: x86cpuid.pl perlasm/x86asm.pl
90         $(PERL) x86cpuid.pl coff $(CFLAGS) $(PROCESSOR) > $@
91 x86cpuid-out.s: x86cpuid.pl perlasm/x86asm.pl
92         $(PERL) x86cpuid.pl a.out $(CFLAGS) $(PROCESSOR) > $@
93
94 uplink.o:       ../ms/uplink.c
95         $(CC) $(CFLAGS) -c -o $@ ../ms/uplink.c
96
97 uplink-cof.s:   ../ms/uplink.pl
98         $(PERL) ../ms/uplink.pl coff > $@
99
100 x86_64cpuid.s: x86_64cpuid.pl
101         $(PERL) x86_64cpuid.pl $@
102 ia64cpuid.s: ia64cpuid.S
103         $(CC) $(CFLAGS) -E ia64cpuid.S > $@
104
105 testapps:
106         [ -z "$(THIS)" ] || ( if echo ${SDIRS} | fgrep ' des '; \
107         then cd des && $(MAKE) des; fi )
108         [ -z "$(THIS)" ] || ( cd pkcs7 && $(MAKE) testapps );
109         @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
110
111 subdirs:
112         @for i in $(SDIRS) ;\
113         do \
114         (cd $$i && echo "making all in crypto/$$i..." && \
115         $(MAKE) $(BUILDENV) INCLUDES='${INCLUDES}' all ) || exit 1; \
116         done;
117
118 files:
119         $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
120         @for i in $(SDIRS) ;\
121         do \
122         (cd $$i && echo "making 'files' in crypto/$$i..." && \
123         $(MAKE) files ); \
124         done;
125
126 links:
127         @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER)
128         @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST)
129         @$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS)
130         @for i in $(SDIRS); do \
131             (cd $$i && echo "making links in crypto/$$i..." && \
132             $(MAKE) links ); \
133         done;
134
135 lib:    $(LIBOBJ)
136         $(AR) $(LIB) $(LIBOBJ)
137         $(RANLIB) $(LIB) || echo Never mind.
138         @touch lib
139
140 shared: buildinf.h lib subdirs
141         if [ -n "$(SHARED_LIBS)" ]; then \
142                 (cd ..; $(MAKE) $(SHARED_LIB)); \
143         fi
144
145 libs:
146         @for i in $(SDIRS) ;\
147         do \
148         (cd $$i && echo "making libs in crypto/$$i..." && \
149         $(MAKE) lib );
150         done;
151
152 tests:
153         @[ -z "$(THIS)" ] || (for i in $(SDIRS) ;\
154         do \
155         (cd $$i && echo "making tests in crypto/$$i..." && \
156         $(MAKE) tests ); \
157         done; )
158         @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
159
160 install:
161         @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
162         @headerlist="$(EXHEADER)"; for i in $$headerlist ;\
163         do \
164         (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
165         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
166         done;
167         @for i in $(SDIRS) ;\
168         do \
169         (cd $$i && echo "making install in crypto/$$i..." && \
170         $(MAKE) install ); \
171         done;
172
173 lint:
174         @for i in $(SDIRS) ;\
175         do \
176         (cd $$i && echo "making lint in crypto/$$i..." && \
177         $(MAKE) lint ); \
178         done;
179
180 depend:
181         [ -z "$(THIS)" -o -f buildinf.h ] || touch buildinf.h # fake buildinf.h if it does not exist
182         [ -z "$(THIS)" ] || $(MAKEDEPEND) -- $(CFLAG) $(INCLUDE) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
183         [ -z "$(THIS)" -o -s buildinf.h ] || rm buildinf.h
184         @[ -z "$(THIS)" ] || (set -e; \
185         for i in $(SDIRS) ; do \
186             (   cd $$i && echo "making depend in crypto/$$i..." && \
187                 $(MAKE) INCLUDES='${INCLUDES}' depend \
188             ); \
189         done; )
190         @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
191
192 clean:
193         rm -f buildinf.h *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
194         @for i in $(SDIRS) ;\
195         do \
196         (cd $$i && echo "making clean in crypto/$$i..." && \
197         $(MAKE) clean ); \
198         done;
199
200 dclean:
201         $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
202         mv -f Makefile.new $(MAKEFILE)
203         @for i in $(SDIRS) ;\
204         do \
205         (cd $$i && echo "making dclean in crypto/$$i..." && \
206         $(MAKE) dclean ); \
207         done;
208
209 # DO NOT DELETE THIS LINE -- make depend depends on it.
210
211 cpt_err.o: ../include/openssl/bio.h ../include/openssl/crypto.h
212 cpt_err.o: ../include/openssl/e_os2.h ../include/openssl/err.h
213 cpt_err.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
214 cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
215 cpt_err.o: ../include/openssl/safestack.h ../include/openssl/stack.h
216 cpt_err.o: ../include/openssl/symhacks.h cpt_err.c
217 cryptlib.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
218 cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
219 cryptlib.o: ../include/openssl/err.h ../include/openssl/lhash.h
220 cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
221 cryptlib.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
222 cryptlib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.c
223 cryptlib.o: cryptlib.h
224 cversion.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
225 cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
226 cversion.o: ../include/openssl/err.h ../include/openssl/lhash.h
227 cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
228 cversion.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
229 cversion.o: ../include/openssl/stack.h ../include/openssl/symhacks.h buildinf.h
230 cversion.o: cryptlib.h cversion.c
231 ebcdic.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h ebcdic.c
232 ex_data.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
233 ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
234 ex_data.o: ../include/openssl/err.h ../include/openssl/lhash.h
235 ex_data.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
236 ex_data.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
237 ex_data.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
238 ex_data.o: ex_data.c
239 mem.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
240 mem.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
241 mem.o: ../include/openssl/err.h ../include/openssl/lhash.h
242 mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
243 mem.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
244 mem.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
245 mem.o: mem.c
246 mem_clr.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
247 mem_clr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
248 mem_clr.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
249 mem_clr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h mem_clr.c
250 mem_dbg.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
251 mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
252 mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h
253 mem_dbg.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
254 mem_dbg.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
255 mem_dbg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
256 mem_dbg.o: mem_dbg.c
257 o_dir.o: ../e_os.h ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
258 o_dir.o: LPdir_unix.c o_dir.c o_dir.h
259 o_str.o: ../e_os.h ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
260 o_str.o: o_str.c o_str.h
261 o_time.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_time.c
262 o_time.o: o_time.h
263 tmdiff.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
264 tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
265 tmdiff.o: ../include/openssl/err.h ../include/openssl/lhash.h
266 tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
267 tmdiff.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
268 tmdiff.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
269 tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h tmdiff.c
270 uid.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
271 uid.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
272 uid.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
273 uid.o: ../include/openssl/stack.h ../include/openssl/symhacks.h uid.c