RT3856: Fix memory leaks in test code
[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 # Zlib stuff
110 ZLIB_INCLUDE=
111 LIBZLIB=
112
113 # This is the location of fipscanister.o and friends.
114 # The FIPS module build will place it $(INSTALLTOP)/lib
115 # but since $(INSTALLTOP) can only take the default value
116 # when the module is built it will be in /usr/local/ssl/lib
117 # $(INSTALLTOP) for this build may be different so hard
118 # code the path.
119
120 FIPSLIBDIR=/usr/local/ssl/$(LIBDIR)/
121
122 # The location of the library which contains fipscanister.o
123 # normally it will be libcrypto. If not compiling in FIPS mode
124 # at all this is empty making it a useful test for a FIPS compile.
125
126 FIPSCANLIB=
127
128 # Shared library base address. Currently only used on Windows.
129 #
130
131 BASEADDR=
132
133 DIRS=   crypto ssl engines apps test tools
134 ENGDIRS= ccgost
135 SHLIBDIRS= crypto ssl
136 INSTALL_SUBS= engines apps tools
137
138 # dirs in crypto to build
139 SDIRS=  \
140         objects \
141         md2 md4 md5 sha mdc2 hmac ripemd whrlpool \
142         des aes rc2 rc4 rc5 idea bf cast camellia seed modes \
143         bn ec rsa dsa ecdsa dh ecdh dso engine \
144         buffer bio stack lhash rand err \
145         evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui \
146         cms pqueue ts jpake srp store cmac
147 # keep in mind that the above list is adjusted by ./Configure
148 # according to no-xxx arguments...
149
150 # tests to perform.  "alltests" is a special word indicating that all tests
151 # should be performed.
152 TESTS = alltests
153
154 MAKEFILE= Makefile
155
156 MANDIR=$(OPENSSLDIR)/man
157 MAN1=1
158 MAN3=3
159 MANSUFFIX=
160 HTMLSUFFIX=html
161 HTMLDIR=$(OPENSSLDIR)/html
162 SHELL=/bin/sh
163
164 TOP=    .
165 LIBS=   libcrypto.a libssl.a
166 SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
167 SHARED_SSL=libssl$(SHLIB_EXT)
168 SHARED_LIBS=
169 SHARED_LIBS_LINK_EXTS=
170 SHARED_LDFLAGS=
171
172 GENERAL=        Makefile
173 BASENAME=       openssl
174 NAME=           $(BASENAME)-$(VERSION)
175 TARFILE=        $(NAME).tar
176 WTARFILE=       $(NAME)-win.tar
177 HEADER=         e_os.h
178
179 # Directories created on install if they don't exist.
180 INSTALLDIRS=    \
181                 $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
182                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
183                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
184                 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
185                 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
186                 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
187                 $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
188                 $(INSTALL_PREFIX)$(OPENSSLDIR)/private
189
190 all: Makefile build_all
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                 $${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                 AS='$(CC)' 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                 ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'     \
223                 EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'       \
224                 SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
225                 PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)'     \
226                 CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'     \
227                 EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'         \
228                 AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'     \
229                 BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)'       \
230                 RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)'       \
231                 SHA1_ASM_OBJ='$(SHA1_ASM_OBJ)'                  \
232                 MD5_ASM_OBJ='$(MD5_ASM_OBJ)'                    \
233                 RMD160_ASM_OBJ='$(RMD160_ASM_OBJ)'              \
234                 WP_ASM_OBJ='$(WP_ASM_OBJ)'                      \
235                 MODES_ASM_OBJ='$(MODES_ASM_OBJ)'                \
236                 ENGINES_ASM_OBJ='$(ENGINES_ASM_OBJ)'            \
237                 PERLASM_SCHEME='$(PERLASM_SCHEME)'              \
238                 FIPSLIBDIR='${FIPSLIBDIR}'                      \
239                 FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}"      \
240                 THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
241 # MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
242 # which in turn eliminates ambiguities in variable treatment with -e.
243
244 # BUILD_CMD is a generic macro to build a given target in a given
245 # subdirectory.  The target must be given through the shell variable
246 # `target' and the subdirectory to build in must be given through `dir'.
247 # This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
248 # BUILD_ONE_CMD instead.
249 #
250 # RECURSIVE_BUILD_CMD is a macro to build a given target in all
251 # subdirectories defined in $(DIRS).  It requires that the target
252 # is given through the shell variable `target'.
253 #
254 # BUILD_ONE_CMD is a macro to build a given target in a given
255 # subdirectory if that subdirectory is part of $(DIRS).  It requires
256 # exactly the same shell variables as BUILD_CMD.
257 BUILD_CMD=  if [ -d "$$dir" ]; then \
258             (   cd $$dir && echo "making $$target in $$dir..." && \
259                 $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
260             ) || exit 1; \
261             fi
262 RECURSIVE_BUILD_CMD=for dir in $(DIRS); do $(BUILD_CMD); done
263 BUILD_ONE_CMD=\
264         if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
265                 $(BUILD_CMD); \
266         fi
267
268 reflect:
269         @[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
270
271 sub_all: build_all
272
273 build_all: build_libs build_apps build_tests build_tools
274
275 build_libs: build_libcrypto build_libssl openssl.pc
276
277 build_libcrypto: build_crypto build_engines libcrypto.pc
278 build_libssl: build_ssl libssl.pc
279
280 build_crypto:
281         @dir=crypto; target=all; $(BUILD_ONE_CMD)
282 build_ssl: build_crypto
283         @dir=ssl; target=all; $(BUILD_ONE_CMD)
284 build_engines: build_crypto
285         @dir=engines; target=all; AS='$(CC) -c'; export AS; $(BUILD_ONE_CMD)
286
287 build_apps: build_libs
288         @dir=apps; target=all; $(BUILD_ONE_CMD)
289 build_tests: build_libs
290         @dir=test; target=all; $(BUILD_ONE_CMD)
291 build_tools: build_libs
292         @dir=tools; target=all; $(BUILD_ONE_CMD)
293
294 all_testapps: build_libs build_testapps
295 build_testapps:
296         @dir=crypto; target=testapps; $(BUILD_ONE_CMD)
297
298 libcrypto$(SHLIB_EXT): libcrypto.a
299         @if [ "$(SHLIB_TARGET)" != "" ]; then \
300                 if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
301                         FIPSLD_CC="$(CC)"; CC=fips/fipsld; \
302                         export CC FIPSLD_CC; \
303                 fi; \
304                 $(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared; \
305         else \
306                 echo "There's no support for shared libraries on this platform" >&2; \
307                 exit 1; \
308         fi
309
310 libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
311         @if [ "$(SHLIB_TARGET)" != "" ]; then \
312                 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
313         else \
314                 echo "There's no support for shared libraries on this platform" >&2; \
315                 exit 1; \
316         fi
317
318 clean-shared:
319         @set -e; for i in $(SHLIBDIRS); do \
320                 if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
321                         tmp="$(SHARED_LIBS_LINK_EXTS)"; \
322                         for j in $${tmp:-x}; do \
323                                 ( set -x; rm -f lib$$i$$j ); \
324                         done; \
325                 fi; \
326                 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
327                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
328                         ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
329                 fi; \
330         done
331
332 link-shared:
333         @ set -e; for i in $(SHLIBDIRS); do \
334                 $(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
335                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
336                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
337                         symlink.$(SHLIB_TARGET); \
338                 libs="$$libs -l$$i"; \
339         done
340
341 build-shared: do_$(SHLIB_TARGET) link-shared
342
343 do_$(SHLIB_TARGET):
344         @ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
345                 $(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
346                         LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
347                         LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
348                         LIBDEPS="$$libs $(EX_LIBS)" \
349                         link_a.$(SHLIB_TARGET); \
350                 libs="-l$$i $$libs"; \
351         done
352
353 libcrypto.pc: Makefile
354         @ ( echo 'prefix=$(INSTALLTOP)'; \
355             echo 'exec_prefix=$${prefix}'; \
356             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
357             echo 'includedir=$${prefix}/include'; \
358             echo ''; \
359             echo 'Name: OpenSSL-libcrypto'; \
360             echo 'Description: OpenSSL cryptography library'; \
361             echo 'Version: '$(VERSION); \
362             echo 'Requires: '; \
363             echo 'Libs: -L$${libdir} -lcrypto'; \
364             echo 'Libs.private: $(EX_LIBS)'; \
365             echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
366
367 libssl.pc: Makefile
368         @ ( echo 'prefix=$(INSTALLTOP)'; \
369             echo 'exec_prefix=$${prefix}'; \
370             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
371             echo 'includedir=$${prefix}/include'; \
372             echo ''; \
373             echo 'Name: OpenSSL-libssl'; \
374             echo 'Description: Secure Sockets Layer and cryptography libraries'; \
375             echo 'Version: '$(VERSION); \
376             echo 'Requires.private: libcrypto'; \
377             echo 'Libs: -L$${libdir} -lssl'; \
378             echo 'Libs.private: $(EX_LIBS)'; \
379             echo 'Cflags: -I$${includedir}' ) > libssl.pc
380
381 openssl.pc: Makefile
382         @ ( echo 'prefix=$(INSTALLTOP)'; \
383             echo 'exec_prefix=$${prefix}'; \
384             echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
385             echo 'includedir=$${prefix}/include'; \
386             echo ''; \
387             echo 'Name: OpenSSL'; \
388             echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
389             echo 'Version: '$(VERSION); \
390             echo 'Requires: libssl libcrypto' ) > openssl.pc
391
392 Makefile: Makefile.org Configure config
393         @echo "Makefile is older than Makefile.org, Configure or config."
394         @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
395         @false
396
397 libclean:
398         rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
399
400 clean:  libclean
401         rm -f */*/*.o */*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
402         rm -rf *.bak certs/.0
403         @set -e; target=clean; $(RECURSIVE_BUILD_CMD)
404         rm -f $(LIBS) tags TAGS
405         rm -f openssl.pc libssl.pc libcrypto.pc
406         rm -f speed.* .pure
407         rm -f $(TARFILE)
408
409 makefile.one: files
410         $(PERL) util/mk1mf.pl >makefile.one; \
411         sh util/do_ms.sh
412
413 files:
414         $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
415         @set -e; target=files; $(RECURSIVE_BUILD_CMD)
416
417 gentests:
418         @(cd test && echo "generating dummy tests (if needed)..." && \
419         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
420
421 dclean:
422         @set -e; target=dclean; $(RECURSIVE_BUILD_CMD)
423
424 rehash: rehash.time
425 rehash.time: certs apps
426         @if [ -z "$(CROSS_COMPILE)" ]; then \
427                 (OPENSSL="`pwd`/util/opensslwrap.sh"; \
428                 [ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
429                 OPENSSL_DEBUG_MEMORY=on; OPENSSL_CONF=/dev/null ; \
430                 export OPENSSL OPENSSL_DEBUG_MEMORY OPENSSL_CONF; \
431                 $(PERL) tools/c_rehash certs/demo) && \
432                 touch rehash.time; \
433         else :; fi
434
435 test:   tests
436
437 tests: rehash
438         @(cd test && echo "testing..." && \
439         $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
440         OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a
441
442 report:
443         @$(PERL) util/selftest.pl
444
445 update: errors stacks util/libeay.num util/ssleay.num TABLE
446         @set -e; target=update; $(RECURSIVE_BUILD_CMD)
447
448 depend:
449         @set -e; target=depend; $(RECURSIVE_BUILD_CMD)
450
451 lint:
452         @set -e; target=lint; $(RECURSIVE_BUILD_CMD)
453
454 tags TAGS: FORCE
455         rm -f TAGS tags
456         -ctags -R .
457         -etags -R .
458
459 FORCE:
460
461 errors:
462         $(PERL) util/ck_errf.pl -strict */*.c */*/*.c
463         $(PERL) util/mkerr.pl -recurse -write
464         (cd engines; $(MAKE) PERL=$(PERL) errors)
465
466 stacks:
467         $(PERL) util/mkstack.pl -write
468
469 util/libeay.num::
470         $(PERL) util/mkdef.pl crypto update
471
472 util/ssleay.num::
473         $(PERL) util/mkdef.pl ssl update
474
475 TABLE: Configure Configurations/*.conf
476         (echo 'Output of `Configure TABLE'"':"; \
477         $(PERL) Configure TABLE) > TABLE
478
479 # Build distribution tar-file. As the list of files returned by "find" is
480 # pretty long, on several platforms a "too many arguments" error or similar
481 # would occur. Therefore the list of files is temporarily stored into a file
482 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
483 # tar does not support the --files-from option.
484 tar:
485         find . -type d -print | xargs chmod 755
486         find . -type f -print | xargs chmod a+r
487         find . -type f -perm -0100 -print | xargs chmod a+x
488         find * \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
489         $(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
490         tardy --user_number=0  --user_name=openssl \
491               --group_number=0 --group_name=openssl \
492               --prefix=openssl-$(VERSION) - |\
493         gzip --best >../$(TARFILE).gz; \
494         rm -f ../$(TARFILE).list; \
495         ls -l ../$(TARFILE).gz
496
497 tar-snap:
498         @$(TAR) $(TARFLAGS) -cvf - \
499                 `find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \! -name '*.so' \! -name '*.so.*'  \! -name 'openssl' \! -name '*test' \! -name '.#*' \! -name '*~' | sort` |\
500         tardy --user_number=0  --user_name=openssl \
501               --group_number=0 --group_name=openssl \
502               --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
503         ls -l ../$(TARFILE)
504
505 dist:   
506         $(PERL) Configure dist
507         @$(MAKE) dist_pem_h
508         @$(MAKE) SDIRS='$(SDIRS)' clean
509         @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' tar
510
511 dist_pem_h:
512         (cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
513
514 install: all install_docs install_sw
515
516 uninstall: uninstall_sw uninstall_docs
517
518 install_sw:
519         @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
520         @set -e; for i in include/openssl/*.h; do \
521         (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$$i; \
522         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$$i ); \
523         done;
524         @set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
525         @set -e; liblist="$(LIBS)"; for i in $$liblist ;\
526         do \
527                 if [ -f "$$i" ]; then \
528                 (       echo installing $$i; \
529                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
530                         $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
531                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
532                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
533                 fi; \
534         done;
535         @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
536                 tmp="$(SHARED_LIBS)"; \
537                 for i in $${tmp:-x}; \
538                 do \
539                         if [ -f "$$i" -o -f "$$i.a" ]; then \
540                         (       echo installing $$i; \
541                                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
542                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
543                                         cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
544                                         chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
545                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
546                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
547                                         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
548                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
549                                 else \
550                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
551                                         chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
552                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
553                                 fi ); \
554                                 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
555                                 (       case $$i in \
556                                                 *crypto*) i=libeay32.dll;; \
557                                                 *ssl*)    i=ssleay32.dll;; \
558                                         esac; \
559                                         echo installing $$i; \
560                                         cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
561                                         chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
562                                         mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
563                                 fi; \
564                         fi; \
565                 done; \
566                 (       here="`pwd`"; \
567                         cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
568                         $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
569                 if [ "$(INSTALLTOP)" != "/usr" ]; then \
570                         echo 'OpenSSL shared libraries have been installed in:'; \
571                         echo '  $(INSTALLTOP)'; \
572                 fi; \
573         fi
574         cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
575         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
576         cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
577         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
578         cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
579         chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
580
581 uninstall_sw:
582         cd include/openssl && files=* && cd $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl && $(RM) $$files
583         @for i in $(LIBS) ;\
584         do \
585                 test -f "$$i" && \
586                 echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i && \
587                 $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
588         done;
589         @if [ -n "$(SHARED_LIBS)" ]; then \
590                 tmp="$(SHARED_LIBS)"; \
591                 for i in $${tmp:-x}; \
592                 do \
593                         if [ -f "$$i" -o -f "$$i.a" ]; then \
594                                 if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
595                                         c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
596                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
597                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
598                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
599                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
600                                 else \
601                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
602                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
603                                 fi; \
604                                 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
605                                         case $$i in \
606                                                 *crypto*) i=libeay32.dll;; \
607                                                 *ssl*)    i=ssleay32.dll;; \
608                                         esac; \
609                                         echo $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
610                                         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
611                                 fi; \
612                         fi; \
613                 done; \
614         fi
615         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
616         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
617         $(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
618         @target=uninstall; $(RECURSIVE_BUILD_CMD)
619
620 install_html_docs:
621         here="`pwd`"; \
622         filecase=; \
623         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
624                 filecase=-i; \
625         esac; \
626         for subdir in apps crypto ssl; do \
627                 $(PERL) $(TOP)/util/mkdir-p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
628                 for i in doc/$$subdir/*.pod; do \
629                         fn=`basename $$i .pod`; \
630                         echo "installing html/$$fn.$(HTMLSUFFIX)"; \
631                         cat $$i \
632                         | sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
633                         | pod2html --podroot=doc --htmlroot=.. --podpath=$$subdir:apps:crypto:ssl \
634                         | sed -r 's/<!DOCTYPE.*//g' \
635                         > $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
636                         $(PERL) util/extract-names.pl < $$i | \
637                                 grep -v $$filecase "^$$fn\$$" | \
638                                 (cd $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
639                                  while read n; do \
640                                         PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
641                                  done); \
642                 done; \
643         done
644
645 uninstall_html_docs:
646         here="`pwd`"; \
647         filecase=; \
648         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
649                 filecase=-i; \
650         esac; \
651         for subdir in apps crypto ssl; do \
652                 for i in doc/$$subdir/*.pod; do \
653                         fn=`basename $$i .pod`; \
654                         $(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
655                         $(PERL) util/extract-names.pl < $$i | \
656                                 grep -v $$filecase "^$$fn\$$" | \
657                                 while read n; do \
658                                         $(RM) $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/"$$n".$(HTMLSUFFIX); \
659                                 done; \
660                 done; \
661         done
662
663 install_docs:
664         @$(PERL) $(TOP)/util/mkdir-p.pl \
665                 $(INSTALL_PREFIX)$(MANDIR)/man1 \
666                 $(INSTALL_PREFIX)$(MANDIR)/man3 \
667                 $(INSTALL_PREFIX)$(MANDIR)/man5 \
668                 $(INSTALL_PREFIX)$(MANDIR)/man7
669         here="`pwd`"; \
670         filecase=; \
671         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
672                 filecase=-i; \
673         esac; \
674         set -e; for i in doc/apps/*.pod; do \
675                 fn=`basename $$i .pod`; \
676                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
677                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
678                 (cd `$(PERL) util/dirname.pl $$i`; \
679                 pod2man \
680                         --section=$$sec --center=OpenSSL \
681                         --release=$(VERSION) `basename $$i`) \
682                         >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
683                 $(PERL) util/extract-names.pl < $$i | \
684                         (grep -v $$filecase "^$$fn\$$"; true) | \
685                         (grep -v "[     ]"; true) | \
686                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
687                          while read n; do \
688                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
689                          done); \
690         done; \
691         set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
692                 fn=`basename $$i .pod`; \
693                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
694                 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
695                 (cd `$(PERL) util/dirname.pl $$i`; \
696                 pod2man \
697                         --section=$$sec --center=OpenSSL \
698                         --release=$(VERSION) `basename $$i`) \
699                         >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
700                 $(PERL) util/extract-names.pl < $$i | \
701                         (grep -v $$filecase "^$$fn\$$"; true) | \
702                         (grep -v "[     ]"; true) | \
703                         (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
704                          while read n; do \
705                                 PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
706                          done); \
707         done
708
709 uninstall_docs:
710         @here="`pwd`"; \
711         filecase=; \
712         case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*) \
713                 filecase=-i; \
714         esac; \
715         for i in doc/apps/*.pod; do \
716                 fn=`basename $$i .pod`; \
717                 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
718                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
719                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
720                 $(PERL) util/extract-names.pl < $$i | \
721                         (grep -v $$filecase "^$$fn\$$"; true) | \
722                         (grep -v "[     ]"; true) | \
723                         while read n; do \
724                                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
725                                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
726                         done; \
727         done; \
728         for i in doc/crypto/*.pod doc/ssl/*.pod; do \
729                 fn=`basename $$i .pod`; \
730                 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
731                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
732                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
733                 $(PERL) util/extract-names.pl < $$i | \
734                         (grep -v $$filecase "^$$fn\$$"; true) | \
735                         (grep -v "[     ]"; true) | \
736                         while read n; do \
737                                 echo $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
738                                 $(RM) $(INSTALL_PREFIX)$(MANDIR)/man$$sec/"$$n".$${sec}$(MANSUFFIX); \
739                         done; \
740         done
741
742 # DO NOT DELETE THIS LINE -- make depend depends on it.