Dead code removal: #if 0 asn1, pkcs7
[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 RANLIB= ranlib
69 NM= nm
70 PERL= perl
71 #RM= echo --
72 RM= rm -f
73 TAR= tar
74 TARFLAGS= --no-recursion
75 MAKEDEPPROG=makedepend
76 LIBDIR=lib
77
78 # We let the C compiler driver to take care of .s files. This is done in
79 # order to be excused from maintaining a separate set of architecture
80 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
81 # gcc, then the driver will automatically translate it to -xarch=v8plus
82 # and pass it down to assembler.
83 AS=$(CC) -c
84 ASFLAG=$(CFLAG)
85
86 # For x86 assembler: Set PROCESSOR to 386 if you want to support
87 # the 80386.
88 PROCESSOR=
89
90 # CPUID module collects small commonly used assembler snippets
91 CPUID_OBJ= 
92 BN_ASM= bn_asm.o
93 EC_ASM=
94 DES_ENC= des_enc.o fcrypt_b.o
95 AES_ENC= aes_core.o aes_cbc.o
96 BF_ENC= bf_enc.o
97 CAST_ENC= c_enc.o
98 RC4_ENC= rc4_enc.o
99 RC5_ENC= rc5_enc.o
100 MD5_ASM_OBJ= 
101 SHA1_ASM_OBJ= 
102 RMD160_ASM_OBJ= 
103 WP_ASM_OBJ=
104 CMLL_ENC=
105 MODES_ASM_OBJ=
106 ENGINES_ASM_OBJ=
107 PERLASM_SCHEME=
108
109 # KRB5 stuff
110 KRB5_INCLUDES=
111 LIBKRB5=
112
113 # Zlib stuff
114 ZLIB_INCLUDE=
115 LIBZLIB=
116
117 # This is the location of fipscanister.o and friends.
118 # The FIPS module build will place it $(INSTALLTOP)/lib
119 # but since $(INSTALLTOP) can only take the default value
120 # when the module is built it will be in /usr/local/ssl/lib
121 # $(INSTALLTOP) for this build may be different so hard
122 # code the path.
123
124 FIPSLIBDIR=/usr/local/ssl/$(LIBDIR)/
125
126 # The location of the library which contains fipscanister.o
127 # normally it will be libcrypto. If not compiling in FIPS mode
128 # at all 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 ssl engines apps test tools
138 ENGDIRS= ccgost
139 SHLIBDIRS= crypto ssl
140
141 # dirs in crypto to build
142 SDIRS=  \
143         objects \
144         md2 md4 md5 sha mdc2 hmac ripemd whrlpool \
145         des aes rc2 rc4 rc5 idea bf cast camellia seed modes \
146         bn ec rsa dsa ecdsa dh ecdh dso engine \
147         buffer bio stack lhash rand err \
148         evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
149         cms pqueue ts jpake srp store cmac
150 # keep in mind that the above list is adjusted by ./Configure
151 # according to no-xxx arguments...
152
153 # tests to perform.  "alltests" is a special word indicating that all tests
154 # should be performed.
155 TESTS = alltests
156
157 MAKEFILE= Makefile
158
159 MANDIR=$(OPENSSLDIR)/man
160 MAN1=1
161 MAN3=3
162 MANSUFFIX=
163 HTMLSUFFIX=html
164 HTMLDIR=$(OPENSSLDIR)/html
165 SHELL=/bin/sh
166
167 TOP=    .
168 ONEDIRS=out tmp
169 EDIRS=  times doc bugs util include certs ms shlib mt demos perl sf dep VMS
170 WDIRS=  windows
171 LIBS=   libcrypto.a libssl.a
172 SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
173 SHARED_SSL=libssl$(SHLIB_EXT)
174 SHARED_LIBS=
175 SHARED_LIBS_LINK_EXTS=
176 SHARED_LDFLAGS=
177
178 GENERAL=        Makefile
179 BASENAME=       openssl
180 NAME=           $(BASENAME)-$(VERSION)
181 TARFILE=        $(NAME).tar
182 WTARFILE=       $(NAME)-win.tar
183 EXHEADER=       e_os2.h
184 HEADER=         e_os.h
185
186 # Directories created on install if they don't exist.
187 INSTALLDIRS=    \
188                 $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
189                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
190                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
191                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
192                 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
193                 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
194                 $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
195                 $(INSTALL_PREFIX)$(OPENSSLDIR)/private
196
197 all: Makefile build_all openssl.pc libssl.pc libcrypto.pc
198
199 # as we stick to -e, CLEARENV ensures that local variables in lower
200 # Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
201 # shell, which [annoyingly enough] terminates unset with error if VAR
202 # is not present:-( TOP= && unset TOP is tribute to HP-UX /bin/sh,
203 # which terminates unset with error if no variable was present:-(
204 CLEARENV=       TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS}     \
205                 $${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES}       \
206                 $${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC}           \
207                 $${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL} \
208                 $${EXHEADER+EXHEADER} $${HEADER+HEADER}         \
209                 $${GENERAL+GENERAL} $${CFLAGS+CFLAGS}           \
210                 $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS}           \
211                 $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
212                 $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS}     \
213                 $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
214
215 BUILDENV=       PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)' \
216                 CC='$(CC)' CFLAG='$(CFLAG)'                     \
217                 AS='$(CC)' ASFLAG='$(CFLAG) -c'                 \
218                 AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)'        \
219                 CROSS_COMPILE='$(CROSS_COMPILE)'        \
220                 PERL='$(PERL)' ENGDIRS='$(ENGDIRS)'             \
221                 SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'     \
222                 INSTALL_PREFIX='$(INSTALL_PREFIX)'              \
223                 INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'   \
224                 LIBDIR='$(LIBDIR)'                              \
225                 MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
226                 DEPFLAG='-DOPENSSL_NO_DEPRECATED $(DEPFLAG)'    \
227                 MAKEDEPPROG='$(MAKEDEPPROG)'                    \
228                 SHARED_LDFLAGS='$(SHARED_LDFLAGS)'              \
229                 KRB5_INCLUDES='$(KRB5_INCLUDES)' LIBKRB5='$(LIBKRB5)'   \
230                 ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'     \
231                 EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'       \
232                 SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
233                 PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)'     \
234                 CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'     \
235                 EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'         \
236                 AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'     \
237                 BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)'       \
238                 RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)'       \
239                 SHA1_ASM_OBJ='$(SHA1_ASM_OBJ)'                  \
240                 MD5_ASM_OBJ='$(MD5_ASM_OBJ)'                    \
241                 RMD160_ASM_OBJ='$(RMD160_ASM_OBJ)'              \
242                 WP_ASM_OBJ='$(WP_ASM_OBJ)'                      \
243                 MODES_ASM_OBJ='$(MODES_ASM_OBJ)'                \
244                 ENGINES_ASM_OBJ='$(ENGINES_ASM_OBJ)'            \
245                 PERLASM_SCHEME='$(PERLASM_SCHEME)'              \
246                 FIPSLIBDIR='${FIPSLIBDIR}'                      \
247                 FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"      \
248                 FIPS_EX_OBJ='${FIPS_EX_OBJ}'    \
249                 THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
250 # MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
251 # which in turn eliminates ambiguities in variable treatment with -e.
252
253 # BUILD_CMD is a generic macro to build a given target in a given
254 # subdirectory.  The target must be given through the shell variable
255 # `target' and the subdirectory to build in must be given through `dir'.
256 # This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
257 # BUILD_ONE_CMD instead.
258 #
259 # RECURSIVE_BUILD_CMD is a macro to build a given target in all
260 # subdirectories defined in $(DIRS).  It requires that the target
261 # is given through the shell variable `target'.
262 #
263 # BUILD_ONE_CMD is a macro to build a given target in a given
264 # subdirectory if that subdirectory is part of $(DIRS).  It requires
265 # exactly the same shell variables as BUILD_CMD.
266 BUILD_CMD=  if [ -d "$$dir" ]; then \
267             (   cd $$dir && echo "making $$target in $$dir..." && \
268                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
269             ) || exit 1; \
270             fi
271 RECURSIVE_BUILD_CMD=for dir in $(DIRS); do $(BUILD_CMD); done
272 BUILD_ONE_CMD=\
273         if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
274                 $(BUILD_CMD); \
275         fi
276
277 reflect:
278         @[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
279
280 FIPS_EX_OBJ= ../crypto/aes/aes_cfb.o \
281         ../crypto/aes/aes_ecb.o \
282         ../crypto/aes/aes_ofb.o \
283         ../crypto/bn/bn_add.o \
284         ../crypto/bn/bn_blind.o \
285         ../crypto/bn/bn_ctx.o \
286         ../crypto/bn/bn_div.o \
287         ../crypto/bn/bn_exp2.o \
288         ../crypto/bn/bn_exp.o \
289         ../crypto/bn/bn_gcd.o \
290         ../crypto/bn/bn_gf2m.o \
291         ../crypto/bn/bn_lib.o \
292         ../crypto/bn/bn_mod.o \
293         ../crypto/bn/bn_mont.o \
294         ../crypto/bn/bn_mul.o \
295         ../crypto/bn/bn_nist.o \
296         ../crypto/bn/bn_prime.o \
297         ../crypto/bn/bn_rand.o \
298         ../crypto/bn/bn_recp.o \
299         ../crypto/bn/bn_shift.o \
300         ../crypto/bn/bn_sqr.o \
301         ../crypto/bn/bn_word.o \
302         ../crypto/bn/bn_x931p.o \
303         ../crypto/buffer/buf_str.o \
304         ../crypto/cmac/cmac.o \
305         ../crypto/cryptlib.o \
306         ../crypto/des/cfb64ede.o \
307         ../crypto/des/cfb64enc.o \
308         ../crypto/des/cfb_enc.o \
309         ../crypto/des/ecb3_enc.o \
310         ../crypto/des/ofb64ede.o \
311         ../crypto/des/fcrypt.o \
312         ../crypto/des/set_key.o \
313         ../crypto/dh/dh_check.o \
314         ../crypto/dh/dh_gen.o \
315         ../crypto/dh/dh_key.o \
316         ../crypto/dsa/dsa_gen.o \
317         ../crypto/dsa/dsa_key.o \
318         ../crypto/dsa/dsa_ossl.o \
319         ../crypto/ec/ec_curve.o \
320         ../crypto/ec/ec_cvt.o \
321         ../crypto/ec/ec_key.o \
322         ../crypto/ec/ec_lib.o \
323         ../crypto/ec/ecp_mont.o \
324         ../crypto/ec/ec_mult.o \
325         ../crypto/ec/ecp_nist.o \
326         ../crypto/ec/ecp_smpl.o \
327         ../crypto/ec/ec2_mult.o \
328         ../crypto/ec/ec2_smpl.o \
329         ../crypto/ecdh/ech_key.o \
330         ../crypto/ecdh/ech_ossl.o \
331         ../crypto/ecdsa/ecs_ossl.o \
332         ../crypto/evp/e_aes.o \
333         ../crypto/evp/e_des3.o \
334         ../crypto/evp/e_null.o \
335         ../crypto/evp/m_sha1.o \
336         ../crypto/evp/m_dss1.o \
337         ../crypto/evp/m_dss.o \
338         ../crypto/evp/m_ecdsa.o \
339         ../crypto/hmac/hmac.o \
340         ../crypto/modes/cbc128.o \
341         ../crypto/modes/ccm128.o \
342         ../crypto/modes/cfb128.o \
343         ../crypto/modes/ctr128.o \
344         ../crypto/modes/gcm128.o \
345         ../crypto/modes/ofb128.o \
346         ../crypto/modes/xts128.o \
347         ../crypto/rsa/rsa_eay.o \
348         ../crypto/rsa/rsa_gen.o \
349         ../crypto/rsa/rsa_crpt.o \
350         ../crypto/rsa/rsa_none.o \
351         ../crypto/rsa/rsa_oaep.o \
352         ../crypto/rsa/rsa_pk1.o \
353         ../crypto/rsa/rsa_pss.o \
354         ../crypto/rsa/rsa_ssl.o \
355         ../crypto/rsa/rsa_x931.o \
356         ../crypto/rsa/rsa_x931g.o \
357         ../crypto/sha/sha1dgst.o \
358         ../crypto/sha/sha256.o \
359         ../crypto/sha/sha512.o \
360         ../crypto/thr_id.o \
361         ../crypto/uid.o
362
363 sub_all: build_all
364
365 build_all: build_libs build_apps build_tests build_tools
366
367 build_libs: build_crypto build_ssl build_engines
368
369 build_crypto:
370         @dir=crypto; target=all; $(BUILD_ONE_CMD)
371 build_ssl: build_crypto
372         @dir=ssl; target=all; $(BUILD_ONE_CMD)
373 build_engines: build_crypto
374         @dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
375
376 build_apps: build_libs
377         @dir=apps; target=all; $(BUILD_ONE_CMD)
378 build_tests: build_libs
379         @dir=test; target=all; $(BUILD_ONE_CMD)
380 build_tools: build_libs
381         @dir=tools; target=all; $(BUILD_ONE_CMD)
382
383 all_testapps: build_libs build_testapps
384 build_testapps:
385         @dir=crypto; target=testapps; $(BUILD_ONE_CMD)
386
387 libcrypto$(SHLIB_EXT): libcrypto.a
388         @if [ "$(SHLIB_TARGET)" != "" ]; then \
389                 if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
390                         FIPSLD_CC="$(CC)"; CC=fips/fipsld; \
391                         export CC FIPSLD_CC; \
392                 fi; \
393                 $(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
394         else \
395                 echo "There's no support for shared libraries on this platform" >&2; \
396                 exit 1; \
397         fi
398
399 libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
400         @if [ "$(SHLIB_TARGET)" != "" ]; then \
401                 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
402         else \
403                 echo "There's no support for shared libraries on this platform" >&2; \
404                 exit 1; \
405         fi
406
407 clean-shared:
408         @set -e; for i in $(SHLIBDIRS); do \
409                 if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
410                         tmp="$(SHARED_LIBS_LINK_EXTS)"; \
411                         for j in $${tmp:-x}; do \
412                                 ( set -x; rm -f lib$$i$$j ); \
413                         done; \
414                 fi; \
415                 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
416                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
417                         ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
418                 fi; \
419         done
420
421 link-shared:
422         @ set -e; for i in $(SHLIBDIRS); do \
423                 $(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
424                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
425                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
426                         symlink.$(SHLIB_TARGET); \
427                 libs="$$libs -l$$i"; \
428         done
429
430 build-shared: do_$(SHLIB_TARGET) link-shared
431
432 do_$(SHLIB_TARGET):
433         @ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
434                 if [ "$$i" = "ssl" -a -n "$(LIBKRB5)" ]; then \
435                         libs="$(LIBKRB5) $$libs"; \
436                 fi; \
437                 $(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
438                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
439                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
440                         LIBDEPS="$$libs $(EX_LIBS)" \
441                         link_a.$(SHLIB_TARGET); \
442                 libs="-l$$i $$libs"; \
443         done
444
445 libcrypto.pc: Makefile
446         @ ( echo 'prefix=$(INSTALLTOP)'; \
447             echo 'exec_prefix=$${prefix}'; \
448             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
449             echo 'includedir=$${prefix}/include'; \
450             echo ''; \
451             echo 'Name: OpenSSL-libcrypto'; \
452             echo 'Description: OpenSSL cryptography library'; \
453             echo 'Version: '$(VERSION); \
454             echo 'Requires: '; \
455             echo 'Libs: -L$${libdir} -lcrypto'; \
456             echo 'Libs.private: $(EX_LIBS)'; \
457             echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libcrypto.pc
458
459 libssl.pc: Makefile
460         @ ( echo 'prefix=$(INSTALLTOP)'; \
461             echo 'exec_prefix=$${prefix}'; \
462             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
463             echo 'includedir=$${prefix}/include'; \
464             echo ''; \
465             echo 'Name: OpenSSL-libssl'; \
466             echo 'Description: Secure Sockets Layer and cryptography libraries'; \
467             echo 'Version: '$(VERSION); \
468             echo 'Requires.private: libcrypto'; \
469             echo 'Libs: -L$${libdir} -lssl'; \
470             echo 'Libs.private: $(EX_LIBS)'; \
471             echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc
472
473 openssl.pc: Makefile
474         @ ( echo 'prefix=$(INSTALLTOP)'; \
475             echo 'exec_prefix=$${prefix}'; \
476             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
477             echo 'includedir=$${prefix}/include'; \
478             echo ''; \
479             echo 'Name: OpenSSL'; \
480             echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
481             echo 'Version: '$(VERSION); \
482             echo 'Requires: libssl libcrypto' ) > openssl.pc
483
484 Makefile: Makefile.org Configure config
485         @echo "Makefile is older than Makefile.org, Configure or config."
486         @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
487         @false
488
489 libclean:
490         rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
491
492 clean:  libclean
493         rm -f shlib/*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
494         rm -rf *.bak certs/.0
495         @set -e; target=clean; $(RECURSIVE_BUILD_CMD)
496         rm -f $(LIBS) tags TAGS
497         rm -f openssl.pc libssl.pc libcrypto.pc
498         rm -f speed.* .pure
499         rm -f $(TARFILE)
500         @set -e; for i in $(ONEDIRS) ;\
501         do \
502         rm -fr $$i/*; \
503         done
504
505 makefile.one: files
506         $(PERL) util/mk1mf.pl >makefile.one; \
507         sh util/do_ms.sh
508
509 files:
510         $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
511         @set -e; target=files; $(RECURSIVE_BUILD_CMD)
512
513 links:
514         @$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
515         @$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
516         @set -e; target=links; $(RECURSIVE_BUILD_CMD)
517
518 gentests:
519         @(cd test && echo "generating dummy tests (if needed)..." && \
520         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
521
522 dclean:
523         @set -e; target=dclean; $(RECURSIVE_BUILD_CMD)
524
525 rehash: rehash.time
526 rehash.time: certs apps
527         @if [ -z "$(CROSS_COMPILE)" ]; then \
528                 (OPENSSL="`pwd`/util/opensslwrap.sh"; \
529                 [ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
530                 OPENSSL_DEBUG_MEMORY=on; \
531                 export OPENSSL OPENSSL_DEBUG_MEMORY; \
532                 $(PERL) tools/c_rehash certs/demo) && \
533                 touch rehash.time; \
534         else :; fi
535
536 test:   tests
537
538 tests: rehash
539         @(cd test && echo "testing..." && \
540         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
541         OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a
542
543 report:
544         @$(PERL) util/selftest.pl
545
546 depend:
547         @set -e; target=depend; $(RECURSIVE_BUILD_CMD)
548
549 lint:
550         @set -e; target=lint; $(RECURSIVE_BUILD_CMD)
551
552 tags TAGS: FORCE
553         rm -f TAGS tags
554         -ctags -R .
555         -etags -R .
556
557 FORCE:
558
559 errors:
560         $(PERL) util/ck_errf.pl -strict */*.c */*/*.c
561         $(PERL) util/mkerr.pl -recurse -write
562         (cd engines; $(MAKE) PERL=$(PERL) errors)
563
564 stacks:
565         $(PERL) util/mkstack.pl -write
566
567 util/libeay.num::
568         $(PERL) util/mkdef.pl crypto update
569
570 util/ssleay.num::
571         $(PERL) util/mkdef.pl ssl update
572
573 crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl crypto/objects/obj_mac.h
574         $(PERL) crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
575 crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
576         $(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
577 crypto/objects/obj_xref.h: crypto/objects/objxref.pl crypto/objects/obj_xref.txt crypto/objects/obj_mac.num
578         $(PERL) crypto/objects/objxref.pl crypto/objects/obj_mac.num crypto/objects/obj_xref.txt >crypto/objects/obj_xref.h
579
580 apps/openssl-vms.cnf: apps/openssl.cnf
581         $(PERL) VMS/VMSify-conf.pl < apps/openssl.cnf > apps/openssl-vms.cnf
582
583 crypto/bn/bn_prime.h: crypto/bn/bn_prime.pl
584         $(PERL) crypto/bn/bn_prime.pl >crypto/bn/bn_prime.h
585
586
587 TABLE: Configure
588         (echo 'Output of `Configure TABLE'"':"; \
589         $(PERL) Configure TABLE) > TABLE
590
591 update: errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h crypto/objects/obj_xref.h apps/openssl-vms.cnf crypto/bn/bn_prime.h TABLE depend
592
593 # Build distribution tar-file. As the list of files returned by "find" is
594 # pretty long, on several platforms a "too many arguments" error or similar
595 # would occur. Therefore the list of files is temporarily stored into a file
596 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
597 # tar does not support the --files-from option.
598 tar:
599         find . -type d -print | xargs chmod 755
600         find . -type f -print | xargs chmod a+r
601         find . -type f -perm -0100 -print | xargs chmod a+x
602         find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
603         $(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
604         tardy --user_number=0  --user_name=openssl \
605               --group_number=0 --group_name=openssl \
606               --prefix=openssl-$(VERSION) - |\
607         gzip --best >../$(TARFILE).gz; \
608         rm -f ../$(TARFILE).list; \
609         ls -l ../$(TARFILE).gz
610
611 tar-snap:
612         @$(TAR) $(TARFLAGS) -cvf - \
613                 `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` |\
614         tardy --user_number=0  --user_name=openssl \
615               --group_number=0 --group_name=openssl \
616               --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
617         ls -l ../$(TARFILE)
618
619 dist:   
620         $(PERL) Configure dist
621         @$(MAKE) dist_pem_h
622         @$(MAKE) SDIRS='$(SDIRS)' clean
623         @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' tar
624
625 dist_pem_h:
626         (cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
627
628 install: all install_docs install_sw
629
630 uninstall: uninstall_sw uninstall_docs
631
632 install_sw:
633         @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
634         @set -e; headerlist="$(EXHEADER)"; for i in $$headerlist;\
635         do \
636         (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
637         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
638         done;
639         @set -e; target=install; $(RECURSIVE_BUILD_CMD)
640         @set -e; liblist="$(LIBS)"; for i in $$liblist ;\
641         do \
642                 if [ -f "$$i" ]; then \
643                 (       echo installing $$i; \
644                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
645                         $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
646                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
647                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
648                 fi; \
649         done;
650         @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
651                 tmp="$(SHARED_LIBS)"; \
652                 for i in $${tmp:-x}; \
653                 do \
654                         if [ -f "$$i" -o -f "$$i.a" ]; then \
655                         (       echo installing $$i; \
656                                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
657                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
658                                         cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
659                                         chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
660                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
661                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
662                                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
663                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
664                                 else \
665                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
666                                         chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
667                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
668                                 fi ); \
669                                 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
670                                 (       case $$i in \
671                                                 *crypto*) i=libeay32.dll;; \
672                                                 *ssl*)    i=ssleay32.dll;; \
673                                         esac; \
674                                         echo installing $$i; \
675                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
676                                         chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
677                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
678                                 fi; \
679                         fi; \
680                 done; \
681                 (       here="`pwd`"; \
682                         cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
683                         $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
684                 if [ "$(INSTALLTOP)" != "/usr" ]; then \
685                         echo 'OpenSSL shared libraries have been installed in:'; \
686                         echo '  $(INSTALLTOP)'; \
687                         echo ''; \
688                         sed -e '1,/^$$/d' doc/openssl-shared.txt; \
689                 fi; \
690         fi
691         cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
692         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
693         cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
694         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
695         cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
696         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
697
698 uninstall_sw:
699         cd include/openssl && files=* && cd $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl && $(RM) $$files
700         @for i in $(LIBS) ;\
701         do \
702                 test -f "$$i" && \
703                 echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i && \
704                 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
705         done;
706         @if [ -n "$(SHARED_LIBS)" ]; then \
707                 tmp="$(SHARED_LIBS)"; \
708                 for i in $${tmp:-x}; \
709                 do \
710                         if [ -f "$$i" -o -f "$$i.a" ]; then \
711                                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
712                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
713                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
714                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
715                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
716                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
717                                 else \
718                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
719                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
720                                 fi; \
721                                 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
722                                         case $$i in \
723                                                 *crypto*) i=libeay32.dll;; \
724                                                 *ssl*)    i=ssleay32.dll;; \
725                                         esac; \
726                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
727                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
728                                 fi; \
729                         fi; \
730                 done; \
731         fi
732         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
733         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
734         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
735         @target=uninstall; $(RECURSIVE_BUILD_CMD)
736
737 install_html_docs:
738         here="`pwd`"; \
739         filecase=; \
740         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
741                 filecase=-i; \
742         esac; \
743         for subdir in apps crypto ssl; do \
744                 $(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
745                 for i in doc/$$subdir/*.pod; do \
746                         fn=`basename $$i .pod`; \
747                         echo "installing html/$$fn.$(HTMLSUFFIX)"; \
748                         cat $$i \
749                         | sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
750                         | pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
751                         | sed -r 's/<!DOCTYPE.*//g' \
752                         > $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
753                         $(PERL) util/extract-names.pl < $$i | \
754                                 grep -v $$filecase "^$$fn\$$" | \
755                                 (cd $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
756                                  while read n; do \
757                                         PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
758                                  done); \
759                 done; \
760         done
761
762 uninstall_html_docs:
763         here="`pwd`"; \
764         filecase=; \
765         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
766                 filecase=-i; \
767         esac; \
768         for subdir in apps crypto ssl; do \
769                 for i in doc/$$subdir/*.pod; do \
770                         fn=`basename $$i .pod`; \
771                         $(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
772                         $(PERL) util/extract-names.pl < $$i | \
773                                 grep -v $$filecase "^$$fn\$$" | \
774                                 while read n; do \
775                                         $(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
776                                 done; \
777                 done; \
778         done
779
780 install_docs:
781         @$(PERL) $(TOP)/util/mkdir-p.pl \
782                 $(INSTALL_PREFIX)$(MANDIR)/man1 \
783                 $(INSTALL_PREFIX)$(MANDIR)/man3 \
784                 $(INSTALL_PREFIX)$(MANDIR)/man5 \
785                 $(INSTALL_PREFIX)$(MANDIR)/man7
786         here="`pwd`"; \
787         filecase=; \
788         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
789                 filecase=-i; \
790         esac; \
791         set -e; for i in doc/apps/*.pod; do \
792                 fn=`basename $$i .pod`; \
793                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
794                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
795                 (cd `$(PERL) util/dirname.pl $$i`; \
796                 pod2man \
797                         --section=$$sec --center=OpenSSL \
798                         --release=$(VERSION) `basename $$i`) \
799                         >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
800                 $(PERL) util/extract-names.pl < $$i | \
801                         (grep -v $$filecase "^$$fn\$$"; true) | \
802                         (grep -v "[     ]"; true) | \
803                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
804                          while read n; do \
805                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
806                          done); \
807         done; \
808         set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
809                 fn=`basename $$i .pod`; \
810                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
811                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
812                 (cd `$(PERL) util/dirname.pl $$i`; \
813                 pod2man \
814                         --section=$$sec --center=OpenSSL \
815                         --release=$(VERSION) `basename $$i`) \
816                         >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
817                 $(PERL) util/extract-names.pl < $$i | \
818                         (grep -v $$filecase "^$$fn\$$"; true) | \
819                         (grep -v "[     ]"; true) | \
820                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
821                          while read n; do \
822                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
823                          done); \
824         done
825
826 uninstall_docs:
827         @here="`pwd`"; \
828         filecase=; \
829         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
830                 filecase=-i; \
831         esac; \
832         for i in doc/apps/*.pod; do \
833                 fn=`basename $$i .pod`; \
834                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
835                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
836                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
837                 $(PERL) util/extract-names.pl < $$i | \
838                         (grep -v $$filecase "^$$fn\$$"; true) | \
839                         (grep -v "[     ]"; true) | \
840                         while read n; do \
841                                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
842                                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
843                         done; \
844         done; \
845         for i in doc/crypto/*.pod doc/ssl/*.pod; do \
846                 fn=`basename $$i .pod`; \
847                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
848                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
849                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
850                 $(PERL) util/extract-names.pl < $$i | \
851                         (grep -v $$filecase "^$$fn\$$"; true) | \
852                         (grep -v "[     ]"; true) | \
853                         while read n; do \
854                                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
855                                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
856                         done; \
857         done
858
859 # DO NOT DELETE THIS LINE -- make depend depends on it.