2 ## Makefile for OpenSSL
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.
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.
27 INSTALLTOP=/usr/local/ssl
29 # Do not edit this manually. Use Configure --openssldir=DIR do change this!
30 OPENSSLDIR=/usr/local/ssl
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.
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
58 # PKCS1_CHECK - pkcs1 tests.
71 TARFLAGS= --no-recursion
72 MAKEDEPPROG=makedepend
74 # We let the C compiler driver to take care of .s files. This is done in
75 # order to be excused from maintaining a separate set of architecture
76 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
77 # gcc, then the driver will automatically translate it to -xarch=v8plus
78 # and pass it down to assembler.
82 # For x86 assembler: Set PROCESSOR to 386 if you want to support
86 # CPUID module collects small commonly used assembler snippets
89 DES_ENC= des_enc.o fcrypt_b.o
90 AES_ASM_OBJ=aes_core.o aes_cbc.o
103 DIRS= crypto ssl engines apps test tools
104 SHLIBDIRS= crypto ssl
106 # dirs in crypto to build
109 md2 md4 md5 sha mdc2 hmac ripemd \
110 des aes rc2 rc4 rc5 idea bf cast \
111 bn ec rsa dsa ecdsa dh ecdh dso engine \
112 buffer bio stack lhash rand err \
113 evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
116 # tests to perform. "alltests" is a special word indicating that all tests
117 # should be performed.
122 MANDIR=$(OPENSSLDIR)/man
130 EDIRS= times doc bugs util include certs ms shlib mt demos perl sf dep VMS
132 LIBS= libcrypto.a libssl.a
133 SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
134 SHARED_SSL=libssl$(SHLIB_EXT)
136 SHARED_LIBS_LINK_EXTS=
141 NAME= $(BASENAME)-$(VERSION)
143 WTARFILE= $(NAME)-win.tar
147 all: Makefile build_all openssl.pc
149 BUILDENV= PLATFORM='${PLATFORM}' PROCESSOR='${PROCESSOR}' \
150 SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' \
151 CC='${CC}' CFLAG='${CFLAG}' \
152 AS='${CC}' ASFLAG='${CFLAG} -c' \
153 AR='${AR}' PERL='${PERL}' RANLIB='${RANLIB}' \
154 LDFLAGS="$(LDFLAGS)" SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
155 KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' \
156 EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' \
157 SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' \
158 PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' \
159 CPUID_OBJ='${CPUID_OBJ}' \
160 BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' \
161 AES_ASM_OBJ='${AES_ASM_OBJ}' \
162 BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' \
163 RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' \
164 SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' \
165 MD5_ASM_OBJ='${MD5_ASM_OBJ}' \
166 RMD160_ASM_OBJ='${RMD160_ASM_OBJ}'
168 BUILD_CMD=if echo " $(DIRS) " | grep " $$dir " >/dev/null 2>/dev/null; then \
169 if [ -d "$$dir" ]; then \
170 (cd $$dir && echo "making $$target in $$dir..." && \
171 $(MAKE) -e $(BUILDENV) $$target ) || exit 1; \
177 build_all: build_libs build_apps build_tests build_tools
179 build_libs: build_crypto build_ssl build_engines
182 @dir=crypto; target=all; $(BUILD_CMD)
184 @dir=ssl; target=all; $(BUILD_CMD)
186 @dir=engines; target=all; $(BUILD_CMD)
188 @dir=apps; target=all; $(BUILD_CMD)
190 @dir=test; target=all; $(BUILD_CMD)
192 @dir=tools; target=all; $(BUILD_CMD)
194 all_testapps: build_libs build_testapps
196 @dir=crypto; target=testapps; $(BUILD_CMD)
198 libcrypto$(SHLIB_EXT): libcrypto.a
199 @if [ "$(SHLIB_TARGET)" != "" ]; then \
200 $(MAKE) SHLIBDIRS=crypto build-shared; \
202 echo "There's no support for shared libraries on this platform" >&2; \
206 libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
207 @if [ "$(SHLIB_TARGET)" != "" ]; then \
208 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
210 echo "There's no support for shared libraries on this platform" >&2; \
215 @set -e; for i in $(SHLIBDIRS); do \
216 if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
217 tmp="$(SHARED_LIBS_LINK_EXTS)"; \
218 for j in $${tmp:-x}; do \
219 ( set -x; rm -f lib$$i$$j ); \
222 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
223 if [ "$(PLATFORM)" = "Cygwin" ]; then \
224 ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
229 @ set -e; for i in ${SHLIBDIRS}; do \
230 $(MAKE) -f $(HERE)/Makefile.shared \
231 LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
232 LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
233 symlink.$(SHLIB_TARGET); \
234 libs="$$libs -l$$i"; \
237 build-shared: do_$(SHLIB_TARGET) link-shared
240 @ set -e; libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
241 if [ "${SHLIBDIRS}" = "ssl" -a -n "$(LIBKRB5)" ]; then \
242 libs="$(LIBKRB5) $$libs"; \
244 $(MAKE) -f Makefile.shared \
246 LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
247 LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
248 LIBDEPS="$$libs $(EX_LIBS)" \
249 LIBRPATH="$(INSTALLTOP)/lib" \
250 link_a.$(SHLIB_TARGET); \
251 libs="-l$$i $$libs"; \
255 @ ( echo 'prefix=$(INSTALLTOP)'; \
256 echo 'exec_prefix=$${prefix}'; \
257 echo 'libdir=$${exec_prefix}/lib'; \
258 echo 'includedir=$${prefix}/include'; \
260 echo 'Name: OpenSSL'; \
261 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
262 echo 'Version: '$(VERSION); \
264 echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
265 echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
267 Makefile: Makefile.org Configure config
268 @echo "Makefile is older than Makefile.org, Configure or config."
269 @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
273 rm -f *.map *.so *.so.* engines/*.so *.a */lib */*/lib
276 rm -f shlib/*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
277 @set -e; for i in $(DIRS) ;\
279 if [ -d "$$i" ]; then \
280 (cd $$i && echo "making clean in $$i..." && \
281 $(MAKE) SDIRS='${SDIRS}' clean ) || exit 1; \
288 @set -e; for i in $(ONEDIRS) ;\
294 $(PERL) util/mk1mf.pl >makefile.one; \
298 $(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
299 @set -e; for i in $(DIRS) ;\
301 if [ -d "$$i" ]; then \
302 (cd $$i && echo "making 'files' in $$i..." && \
303 $(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' files ) || exit 1; \
308 @$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
309 @$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
310 @set -e; target=links; for dir in $(DIRS); do $(BUILD_CMD); done
313 @(cd test && echo "generating dummy tests (if needed)..." && \
314 $(MAKE) $(BUILDENV) TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on generate );
318 @set -e; for i in $(DIRS) ;\
320 if [ -d "$$i" ]; then \
321 (cd $$i && echo "making dclean in $$i..." && \
322 $(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' dclean ) || exit 1; \
328 @(OPENSSL="`pwd`/util/opensslwrap.sh"; \
329 OPENSSL_DEBUG_MEMORY=on; \
330 export OPENSSL OPENSSL_DEBUG_MEMORY; \
331 $(PERL) tools/c_rehash certs)
337 @(cd test && echo "testing..." && \
338 $(MAKE) -e $(BUILDENV) TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on tests );
339 util/opensslwrap.sh version -a
342 @$(PERL) util/selftest.pl
345 @set -e; for i in $(DIRS) ;\
347 if [ -d "$$i" ]; then \
348 (cd $$i && echo "making dependencies $$i..." && \
349 $(MAKE) SDIRS='${SDIRS}' CFLAG='-DOPENSSL_NO_DEPRECATED ${CFLAG}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' KRB5_INCLUDES='${KRB5_INCLUDES}' PERL='${PERL}' depend ) || exit 1; \
354 @set -e; for i in $(DIRS) ;\
356 if [ -d "$$i" ]; then \
357 (cd $$i && echo "making lint $$i..." && \
358 $(MAKE) SDIRS='${SDIRS}' lint ) || exit 1; \
364 find . -name '[^.]*.[ch]' | xargs etags -a
367 $(PERL) util/mkerr.pl -recurse -write
368 (cd engines; $(MAKE) PERL=$(PERL) errors)
369 $(PERL) util/ck_errf.pl */*.c */*/*.c
372 $(PERL) util/mkstack.pl -write
375 $(PERL) util/mkdef.pl crypto update
378 $(PERL) util/mkdef.pl ssl update
380 crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl crypto/objects/obj_mac.h
381 $(PERL) crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
382 crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
383 $(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
385 apps/openssl-vms.cnf: apps/openssl.cnf
386 $(PERL) VMS/VMSify-conf.pl < apps/openssl.cnf > apps/openssl-vms.cnf
389 (echo 'Output of `Configure TABLE'"':"; \
390 $(PERL) Configure TABLE) > TABLE
392 update: depend errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h apps/openssl-vms.cnf TABLE
394 # Build distribution tar-file. As the list of files returned by "find" is
395 # pretty long, on several platforms a "too many arguments" error or similar
396 # would occur. Therefore the list of files is temporarily stored into a file
397 # and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
398 # tar does not support the --files-from option.
400 find . -type d -print | xargs chmod 755
401 find . -type f -print | xargs chmod a+r
402 find . -type f -perm -0100 -print | xargs chmod a+x
403 find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
404 $(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
405 tardy --user_number=0 --user_name=openssl \
406 --group_number=0 --group_name=openssl \
407 --prefix=openssl-$(VERSION) - |\
408 gzip --best >../$(TARFILE).gz; \
409 rm -f ../$(TARFILE).list; \
410 ls -l ../$(TARFILE).gz
413 @$(TAR) $(TARFLAGS) -cvf - \
414 `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` |\
415 tardy --user_number=0 --user_name=openssl \
416 --group_number=0 --group_name=openssl \
417 --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
421 $(PERL) Configure dist
423 @$(MAKE) SDIRS='${SDIRS}' clean
424 @$(MAKE) TAR='${TAR}' TARFLAGS='${TARFLAGS}' tar
427 (cd crypto/pem; $(MAKE) $(BUILDENV) pem.h; $(MAKE) clean)
429 install: all install_docs install_sw
432 @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
433 $(INSTALL_PREFIX)$(INSTALLTOP)/lib \
434 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/engines \
435 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig \
436 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
437 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
438 $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
439 $(INSTALL_PREFIX)$(OPENSSLDIR)/private
440 @set -e; headerlist="$(EXHEADER)"; for i in $$headerlist;\
442 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
443 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
445 @set -e; for i in $(DIRS) ;\
447 if [ -d "$$i" ]; then \
448 (cd $$i; echo "installing $$i..."; \
449 $(MAKE) $(BUILDENV) INSTALL_PREFIX='${INSTALL_PREFIX}' OPENSSLDIR='${OPENSSLDIR}' install ); \
452 @set -e; for i in $(LIBS) ;\
454 if [ -f "$$i" ]; then \
455 ( echo installing $$i; \
456 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
457 $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
458 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
459 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
462 @set -e; if [ -n "$(SHARED_LIBS)" ]; then \
463 tmp="$(SHARED_LIBS)"; \
464 for i in $${tmp:-x}; \
466 if [ -f "$$i" -o -f "$$i.a" ]; then \
467 ( echo installing $$i; \
468 if [ "$(PLATFORM)" != "Cygwin" ]; then \
469 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
470 chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
471 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
473 c=`echo $$i | sed 's/^lib/cyg/'`; \
474 cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
475 chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
476 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
477 cp $$i.a $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new; \
478 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new; \
479 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \
484 cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
485 $(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
486 if [ "$(INSTALLTOP)" != "/usr" ]; then \
487 echo 'OpenSSL shared libraries have been installed in:'; \
488 echo ' $(INSTALLTOP)'; \
490 sed -e '1,/^$$/d' doc/openssl-shared.txt; \
493 cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig
494 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkgconfig/openssl.pc
497 @$(PERL) $(TOP)/util/mkdir-p.pl \
498 $(INSTALL_PREFIX)$(MANDIR)/man1 \
499 $(INSTALL_PREFIX)$(MANDIR)/man3 \
500 $(INSTALL_PREFIX)$(MANDIR)/man5 \
501 $(INSTALL_PREFIX)$(MANDIR)/man7
502 @pod2man="`cd util; ./pod2mantest $(PERL)`"; \
505 if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" -o "$(PLATFORM)" = "mingw" ]; then \
508 set -e; for i in doc/apps/*.pod; do \
509 fn=`basename $$i .pod`; \
510 sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
511 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
512 (cd `$(PERL) util/dirname.pl $$i`; \
514 --section=$$sec --center=OpenSSL \
515 --release=$(VERSION) `basename $$i`") \
516 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
517 $(PERL) util/extract-names.pl < $$i | \
518 grep -v $$filecase "^$$fn\$$" | \
520 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
522 $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
525 set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
526 fn=`basename $$i .pod`; \
527 sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
528 echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
529 (cd `$(PERL) util/dirname.pl $$i`; \
531 --section=$$sec --center=OpenSSL \
532 --release=$(VERSION) `basename $$i`") \
533 > $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
534 $(PERL) util/extract-names.pl < $$i | \
535 grep -v $$filecase "^$$fn\$$" | \
537 (cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
539 $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
543 # DO NOT DELETE THIS LINE -- make depend depends on it.