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