The pointer to the cipher object is not yet set, when session was reloaded
[openssl.git] / Makefile.org
index ca16ab0..c32c1ae 100644 (file)
@@ -56,13 +56,16 @@ CC= gcc
 #CFLAG= -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
 CFLAG= -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
 DEPFLAG= 
-PEX_LIBS= -L. -L.. -L../.. -L../../..
+PEX_LIBS= 
 EX_LIBS= 
-AR=ar r
+EXE_EXT= 
+ARFLAGS=
+AR=ar $(ARFLAGS) r
 RANLIB= ranlib
 PERL= perl
 TAR= tar
 TARFLAGS= --no-recursion
+MAKEDEPPROG=makedepend
 
 # Set BN_ASM to bn_asm.o if you want to use the C version
 BN_ASM= bn_asm.o
@@ -149,27 +152,28 @@ RMD160_ASM_OBJ= asm/rm86-out.o
 #RMD160_ASM_OBJ= asm/rm86-out.o       # a.out, FreeBSD
 #RMD160_ASM_OBJ= asm/rm86bsdi.o       # bsdi
 
-# When we're prepared to use shared libraries in the programs we link here
-# we might set SHLIB_MARK to '$(SHARED_LIBS)'.
-SHLIB_MARK=
+# KRB5 stuff
+KRB5_INCLUDES=
+LIBKRB5=
 
-DIRS=   crypto ssl $(SHLIB_MARK) apps test tools
+DIRS=   crypto ssl engines apps test tools
 SHLIBDIRS= crypto ssl
 
 # dirs in crypto to build
 SDIRS=  \
        md2 md4 md5 sha mdc2 hmac ripemd \
        des rc2 rc4 rc5 idea bf cast \
-       bn rsa dsa dh dso engine rijndael \
+       bn ec rsa dsa ecdsa dh ecdh 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.
 TESTS = alltests
 
 MAKEFILE= Makefile.ssl
-MAKE=     make -f Makefile.ssl
+NEWMAKE=  make
+MAKE=     $(NEWMAKE) -f Makefile.ssl
 
 MANDIR=$(OPENSSLDIR)/man
 MAN1=1
@@ -185,35 +189,43 @@ SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
 SHARED_SSL=libssl$(SHLIB_EXT)
 SHARED_LIBS=
 SHARED_LIBS_LINK_EXTS=
+SHARED_LDFLAGS=
 
 GENERAL=        Makefile
 BASENAME=       openssl
 NAME=           $(BASENAME)-$(VERSION)
 TARFILE=        $(NAME).tar
 WTARFILE=       $(NAME)-win.tar
-EXHEADER=       e_os.h e_os2.h
+EXHEADER=       e_os2.h
 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: Makefile.ssl build_all openssl.pc
 
-all: clean-shared Makefile.ssl sub_all
-
-sub_all:
-       @for i in $(DIRS); \
-       do \
+BUILD_CMD=if echo " $(DIRS) " | grep " $$i " >/dev/null 2>/dev/null; then \
        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}' 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}' SHLIB_TARGET='${SHLIB_TARGET}' 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
+       fi; fi
+
+sub_all: build_all
+build_all: build_libs build_apps build_tests build_tools
+
+build_libs: build_crypto build_ssl build_engines
+
+build_crypto:
+       @i=crypto; $(BUILD_CMD)
+build_ssl:
+       @i=ssl; $(BUILD_CMD)
+build_engines:
+       @i=engines; $(BUILD_CMD)
+build_apps:
+       @i=apps; $(BUILD_CMD)
+build_tests:
+       @i=test; $(BUILD_CMD)
+build_tools:
+       @i=tools; $(BUILD_CMD)
 
 libcrypto$(SHLIB_EXT): libcrypto.a
        @if [ "$(SHLIB_TARGET)" != "" ]; then \
@@ -221,9 +233,10 @@ libcrypto$(SHLIB_EXT): libcrypto.a
        else \
                echo "There's no support for shared libraries on this platform" >&2; \
        fi
+
 libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
        @if [ "$(SHLIB_TARGET)" != "" ]; then \
-               $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-L. -lcrypto' build-shared; \
+               $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
        else \
                echo "There's no support for shared libraries on this platform" >&2; \
        fi
@@ -237,95 +250,46 @@ clean-shared:
                        done; \
                fi; \
                ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
-       done
-
-link-shared:
-       @for i in $(SHLIBDIRS); do \
-               prev=lib$$i$(SHLIB_EXT); \
-               if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
-                       tmp="$(SHARED_LIBS_LINK_EXTS)"; \
-                       for j in $${tmp:-x}; do \
-                               ( set -x; ln -s -f $$prev lib$$i$$j ); \
-                               prev=lib$$i$$j; \
-                       done; \
+               if [ "$(PLATFORM)" = "Cygwin" ]; then \
+                       ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
                fi; \
        done
 
-build-shared: clean-shared do_$(SHLIB_TARGET) link-shared
-
-do_bsd-gcc-shared: linux-shared
-do_linux-shared:
-       libs='${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} \
-               -Wl,--whole-archive lib$$i.a \
-               -Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \
-       libs="$$libs -L. -l$$i"; \
-       done
-
-# This assumes that GNU utilities are *not* used
-do_tru64-shared:
-       libs='${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. -l$$i"; \
-       done
-
-# This assumes that GNU utilities are *not* used
-do_solaris-shared:
-       libs='${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
-       ( 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. -l$$i"; \
-       done
-
-# This assumes that GNU utilities are *not* used
-do_irix-shared:
-       libs='${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. -l$$i"; \
+link-shared:
+       @ for i in ${SHLIBDIRS}; do \
+               $(NEWMAKE) -f Makefile.shared \
+                       LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
+                       symlink.$(SHLIB_TARGET); \
+               libs="$$libs -l$$i"; \
        done
 
-# This assumes that GNU utilities are *not* used
-# HP-UX includes the full pathname of libs we depend on, so we would get
-# ./libcrypto (with ./ as path information) compiled into libssl, hence
-# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
-# anyway.
-# The object modules are loaded from lib$i.a using the undocumented -Fl
-# option.
-#
-# WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
-#          by temporarily specifying "+s"!
-#
-do_hpux-shared:
-       for i in ${SHLIBDIRS}; do \
-       ( set -x; /usr/ccs/bin/ld +vnocompatwarnings \
-               -b -z +s \
-               -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
-               +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
-               -Fl lib$$i.a -ldld -lc ) || exit 1; \
+build-shared: do_$(SHLIB_TARGET) link-shared
+
+do_$(SHLIB_TARGET):
+       @ libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
+               $(NEWMAKE) -f Makefile.shared \
+                       CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
+                       SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
+                       LIBNAME=$$i LIBVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} \
+                       LIBCOMPATVERSIONS=";${SHLIB_VERSION_HISTORY}" \
+                       LIBDEPS="$$libs $(EX_LIBS)" \
+                       link_a.$(SHLIB_TARGET); \
+               libs="$$libs -l$$i"; \
        done
 
-# This assumes that GNU utilities are *not* used
-# HP-UX includes the full pathname of libs we depend on, so we would get
-# ./libcrypto (with ./ as path information) compiled into libssl, hence
-# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
-# anyway.
-#
-# HP-UX in 64bit mode has "+s" enabled by default; it will search for
-# shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
-#
-do_hpux64-shared:
-       for i in ${SHLIBDIRS}; do \
-       ( set -x; /usr/ccs/bin/ld -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
+openssl.pc:
+       @ ( echo 'prefix=$(INSTALLTOP)'; \
+           echo 'exec_prefix=$${prefix}'; \
+           echo 'libdir=$${exec_prefix}/lib'; \
+           echo 'includedir=$${prefix}/include'; \
+           echo ''; \
+           echo 'Name: OpenSSL'; \
+           echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
+           echo 'Version: '$(VERSION); \
+           echo 'Requires: '; \
+           echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
+           echo 'Cflags: -I$${includedir}' ) > openssl.pc
 
 Makefile.ssl: Makefile.org
        @echo "Makefile.ssl is older than Makefile.org."
@@ -333,7 +297,7 @@ Makefile.ssl: Makefile.org
        @false
 
 libclean:
-       rm -f *.a */lib */*/lib
+       rm -f *.so *.so.* engines/*.so *.a */lib */*/lib
 
 clean:
        rm -f shlib/*.o *.o core a.out fluff *.map rehash.time testlog make.log cctest cctest.c
@@ -345,6 +309,7 @@ clean:
                rm -f $(LIBS); \
        fi; \
        done;
+       rm -f openssl.pc
        rm -f *.a *.o speed.* *.map *.so .pure core
        rm -f $(TARFILE)
        @for i in $(ONEDIRS) ;\
@@ -373,10 +338,14 @@ links:
        @for i in $(DIRS); do \
        if [ -d "$$i" ]; then \
                (cd $$i && echo "making links 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}' PERL='${PERL}' links ) || 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}' PERL='${PERL}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' links ) || exit 1; \
        fi; \
        done;
 
+gentests:
+       @(cd test && echo "generating dummy tests (if needed)..." && \
+       $(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}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on generate );
+
 dclean:
        rm -f *.bak
        @for i in $(DIRS) ;\
@@ -389,15 +358,21 @@ dclean:
 
 rehash: rehash.time
 rehash.time: certs
-       @(OPENSSL="`pwd`/apps/openssl"; export OPENSSL; $(PERL) tools/c_rehash certs)
+       @(OPENSSL="`pwd`/apps/openssl"; OPENSSL_DEBUG_MEMORY=on; \
+               export OPENSSL OPENSSL_DEBUG_MEMORY; \
+               LD_LIBRARY_PATH="`pwd`"; DYLD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \
+               export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
+               $(PERL) tools/c_rehash certs)
        touch rehash.time
 
 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}' TESTS='${TESTS}' tests );
-       @apps/openssl version -a
+       $(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}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' TESTS='${TESTS}' OPENSSL_DEBUG_MEMORY=on tests );
+       @LD_LIBRARY_PATH="`pwd`"; DYLD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \
+               export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
+               apps/openssl version -a
 
 report:
        @$(PERL) util/selftest.pl
@@ -407,7 +382,7 @@ depend:
        do \
        if [ -d "$$i" ]; then \
                (cd $$i && echo "making dependencies $$i..." && \
-               $(MAKE) SDIRS='${SDIRS}' DEPFLAG='${DEPFLAG}' depend ) || exit 1; \
+               $(MAKE) SDIRS='${SDIRS}' CFLAG='${CFLAG}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' KRB5_INCLUDES='${KRB5_INCLUDES}' PERL='${PERL}' depend ) || exit 1; \
        fi; \
        done;
 
@@ -430,42 +405,60 @@ tags:
        done;
 
 errors:
-       perl util/mkerr.pl -recurse -write
+       $(PERL) util/mkerr.pl -recurse -write
+       (cd engines; $(MAKE) PERL=$(PERL) errors)
 
 stacks:
-       perl util/mkstack.pl -write
+       $(PERL) util/mkstack.pl -write
 
 util/libeay.num::
-       perl util/mkdef.pl crypto update
+       $(PERL) util/mkdef.pl crypto update
 
 util/ssleay.num::
-       perl util/mkdef.pl ssl update
+       $(PERL) util/mkdef.pl ssl update
 
-crypto/objects/obj_dat.h: crypto/objects/obj_mac.h crypto/objects/obj_dat.pl
-       perl crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
-crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt 
-       perl crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
+crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl crypto/objects/obj_mac.h
+       $(PERL) crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
+crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
+       $(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
 
 TABLE: Configure
        (echo 'Output of `Configure TABLE'"':"; \
-       perl Configure TABLE) > TABLE
+       $(PERL) Configure TABLE) > TABLE
 
 update: depend errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h TABLE
 
+# Build distribution tar-file. As the list of files returned by "find" is
+# pretty long, on several platforms a "too many arguments" error or similar
+# would occur. Therefore the list of files is temporarily stored into a file
+# and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
+# tar does not support the --files-from option.
 tar:
-       @$(TAR) $(TARFLAGS) -cvf - \
-               `find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort` |\
+       find . -type d -print | xargs chmod 755
+       find . -type f -print | xargs chmod a+r
+       find . -type f -perm -0100 -print | xargs chmod a+x
+       find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort > ../$(TARFILE).list; \
+       $(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list -cvf - | \
        tardy --user_number=0  --user_name=openssl \
              --group_number=0 --group_name=openssl \
              --prefix=openssl-$(VERSION) - |\
        gzip --best >../$(TARFILE).gz; \
+       rm -f ../$(TARFILE).list; \
        ls -l ../$(TARFILE).gz
 
+tar-snap:
+       @$(TAR) $(TARFLAGS) -cvf - \
+               `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` |\
+       tardy --user_number=0  --user_name=openssl \
+             --group_number=0 --group_name=openssl \
+             --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
+       ls -l ../$(TARFILE)
+
 dist:   
        $(PERL) Configure dist
        @$(MAKE) dist_pem_h
        @$(MAKE) SDIRS='${SDIRS}' clean
-       @$(MAKE) tar
+       @$(MAKE) TAR='${TAR}' TARFLAGS='${TARFLAGS}' tar
 
 dist_pem_h:
        (cd crypto/pem; $(MAKE) CC='${CC}' SDIRS='${SDIRS}' CFLAG='${CFLAG}' pem.h; $(MAKE) clean)
@@ -473,7 +466,9 @@ dist_pem_h:
 install: all install_docs
        @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
                $(INSTALL_PREFIX)$(INSTALLTOP)/lib \
+               $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkginfo \
                $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
+               $(INSTALL_PREFIX)$(OPENSSLDIR)/engines \
                $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
                $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
                $(INSTALL_PREFIX)$(OPENSSLDIR)/private \
@@ -487,32 +482,45 @@ install: all install_docs
        do \
        if [ -d "$$i" ]; then \
                (cd $$i; echo "installing $$i..."; \
-               $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' RANLIB='${RANLIB}' install ); \
+               $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' RANLIB='${RANLIB}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' install ); \
        fi; \
        done
        @for i in $(LIBS) ;\
        do \
                if [ -f "$$i" ]; then \
                (       echo installing $$i; \
-                       cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
-                       $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
-                       chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
-               fi \
-       done
+                       cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
+                       $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
+                       chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
+                       mv $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
+               fi; \
+       done;
        @if [ -n "$(SHARED_LIBS)" ]; then \
                tmp="$(SHARED_LIBS)"; \
                for i in $${tmp:-x}; \
                do \
-                       if [ -f "$$i" ]; then \
+                       if [ -f "$$i" -o -f "$$i.a" ]; then \
                        (       echo installing $$i; \
-                               cp -f $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
-                               chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
-                       fi \
+                               if [ "$(PLATFORM)" != "Cygwin" ]; then \
+                                       cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
+                                       chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new; \
+                                       mv $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
+                               else \
+                                       c=`echo $$i | sed 's/^lib/cyg/'`; \
+                                       cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
+                                       chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
+                                       mv $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
+                                       cp $$i.a $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new; \
+                                       chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new; \
+                                       mv $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \
+                               fi ); \
+                       fi; \
                done; \
                (       here="`pwd`"; \
                        cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
-                       make -f $$here/Makefile link-shared ); \
+                       $(NEWMAKE) -f $$here/Makefile link-shared ); \
        fi
+       cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/lib/pkginfo
 
 install_docs:
        @$(PERL) $(TOP)/util/mkdir-p.pl \
@@ -520,22 +528,25 @@ install_docs:
                $(INSTALL_PREFIX)$(MANDIR)/man3 \
                $(INSTALL_PREFIX)$(MANDIR)/man5 \
                $(INSTALL_PREFIX)$(MANDIR)/man7
-       @for i in doc/apps/*.pod; do \
+       @pod2man="`cd util; ./pod2mantest $(PERL)`"; \
+       for i in doc/apps/*.pod; do \
                fn=`basename $$i .pod`; \
-               sec=`[ "$$fn" = "config" ] && echo 5 || echo 1`; \
+               if [ "$$fn" = "config" ]; then sec=5; else sec=1; fi; \
                echo "installing man$$sec/`basename $$i .pod`.$$sec"; \
-               (cd `dirname $$i`; \
-               $(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
-                        --release=$(VERSION) `basename $$i`) \
+               (cd `$(PERL) util/dirname.pl $$i`; \
+               sh -c "$$pod2man \
+                       --section=$$sec --center=OpenSSL \
+                       --release=$(VERSION) `basename $$i`") \
                        >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \
-       done
-       @for i in doc/crypto/*.pod doc/ssl/*.pod; do \
+       done; \
+       for i in doc/crypto/*.pod doc/ssl/*.pod; do \
                fn=`basename $$i .pod`; \
-               sec=`[ "$$fn" = "des_modes" ] && echo 7 || echo 3`; \
+               if [ "$$fn" = "des_modes" ]; then sec=7; else sec=3; fi; \
                echo "installing man$$sec/`basename $$i .pod`.$$sec"; \
-               (cd `dirname $$i`; \
-               $(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
-                       --release=$(VERSION) `basename $$i`) \
+               (cd `$(PERL) util/dirname.pl $$i`; \
+               sh -c "$$pod2man \
+                       --section=$$sec --center=OpenSSL \
+                       --release=$(VERSION) `basename $$i`") \
                        >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \
        done