Fix incorrect BIO_*_ctrl() macros (Shay Harding <sharding@ccbill.com>).
[openssl.git] / Makefile.org
index 6fbf6b5..0427ce9 100644 (file)
@@ -166,9 +166,9 @@ SHLIBDIRS= crypto ssl
 SDIRS=  \
        md2 md4 md5 sha mdc2 hmac ripemd \
        des rc2 rc4 rc5 idea bf cast \
-       bn ec rsa dsa dh dso engine rijndael \
+       bn ec rsa dsa dh dso engine aes \
        buffer bio stack lhash rand err objects \
-       evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp
+       evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5
 
 # tests to perform.  "alltests" is a special word indicating that all tests
 # should be performed.
@@ -191,6 +191,7 @@ SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
 SHARED_SSL=libssl$(SHLIB_EXT)
 SHARED_LIBS=
 SHARED_LIBS_LINK_EXTS=
+SHARED_LDFLAGS=
 
 GENERAL=        Makefile
 BASENAME=       openssl
@@ -203,23 +204,18 @@ HEADER=         e_os.h
 # When we're prepared to use shared libraries in the programs we link here
 # we might remove 'clean-shared' from the targets to perform at this stage
 
-all: clean-shared Makefile.ssl sub_all
+all: Makefile.ssl sub_all
 
 sub_all:
        @for i in $(DIRS); \
        do \
        if [ -d "$$i" ]; then \
                (cd $$i && echo "making all in $$i..." && \
-               $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' all ) || exit 1; \
+               $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' all ) || exit 1; \
        else \
                $(MAKE) $$i; \
        fi; \
        done; \
-       if echo "$(DIRS)" | \
-           egrep '(^| )(crypto|ssl)( |$$)' > /dev/null 2>&1 && \
-          [ -n "$(SHARED_LIBS)" ]; then \
-               $(MAKE) $(SHARED_LIBS); \
-       fi
 
 libcrypto$(SHLIB_EXT): libcrypto.a
        @if [ "$(SHLIB_TARGET)" != "" ]; then \
@@ -263,40 +259,128 @@ do_bsd-gcc-shared: do_gnu-shared
 do_linux-shared: do_gnu-shared
 do_gnu-shared:
        libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
-       ( set -x; ${CC}  -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
-               -Wl,-S,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+       ( set -x; ${CC} ${SHARED_LDFLAGS} \
+               -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+               -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                -Wl,--whole-archive lib$$i.a \
                -Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \
        libs="$$libs -l$$i"; \
        done
 
-# This assumes that GNU utilities are *not* used
-do_tru64-shared:
+DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \
+       collect2=`gcc -print-prog-name=collect2 2>&1` && \
+       [ -n "$$collect2" ] && \
+       my_ld=`$$collect2 --help 2>&1 | grep Usage: | sed 's/^Usage: *\([^ ][^ ]*\).*/\1/'` && \
+       [ -n "$$my_ld" ] && \
+       $$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1
+
+# For Darwin AKA Mac OS/X (dyld)
+do_darwin-shared: 
        libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
-       ( set -x; ${CC}  -shared -no_archive -o lib$$i.so \
-               -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
-               -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
-       libs="$$libs -l$$i"; \
+       ( set -x ; ${CC} --verbose -dynamiclib -o lib$$i${SHLIB_EXT} \
+               lib$$i.a $$libs -all_load -current_version ${SHLIB_MAJOR}.${SHLIB_MINOR} \
+               -compatibility_version ${SHLIB_MAJOR}.`echo ${SHLIB_MINOR} | cut -d. -f1` \
+               -install_name ${INSTALLTOP}/lib/lib$$i${SHLIB_EXT} ) || exit 1; \
+       libs="$$libs -l`basename $$i${SHLIB_EXT} .dylib`"; \
+       echo "" ; \
        done
 
+# This assumes that GNU utilities are *not* used
+do_alpha-osf1-shared:
+       if ${DETECT_GNU_LD}; then \
+               $(MAKE) do_gnu-shared; \
+       else \
+               libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+               ( set -x; ${CC} ${SHARED_LDFLAGS} \
+                       -shared -o lib$$i.so \
+                       -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
+                       -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
+               libs="$$libs -l$$i"; \
+               done; \
+       fi
+
+# This assumes that GNU utilities are *not* used
+# The difference between alpha-osf1-shared and tru64-shared is the `-msym'
+# option passed to the linker.
+do_tru64-shared:
+       if ${DETECT_GNU_LD}; then \
+               $(MAKE) do_gnu-shared; \
+       else \
+               libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+               ( set -x; ${CC} ${SHARED_LDFLAGS} \
+                       -shared -msym -o lib$$i.so \
+                       -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
+                       -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
+               libs="$$libs -l$$i"; \
+               done; \
+       fi
+
+# This assumes that GNU utilities are *not* used
+# The difference between tru64-shared and tru64-shared-rpath is the
+# -rpath ${INSTALLTOP}/lib passed to the linker.
+do_tru64-shared-rpath:
+       if ${DETECT_GNU_LD}; then \
+               $(MAKE) do_gnu-shared; \
+       else \
+               libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+               ( set -x; ${CC} ${SHARED_LDFLAGS} \
+                       -shared -msym -o lib$$i.so \
+                       -rpath  ${INSTALLTOP}/lib \
+                       -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
+                       -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
+               libs="$$libs -l$$i"; \
+               done; \
+       fi
+
+
 # This assumes that GNU utilities are *not* used
 do_solaris-shared:
-       libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
-       ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
-         set -x; ${CC}  -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
-               -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
-               -z allextract lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \
-       libs="$$libs -l$$i"; \
-       done
+       if ${DETECT_GNU_LD}; then \
+               $(MAKE) do_gnu-shared; \
+       else \
+               libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+               ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
+                 set -x; ${CC} ${SHARED_LDFLAGS} \
+                       -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       -z allextract lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \
+               libs="$$libs -l$$i"; \
+               done; \
+       fi
+
+# UnixWare 7 and OpenUNIX 8 native compilers used
+do_svr5-shared:
+       if ${DETECT_GNU_LD}; then \
+               $(MAKE) do_gnu-shared; \
+       else \
+               libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+               ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
+                 find . -name "*.o" -print > allobjs ; \
+                 OBJS= ; export OBJS ; \
+                 for obj in `ar t lib$$i.a` ; do \
+                   OBJS="$${OBJS} `grep $$obj allobjs`" ; \
+                 done ; \
+                 set -x; ${CC} ${SHARED_LDFLAGS} \
+                       -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       $${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
+               libs="$$libs -l$$i"; \
+               done; \
+       fi
 
 # This assumes that GNU utilities are *not* used
 do_irix-shared:
-       libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
-       ( set -x; ${CC} -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
-               -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
-               -all lib$$i.a $$libs ${EX_LIBS} -lc) || exit 1; \
-       libs="$$libs -l$$i"; \
-       done
+       if ${DETECT_GNU_LD}; then \
+               $(MAKE) do_gnu-shared; \
+       else \
+               libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+               ( set -x; ${CC} ${SHARED_LDFLAGS} \
+                       -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       -all lib$$i.a $$libs ${EX_LIBS} -lc) || exit 1; \
+               libs="$$libs -l$$i"; \
+               done; \
+       fi
 
 # This assumes that GNU utilities are *not* used
 # HP-UX includes the full pathname of libs we depend on, so we would get
@@ -311,7 +395,8 @@ do_irix-shared:
 #
 do_hpux-shared:
        for i in ${SHLIBDIRS}; do \
-       ( set -x; /usr/ccs/bin/ld +vnocompatwarnings \
+       ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
+               +vnocompatwarnings \
                -b -z +s \
                -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
@@ -329,12 +414,56 @@ do_hpux-shared:
 #
 do_hpux64-shared:
        for i in ${SHLIBDIRS}; do \
-       ( set -x; /usr/ccs/bin/ld -b -z \
+       ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
+               -b -z \
                -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
                +forceload lib$$i.a -ldl -lc ) || exit 1; \
        done
 
+# The following method is said to work on all platforms.  Tests will
+# determine if that's how it's gong to be used.
+# This assumes that for all but GNU systems, GNU utilities are *not* used.
+# ALLSYMSFLAGS would be:
+#  GNU systems: --whole-archive
+#  Tru64 Unix:  -all
+#  Solaris:     -z allextract
+#  Irix:        -all
+#  HP/UX-32bit: -Fl
+#  HP/UX-64bit: +forceload
+#  AIX:                -bnogc
+# SHAREDFLAGS would be:
+#  GNU systems: -shared -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
+#  Tru64 Unix:  -shared \
+#              -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}"
+#  Solaris:     -G -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
+#  Irix:        -shared -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
+#  HP/UX-32bit: +vnocompatwarnings -b -z +s \
+#              +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
+#  HP/UX-64bit: -b -z +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
+#  AIX:                -G -bE:lib$$i.exp -bM:SRE
+# SHAREDCMD would be:
+#  GNU systems: $(CC)
+#  Tru64 Unix:  $(CC)
+#  Solaris:     $(CC)
+#  Irix:        $(CC)
+#  HP/UX-32bit: /usr/ccs/bin/ld
+#  HP/UX-64bit: /usr/ccs/bin/ld
+#  AIX:                $(CC)
+ALLSYMSFLAG=-bnogc
+SHAREDFLAGS=${SHARED_LDFLAGS} -G -bE:lib$$i.exp -bM:SRE
+SHAREDCMD=$(CC)
+do_aix-shared:
+       libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+       ( set -x; \
+         ld -r -o $$i.o $(ALLSYMSFLAG) lib$$i.a && \
+         ( nm -Pg lib$$i.o | grep ' [BD] ' | cut -f1 -d' ' > lib$$i.exp; \
+           $(SHAREDCMD) $(SHAREDFLAG) -o lib$$i.so lib$$i.o \
+               $$libs ${EX_LIBS} ) ) \
+       || exit 1; \
+       libs="$$libs -l$$i"; \
+       done
+
 Makefile.ssl: Makefile.org
        @echo "Makefile.ssl is older than Makefile.org."
        @echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
@@ -397,7 +526,11 @@ dclean:
 
 rehash: rehash.time
 rehash.time: certs
-       @(OPENSSL="`pwd`/apps/openssl"; OPENSSL_DEBUG_MEMORY=on; export OPENSSL OPENSSL_DEBUG_MEMORY; $(PERL) tools/c_rehash certs)
+       @(OPENSSL="`pwd`/apps/openssl"; OPENSSL_DEBUG_MEMORY=on; \
+               export OPENSSL OPENSSL_DEBUG_MEMORY; \
+               LD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \
+               export LD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
+               $(PERL) tools/c_rehash certs)
        touch rehash.time
 
 test:   tests
@@ -405,7 +538,9 @@ test:   tests
 tests: rehash
        @(cd test && echo "testing..." && \
        $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SDIRS='${SDIRS}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' OPENSSL_DEBUG_MEMORY=on tests );
-       @apps/openssl version -a
+       @LD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \
+               export LD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
+               apps/openssl version -a
 
 report:
        @$(PERL) util/selftest.pl
@@ -415,7 +550,7 @@ depend:
        do \
        if [ -d "$$i" ]; then \
                (cd $$i && echo "making dependencies $$i..." && \
-               $(MAKE) SDIRS='${SDIRS}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' depend ) || exit 1; \
+               $(MAKE) SDIRS='${SDIRS}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' KRB5_INCLUDES='${KRB5_INCLUDES}' depend ) || exit 1; \
        fi; \
        done;