aix updates from HEAD.
[oweals/openssl.git] / Makefile.org
1 ##
2 ## Makefile for OpenSSL
3 ##
4
5 VERSION=
6 MAJOR=
7 MINOR=
8 SHLIB_VERSION_NUMBER=
9 SHLIB_VERSION_HISTORY=
10 SHLIB_MAJOR=
11 SHLIB_MINOR=
12 SHLIB_EXT=
13 PLATFORM=dist
14 OPTIONS=
15 CONFIGURE_ARGS=
16 SHLIB_TARGET=
17
18 # HERE indicates where this Makefile lives.  This can be used to indicate
19 # where sub-Makefiles are expected to be.  Currently has very limited usage,
20 # and should probably not be bothered with at all.
21 HERE=.
22
23 # INSTALL_PREFIX is for package builders so that they can configure
24 # for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
25 # Normally it is left empty.
26 INSTALL_PREFIX=
27 INSTALLTOP=/usr/local/ssl
28
29 # Do not edit this manually. Use Configure --openssldir=DIR do change this!
30 OPENSSLDIR=/usr/local/ssl
31
32 # NO_IDEA - Define to build without the IDEA algorithm
33 # NO_RC4  - Define to build without the RC4 algorithm
34 # NO_RC2  - Define to build without the RC2 algorithm
35 # THREADS - Define when building with threads, you will probably also need any
36 #           system defines as well, i.e. _REENTERANT for Solaris 2.[34]
37 # TERMIO  - Define the termio terminal subsystem, needed if sgtty is missing.
38 # TERMIOS - Define the termios terminal subsystem, Silicon Graphics.
39 # LONGCRYPT - Define to use HPUX 10.x's long password modification to crypt(3).
40 # DEVRANDOM - Give this the value of the 'random device' if your OS supports
41 #           one.  32 bytes will be read from this when the random
42 #           number generator is initalised.
43 # SSL_FORBID_ENULL - define if you want the server to be not able to use the
44 #           NULL encryption ciphers.
45 #
46 # LOCK_DEBUG - turns on lots of lock debug output :-)
47 # REF_CHECK - turn on some xyz_free() assertions.
48 # REF_PRINT - prints some stuff on structure free.
49 # CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff
50 # MFUNC - Make all Malloc/Free/Realloc calls call
51 #       CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
52 #       call application defined callbacks via CRYPTO_set_mem_functions()
53 # MD5_ASM needs to be defined to use the x86 assembler for MD5
54 # SHA1_ASM needs to be defined to use the x86 assembler for SHA1
55 # RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160
56 # Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8.  It must
57 # equal 4.
58 # PKCS1_CHECK - pkcs1 tests.
59
60 CC= cc
61 CFLAG= -O
62 DEPFLAG= 
63 PEX_LIBS= 
64 EX_LIBS= 
65 EXE_EXT= 
66 ARFLAGS=
67 AR=ar $(ARFLAGS) r
68 ARD=ar $(ARFLAGS) d
69 RANLIB= ranlib
70 PERL= perl
71 TAR= tar
72 TARFLAGS= --no-recursion
73 MAKEDEPPROG=makedepend
74
75 # We let the C compiler driver to take care of .s files. This is done in
76 # order to be excused from maintaining a separate set of architecture
77 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
78 # gcc, then the driver will automatically translate it to -xarch=v8plus
79 # and pass it down to assembler.
80 AS=$(CC) -c
81 ASFLAG=$(CFLAG)
82
83 # For x86 assembler: Set PROCESSOR to 386 if you want to support
84 # the 80386.
85 PROCESSOR=
86
87 # CPUID module collects small commonly used assembler snippets
88 CPUID_OBJ= 
89 BN_ASM= bn_asm.o
90 FIPS_DES_ENC= des_enc.o fcrypt_b.o
91 FIPS_AES_ENC= fips_aes_core.o
92 DES_ENC= des_enc.o fcrypt_b.o
93 AES_ASM_OBJ=aes_core.o aes_cbc.o
94 BF_ENC= bf_enc.o
95 CAST_ENC= c_enc.o
96 RC4_ENC= rc4_enc.o
97 RC5_ENC= rc5_enc.o
98 MD5_ASM_OBJ= 
99 FIPS_SHA1_ASM_OBJ= 
100 SHA1_ASM_OBJ= 
101 RMD160_ASM_OBJ= 
102
103 # KRB5 stuff
104 KRB5_INCLUDES=
105 LIBKRB5=
106
107 # Zlib stuff
108 ZLIB_INCLUDE=
109 LIBZLIB=
110
111 # This is the location of fipscanister.o and friends.
112 # The FIPS module build will place it $(INSTALLTOP)/lib
113 # but since $(INSTALLTOP) can only take the default value
114 # when the module is built it will be in /usr/local/ssl/lib
115 # $(INSTALLTOP) for this build make be different so hard
116 # code the path.
117
118 FIPSLIBDIR=/usr/local/ssl/lib/
119
120 # This is set to "y" if fipscanister.o is compiled internally as
121 # opposed to coming from an external validated location.
122
123 FIPSCANISTERINTERNAL=n
124
125 # The location of the library which contains fipscanister.o
126 # normally it will be libcrypto unless fipsdso is set in which
127 # case it will be libfips. If not compiling in FIPS mode at all
128 # this is empty making it a useful test for a FIPS compile.
129
130 FIPSCANLIB=
131
132 # Shared library base address. Currently only used on Windows.
133 #
134
135 BASEADDR=
136
137 DIRS=   crypto fips-1.0 ssl engines apps test tools
138 SHLIBDIRS= crypto ssl fips
139
140 # dirs in crypto to build
141 SDIRS=  \
142         objects \
143         md2 md4 md5 sha mdc2 hmac ripemd \
144         des aes rc2 rc4 rc5 idea bf cast camellia \
145         bn ec rsa dsa ecdsa dh ecdh dso engine \
146         buffer bio stack lhash rand err \
147         evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
148         store pqueue
149 # keep in mind that the above list is adjusted by ./Configure
150 # according to no-xxx arguments...
151
152 # tests to perform.  "alltests" is a special word indicating that all tests
153 # should be performed.
154 TESTS = alltests
155
156 MAKEFILE= Makefile
157
158 MANDIR=$(OPENSSLDIR)/man
159 MAN1=1
160 MAN3=3
161 MANSUFFIX=
162 SHELL=/bin/sh
163
164 TOP=    .
165 ONEDIRS=out tmp
166 EDIRS=  times doc bugs util include certs ms shlib mt demos perl sf dep VMS
167 WDIRS=  windows
168 LIBS=   libcrypto.a libssl.a
169 SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
170 SHARED_SSL=libssl$(SHLIB_EXT)
171 SHARED_FIPS=
172 SHARED_LIBS=
173 SHARED_LIBS_LINK_EXTS=
174 SHARED_LDFLAGS=
175
176 GENERAL=        Makefile
177 BASENAME=       openssl
178 NAME=           $(BASENAME)-fips-$(VERSION)
179 TARFILE=        $(NAME).tar
180 WTARFILE=       $(NAME)-win.tar
181 EXHEADER=       e_os2.h
182 HEADER=         e_os.h
183
184 all: Makefile build_all openssl.pc libssl.pc libcrypto.pc
185
186 # as we stick to -e, CLEARENV ensures that local variables in lower
187 # Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
188 # shell, which [annoyingly enough] terminates unset with error if VAR
189 # is not present:-( TOP= && unset TOP is tribute to HP-UX /bin/sh,
190 # which terminates unset with error if no variable was present:-(
191 CLEARENV=       TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS}     \
192                 $${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}       \
193                 $${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}           \
194                 $${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL} \
195                 $${EXHEADER+EXHEADER} $${HEADER+HEADER}         \
196                 $${GENERAL+GENERAL} $${CFLAGS+CFLAGS}           \
197                 $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}           \
198                 $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS}             \
199                 $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}     \
200                 $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
201
202 BUILDENV=       PLATFORM='${PLATFORM}' PROCESSOR='${PROCESSOR}' \
203                 CC='${CC}' CFLAG='${CFLAG}'                     \
204                 AS='${CC}' ASFLAG='${CFLAG} -c'                 \
205                 AR='${AR}' PERL='${PERL}' RANLIB='${RANLIB}'    \
206                 SDIRS='${SDIRS}' LIBRPATH='${INSTALLTOP}/lib'   \
207                 INSTALL_PREFIX='${INSTALL_PREFIX}'              \
208                 INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}'   \
209                 MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD ${MAKEDEPPROG}' \
210                 DEPFLAG='-DOPENSSL_NO_DEPRECATED ${DEPFLAG}'    \
211                 MAKEDEPPROG='${MAKEDEPPROG}'                    \
212                 SHARED_LDFLAGS='${SHARED_LDFLAGS}'              \
213                 KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}'   \
214                 EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}'       \
215                 SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' \
216                 PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}'     \
217                 CPUID_OBJ='${CPUID_OBJ}'                        \
218                 BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}'         \
219                 AES_ASM_OBJ='${AES_ASM_OBJ}'                    \
220                 BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}'       \
221                 RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}'       \
222                 SHA1_ASM_OBJ='${SHA1_ASM_OBJ}'                  \
223                 MD5_ASM_OBJ='${MD5_ASM_OBJ}'                    \
224                 RMD160_ASM_OBJ='${RMD160_ASM_OBJ}'              \
225                 FIPS_SHA1_ASM_OBJ='${FIPS_SHA1_ASM_OBJ}'        \
226                 FIPS_DES_ENC='${FIPS_DES_ENC}'                  \
227                 FIPS_AES_ENC='${FIPS_AES_ENC}'                  \
228                 FIPSLIBDIR='${FIPSLIBDIR}' FIPSCANLIB='${FIPSCANLIB}' \
229                 FIPSCANISTERINTERNAL='${FIPSCANISTERINTERNAL}'  \
230                 FIPS_EX_OBJ='${FIPS_EX_OBJ}'    \
231                 THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
232 # MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
233 # which in turn eliminates ambiguities in variable treatment with -e.
234
235 # BUILD_CMD is a generic macro to build a given target in a given
236 # subdirectory.  The target must be given through the shell variable
237 # `target' and the subdirectory to build in must be given through `dir'.
238 # This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
239 # BUILD_ONE_CMD instead.
240 #
241 # BUILD_ONE_CMD is a macro to build a given target in a given
242 # subdirectory if that subdirectory is part of $(DIRS).  It requires
243 # exactly the same shell variables as BUILD_CMD.
244 #
245 # RECURSIVE_BUILD_CMD is a macro to build a given target in all
246 # subdirectories defined in $(DIRS).  It requires that the target
247 # is given through the shell variable `target'.
248 BUILD_CMD=  if [ -d "$$dir" ]; then \
249             (   cd $$dir && echo "making $$target in $$dir..." && \
250                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
251             ) || exit 1; \
252             fi
253 RECURSIVE_BUILD_CMD=for dir in $(DIRS); do $(BUILD_CMD); done
254 BUILD_ONE_CMD=\
255         if echo " $(DIRS) " | grep " $$dir " >/dev/null 2>/dev/null; then \
256                 $(BUILD_CMD); \
257         fi
258
259 reflect:
260         @[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
261
262 FIPS_EX_OBJ= ../crypto/aes/aes_cbc.o \
263         ../crypto/aes/aes_cfb.o \
264         ../crypto/aes/aes_ecb.o \
265         ../crypto/aes/aes_ofb.o \
266         ../crypto/bn/bn_add.o \
267         ../crypto/bn/bn_blind.o \
268         ../crypto/bn/bn_ctx.o \
269         ../crypto/bn/bn_div.o \
270         ../crypto/bn/bn_exp2.o \
271         ../crypto/bn/bn_exp.o \
272         ../crypto/bn/bn_gcd.o \
273         ../crypto/bn/bn_lib.o \
274         ../crypto/bn/bn_mod.o \
275         ../crypto/bn/bn_mont.o \
276         ../crypto/bn/bn_mul.o \
277         ../crypto/bn/bn_prime.o \
278         ../crypto/bn/bn_rand.o \
279         ../crypto/bn/bn_recp.o \
280         ../crypto/bn/bn_shift.o \
281         ../crypto/bn/bn_sqr.o \
282         ../crypto/bn/bn_word.o \
283         ../crypto/bn/bn_x931p.o \
284         ../crypto/buffer/buf_str.o \
285         ../crypto/cryptlib.o \
286         ../crypto/des/cfb64ede.o \
287         ../crypto/des/cfb64enc.o \
288         ../crypto/des/cfb_enc.o \
289         ../crypto/des/des_enc.o \
290         ../crypto/des/ecb3_enc.o \
291         ../crypto/des/ecb_enc.o \
292         ../crypto/des/ofb64ede.o \
293         ../crypto/des/ofb64enc.o \
294         ../crypto/des/fcrypt_b.o \
295         ../crypto/des/fcrypt.o \
296         ../crypto/dsa/dsa_utl.o \
297         ../crypto/dsa/dsa_sign.o \
298         ../crypto/dsa/dsa_vrf.o \
299         ../crypto/err/err.o \
300         ../crypto/evp/digest.o \
301         ../crypto/evp/m_sha1.o \
302         ../crypto/evp/p_sign.o \
303         ../crypto/evp/p_verify.o \
304         ../crypto/mem_clr.o \
305         ../crypto/mem.o \
306         ../crypto/rand/md_rand.o \
307         ../crypto/rand/rand_egd.o \
308         ../crypto/rand/randfile.o \
309         ../crypto/rand/rand_lib.o \
310         ../crypto/rand/rand_os2.o \
311         ../crypto/rand/rand_unix.o \
312         ../crypto/rand/rand_win.o \
313         ../crypto/rsa/rsa_lib.o \
314         ../crypto/rsa/rsa_none.o \
315         ../crypto/rsa/rsa_oaep.o \
316         ../crypto/rsa/rsa_pk1.o \
317         ../crypto/rsa/rsa_pss.o \
318         ../crypto/rsa/rsa_ssl.o \
319         ../crypto/rsa/rsa_x931.o \
320         ../crypto/uid.o
321
322 sub_all: build_all
323 build_all: build_libs build_apps build_tests build_tools
324
325 build_libs: build_crypto build_fips build_ssl build_engines
326
327 build_crypto:
328         if [ -n "$(FIPSCANLIB)" ]; then \
329                 EXCL_OBJ='$(BN_ASM) $(CPUID_OBJ) $(FIPS_EX_OBJ)' ; export EXCL_OBJ ; \
330                 ARX='$(PERL) $${TOP}/util/arx.pl $(AR)' ; \
331         else \
332                 ARX='${AR}' ; \
333         fi ; export ARX ; \
334                 dir=crypto; target=all; $(BUILD_ONE_CMD)
335 build_fips:
336         @dir=fips-1.0; target=all; $(BUILD_ONE_CMD)
337 build_ssl:
338         @dir=ssl; target=all; $(BUILD_ONE_CMD)
339 build_engines:
340         @dir=engines; target=all; $(BUILD_ONE_CMD)
341 build_apps:
342         @dir=apps; target=all; $(BUILD_ONE_CMD)
343 build_tests:
344         @dir=test; target=all; $(BUILD_ONE_CMD)
345 build_tools:
346         @dir=tools; target=all; $(BUILD_ONE_CMD)
347
348 all_testapps: build_libs build_testapps
349 build_testapps:
350         @dir=crypto; target=testapps; $(BUILD_ONE_CMD)
351
352 libcrypto$(SHLIB_EXT): libcrypto.a $(SHARED_FIPS)
353         @if [ "$(SHLIB_TARGET)" != "" ]; then \
354                 if [ "$(FIPSCANLIB)" = "libfips" ]; then \
355                         ( dir=fips-1.0; target=all; $(BUILD_ONE_CMD) ) ; \
356                         $(ARD) libcrypto.a fipscanister.o ; \
357                         $(MAKE) SHLIBDIRS='crypto' SHLIBDEPS='-lfips' build-shared; \
358                         $(AR) libcrypto.a fips-1.0/fipscanister.o ; \
359                 else \
360                         $(MAKE) SHLIBDIRS='crypto' build-shared; \
361                 fi \
362         else \
363                 echo "There's no support for shared libraries on this platform" >&2; \
364         fi
365
366 libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
367         @if [ "$(SHLIB_TARGET)" != "" ]; then \
368                 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
369         else \
370                 echo "There's no support for shared libraries on this platform" >&2 ; \
371                 exit 1; \
372         fi
373
374 libfips$(SHLIB_EXT): libfips.a
375         @if [ "$(SHLIB_TARGET)" != "" ]; then \
376                 if [ "$(FIPSCANLIB)" = "libfips" ]; then \
377                         FIPSLD_CC=$(CC); CC=fips-1.0/fipsld; FIPSLD_NPT="y"; \
378                         FIPSLD_LIBFIPS=y; \
379                         export CC FIPSLD_CC FIPSLD_NPT FIPSLD_LIBFIPS; \
380                 fi; \
381                 $(MAKE) -e SHLIBDIRS=fips build-shared; \
382         else \
383                 echo "There's no support for shared libraries on this platform" >&2; \
384         fi
385
386 libfips.a:
387         dir=fips-1.0; target=all; $(BUILD_ONE_CMD)
388
389 clean-shared:
390         @set -e; for i in $(SHLIBDIRS); do \
391                 if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
392                         tmp="$(SHARED_LIBS_LINK_EXTS)"; \
393                         for j in $${tmp:-x}; do \
394                                 ( set -x; rm -f lib$$i$$j ); \
395                         done; \
396                 fi; \
397                 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
398                 if [ "$(PLATFORM)" = "Cygwin" ]; then \
399                         ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
400                 fi; \
401         done
402
403 link-shared:
404         @ set -e; for i in ${SHLIBDIRS}; do \
405                 $(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
406                         LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
407                         LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
408                         symlink.$(SHLIB_TARGET); \
409                 libs="$$libs -l$$i"; \
410         done
411
412 build-shared: do_$(SHLIB_TARGET) link-shared
413
414 do_$(SHLIB_TARGET):
415         @ set -e; libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
416                 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
417                         libs="$(LIBKRB5) $$libs"; \
418                 fi; \
419                 $(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
420                         LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
421                         LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
422                         LIBDEPS="$$libs $(EX_LIBS)" \
423                         link_a.$(SHLIB_TARGET); \
424                 libs="-l$$i $$libs"; \
425         done
426
427 libcrypto.pc: Makefile
428         @ ( echo 'prefix=$(INSTALLTOP)'; \
429             echo 'exec_prefix=$${prefix}'; \
430             echo 'libdir=$${exec_prefix}/lib'; \
431             echo 'includedir=$${prefix}/include'; \
432             echo ''; \
433             echo 'Name: OpenSSL-libcrypto'; \
434             echo 'Description: OpenSSL cryptography library'; \
435             echo 'Version: '$(VERSION); \
436             echo 'Requires: '; \
437             echo 'Libs: -L$${libdir} -lcrypto $(EX_LIBS)'; \
438             echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libcrypto.pc
439
440 libssl.pc: Makefile
441         @ ( echo 'prefix=$(INSTALLTOP)'; \
442             echo 'exec_prefix=$${prefix}'; \
443             echo 'libdir=$${exec_prefix}/lib'; \
444             echo 'includedir=$${prefix}/include'; \
445             echo ''; \
446             echo 'Name: OpenSSL'; \
447             echo 'Description: Secure Sockets Layer and cryptography libraries'; \
448             echo 'Version: '$(VERSION); \
449             echo 'Requires: '; \
450             echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
451             echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc
452
453 openssl.pc: Makefile
454         @ ( echo 'prefix=$(INSTALLTOP)'; \
455             echo 'exec_prefix=$${prefix}'; \
456             echo 'libdir=$${exec_prefix}/lib'; \
457             echo 'includedir=$${prefix}/include'; \
458             echo ''; \
459             echo 'Name: OpenSSL'; \
460             echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
461             echo 'Version: '$(VERSION); \
462             echo 'Requires: '; \
463             echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
464             echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
465
466 Makefile: Makefile.org Configure config
467         @echo "Makefile is older than Makefile.org, Configure or config."
468         @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
469         @false
470
471 libclean:
472         rm -f *.map *.so *.so.* *.dll engines/*.so engines/*.dll *.a engines/*.a */lib */*/lib
473
474 clean:  libclean
475         rm -f shlib/*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
476         @set -e; target=clean; $(RECURSIVE_BUILD_CMD)
477         rm -f $(LIBS)
478         rm -f openssl.pc libssl.pc libcrypto.pc
479         rm -f speed.* .pure
480         rm -f $(TARFILE)
481         @set -e; for i in $(ONEDIRS) ;\
482         do \
483         rm -fr $$i/*; \
484         done
485
486 makefile.one: files
487         $(PERL) util/mk1mf.pl >makefile.one; \
488         sh util/do_ms.sh
489
490 files:
491         $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
492         @set -e; target=files; $(RECURSIVE_BUILD_CMD)
493
494 links:
495         @$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
496         @$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
497         @set -e; target=links; $(RECURSIVE_BUILD_CMD)
498
499 gentests:
500         @(cd test && echo "generating dummy tests (if needed)..." && \
501         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on generate );
502
503 dclean:
504         rm -f *.bak
505         @set -e; target=dclean; $(RECURSIVE_BUILD_CMD)
506
507 rehash: rehash.time
508 rehash.time: certs
509         @(OPENSSL="`pwd`/util/opensslwrap.sh"; \
510           OPENSSL_DEBUG_MEMORY=on; \
511           export OPENSSL OPENSSL_DEBUG_MEMORY; \
512           $(PERL) tools/c_rehash certs)
513         touch rehash.time
514
515 test:   tests
516
517 tests: rehash
518         @(cd test && echo "testing..." && \
519         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on tests );
520         util/opensslwrap.sh version -a
521
522 report:
523         @$(PERL) util/selftest.pl
524
525 depend:
526         @set -e; target=depend; $(RECURSIVE_BUILD_CMD)
527
528 lint:
529         @set -e; target=lint; $(RECURSIVE_BUILD_CMD)
530
531 tags:
532         rm -f TAGS
533         find . -name '[^.]*.[ch]' | xargs etags -a
534
535 errors:
536         $(PERL) util/mkerr.pl -recurse -write
537         (cd engines; $(MAKE) PERL=$(PERL) errors)
538         $(PERL) util/ck_errf.pl */*.c */*/*.c
539
540 stacks:
541         $(PERL) util/mkstack.pl -write
542
543 util/libeay.num::
544         $(PERL) util/mkdef.pl crypto update
545
546 util/ssleay.num::
547         $(PERL) util/mkdef.pl ssl update
548
549 crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl crypto/objects/obj_mac.h
550         $(PERL) crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
551 crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
552         $(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
553
554 apps/openssl-vms.cnf: apps/openssl.cnf
555         $(PERL) VMS/VMSify-conf.pl < apps/openssl.cnf > apps/openssl-vms.cnf
556
557 crypto/bn/bn_prime.h: crypto/bn/bn_prime.pl
558         $(PERL) crypto/bn/bn_prime.pl >crypto/bn/bn_prime.h
559
560
561 TABLE: Configure
562         (echo 'Output of `Configure TABLE'"':"; \
563         $(PERL) Configure TABLE) > TABLE
564
565 update: errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h apps/openssl-vms.cnf crypto/bn/bn_prime.h TABLE depend
566
567 # Build distribution tar-file. As the list of files returned by "find" is
568 # pretty long, on several platforms a "too many arguments" error or similar
569 # would occur. Therefore the list of files is temporarily stored into a file
570 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
571 # tar does not support the --files-from option.
572 tar:
573         find . -type d -print | xargs chmod 755
574         find . -type f -print | xargs chmod a+r
575         find . -type f -perm -0100 -print | xargs chmod a+x
576         find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
577         $(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
578         tardy --user_number=0  --user_name=openssl \
579               --group_number=0 --group_name=openssl \
580               --prefix=openssl-fips-$(VERSION) - |\
581         gzip --best >../$(TARFILE).gz; \
582         rm -f ../$(TARFILE).list; \
583         ls -l ../$(TARFILE).gz
584
585 tar-snap:
586         @$(TAR) $(TARFLAGS) -cvf - \
587                 `find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \! -name '*.so' \! -name '*.so.*'  \! -name 'openssl' \! -name '*test' \! -name '.#*' \! -name '*~' | sort` |\
588         tardy --user_number=0  --user_name=openssl \
589               --group_number=0 --group_name=openssl \
590               --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
591         ls -l ../$(TARFILE)
592
593 dist:   
594         $(PERL) Configure dist
595         @$(MAKE) dist_pem_h
596         @$(MAKE) SDIRS='${SDIRS}' clean
597         @$(MAKE) TAR='${TAR}' TARFLAGS='${TARFLAGS}' tar
598
599 dist_pem_h:
600         (cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
601
602 install: all install_docs install_sw
603
604 install_sw:
605         @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
606                 $(INSTALL_PREFIX)$(INSTALLTOP)/lib \
607                 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/engines \
608                 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig \
609                 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
610                 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
611                 $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
612                 $(INSTALL_PREFIX)$(OPENSSLDIR)/private
613         @set -e; headerlist="$(EXHEADER)"; for i in $$headerlist;\
614         do \
615         (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
616         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
617         done;
618         @set -e; target=install; $(RECURSIVE_BUILD_CMD)
619         @set -e; for i in $(LIBS) ;\
620         do \
621                 if [ -f "$$i" ]; then \
622                 (       echo installing $$i; \
623                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
624                         $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
625                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
626                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
627                 fi; \
628         done;
629         @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
630                 tmp="$(SHARED_LIBS)"; \
631                 for i in $${tmp:-x}; \
632                 do \
633                         if [ -f "$$i" -o -f "$$i.a" ]; then \
634                         (       echo installing $$i; \
635                                 if [ "$(PLATFORM)" != "Cygwin" ]; then \
636                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
637                                         chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
638                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
639                                 else \
640                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
641                                         cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
642                                         chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
643                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
644                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
645                                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
646                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
647                                 fi ); \
648                         fi; \
649                 done; \
650                 (       here="`pwd`"; \
651                         cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
652                         $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
653                 if [ "$(INSTALLTOP)" != "/usr" ]; then \
654                         echo 'OpenSSL shared libraries have been installed in:'; \
655                         echo '  $(INSTALLTOP)'; \
656                         echo ''; \
657                         sed -e '1,/^$$/d' doc/openssl-shared.txt; \
658                 fi; \
659         fi
660         cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
661         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig/libcrypto.pc
662         cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
663         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig/libssl.pc
664         cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
665         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig/openssl.pc
666
667 install_docs:
668         @$(PERL) $(TOP)/util/mkdir-p.pl \
669                 $(INSTALL_PREFIX)$(MANDIR)/man1 \
670                 $(INSTALL_PREFIX)$(MANDIR)/man3 \
671                 $(INSTALL_PREFIX)$(MANDIR)/man5 \
672                 $(INSTALL_PREFIX)$(MANDIR)/man7
673         @pod2man="`cd util; ./pod2mantest $(PERL)`"; \
674         here="`pwd`"; \
675         filecase=; \
676         if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" -o "$(PLATFORM)" = "mingw" ]; then \
677                 filecase=-i; \
678         fi; \
679         set -e; for i in doc/apps/*.pod; do \
680                 fn=`basename $$i .pod`; \
681                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
682                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
683                 (cd `$(PERL) util/dirname.pl $$i`; \
684                 sh -c "$$pod2man \
685                         --section=$$sec --center=OpenSSL \
686                         --release=$(VERSION) `basename $$i`") \
687                         >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
688                 $(PERL) util/extract-names.pl < $$i | \
689                         (grep -v $$filecase "^$$fn\$$"; true) | \
690                         (grep -v "[     ]"; true) | \
691                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
692                          while read n; do \
693                                 $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
694                          done); \
695         done; \
696         set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
697                 fn=`basename $$i .pod`; \
698                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
699                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
700                 (cd `$(PERL) util/dirname.pl $$i`; \
701                 sh -c "$$pod2man \
702                         --section=$$sec --center=OpenSSL \
703                         --release=$(VERSION) `basename $$i`") \
704                         >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
705                 $(PERL) util/extract-names.pl < $$i | \
706                         (grep -v $$filecase "^$$fn\$$"; true) | \
707                         (grep -v "[     ]"; true) | \
708                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
709                          while read n; do \
710                                 $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
711                          done); \
712         done
713
714 # DO NOT DELETE THIS LINE -- make depend depends on it.