Missing semicolon.
[openssl.git] / fips / fipsld
index 8c26c85..50f2075 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh -e
 #
-# Copyright (c) 2005-2007 The OpenSSL Project.
+# Copyright (c) 2005-2011 The OpenSSL Project.
 #
 # Depending on output file name, the script either embeds fingerprint
 # into libcrypto.so or static application. "Static" refers to static
@@ -71,7 +71,7 @@ PREMAIN_C=`dirname "${CANISTER_O}"`/fips_premain.c
 
 HMAC_KEY="etaonrishdlcupfm"
 
-case "`(uname -s) 2>/dev/null`" in
+case "${CROSS_COMPILE:-`(uname -s) 2>/dev/null`}" in
 OSF1|IRIX*)    _WL_PREMAIN="-Wl,-init,FINGERPRINT_premain"     ;;
 HP-UX)         _WL_PREMAIN="-Wl,+init,FINGERPRINT_premain"     ;;
 AIX)           _WL_PREMAIN="-Wl,-binitfini:FINGERPRINT_premain,-bnoobjreorder";;
@@ -88,7 +88,14 @@ case `basename "${TARGET}"` in
 lib*|*.dll)    # must be linking a shared lib...
        # Shared lib creation can be taking place in the source
        # directory only, but fipscanister.o can reside elsewhere...
-       FINGERTYPE="${THERE}/fips/fips_standalone_sha1"
+
+       if [ -x "${THERE}/fips/fips_standalone_sha1" ]; then
+               FINGERTYPE="${THERE}/fips/fips_standalone_sha1"
+               PREMAIN_DSO="${THERE}/fips/fips_premain_dso"
+       elif [ -x "${THERE}/bin/fips_standalone_sha1" ]; then
+               FINGERTYPE="${THERE}/bin/fips_standalone_sha1"
+               PREMAIN_DSO="./fips_premain_dso"
+       fi
 
        # verify fipspremain.c against its detached signature...
        ${FINGERTYPE} "${PREMAIN_C}" | sed "s/(.*\//(/" | \
@@ -99,13 +106,17 @@ lib*|*.dll)        # must be linking a shared lib...
                diff -w "${CANISTER_O}.sha1" - || \
        { echo "${CANISTER_O} fingerprint mismatch"; exit 1; }
 
+       [ -z "${FIPSLD_LIBCRYPTO}" -a -f "${THERE}/libcrypto.a" ] && \
+               FIPSLD_LIBCRYPTO="${THERE}/libcrypto.a"
+               
+
        # Temporarily remove fipscanister.o from libcrypto.a!
        # We are required to use the standalone copy...
-       if [ -f "${THERE}/libcrypto.a" ]; then
-           if ar d "${THERE}/libcrypto.a" fipscanister.o; then
-               (ranlib "${THERE}/libcrypto.a") 2>/dev/null || :
-               trap    'ar r "${THERE}/libcrypto.a" "${CANISTER_O}";
-                        (ranlib "${THERE}/libcrypto.a") 2>/dev/null || :;
+       if [ -n  "${FIPSLD_LIBCRYPTO}" ]; then
+           if ${CROSS_COMPILE}ar d "${FIPSLD_LIBCRYPTO}" fipscanister.o; then
+               (${CROSS_COMPILE}ranlib "${FIPSLD_LIBCRYPTO}") 2>/dev/null || :
+               trap    '${CROSS_COMPILE}ar r "${FIPSLD_LIBCRYPTO}" "${CANISTER_O}";
+                        (${CROSS_COMPILE}ranlib "${FIPSLD_LIBCRYPTO}") 2>/dev/null || :;
                         sleep 1;
                         touch -c "${TARGET}"' 0
            fi
@@ -116,12 +127,15 @@ lib*|*.dll)       # must be linking a shared lib...
                "${PREMAIN_C}" \
                ${_WL_PREMAIN} "$@"
 
-       # generate signature...
-       if [ -z "${FIPS_SIG}" ]; then
-               SIG=`"${THERE}/fips/fips_premain_dso" "${TARGET}"`
-       else
-               SIG=`"${FIPS_SIG}" -dso "${TARGET}"`
+       if [ "x${FIPS_SIG}" != "x" ]; then
+               # embed signature
+               "${FIPS_SIG}" "${TARGET}"
+               [ $? -ne 42 ] && exit $?
        fi
+
+       # generate signature...
+       SIG=`"${PREMAIN_DSO}" "${TARGET}"`
+
        /bin/rm -f "${TARGET}"
        if [ -z "${SIG}" ]; then
           echo "unable to collect signature"; exit 1
@@ -138,6 +152,8 @@ lib*|*.dll) # must be linking a shared lib...
        # directory or off the installed binary target destination.
        if [ -x "${THERE}/fips/fips_standalone_sha1" ]; then
                FINGERTYPE="${THERE}/fips/fips_standalone_sha1"
+       elif [ -x "${THERE}/bin/fips_standalone_sha1" ]; then
+               FINGERTYPE="${THERE}/bin/fips_standalone_sha1"
        else    # Installed tree is expected to contain
                # lib/fipscanister.o, lib/fipscanister.o.sha1 and
                # lib/fips_premain.c [not to mention bin/openssl].
@@ -159,12 +175,15 @@ lib*|*.dll)       # must be linking a shared lib...
                "${PREMAIN_C}" \
                ${_WL_PREMAIN} "$@"
 
-       # generate signature...
-       if [ -z "${FIPS_SIG}" ]; then
-               SIG=`"${TARGET}"`
-       else
-               SIG=`"${FIPS_SIG}" -exe "${TARGET}"`
+       if [ "x${FIPS_SIG}" != "x" ]; then
+               # embed signature
+               "${FIPS_SIG}" "${TARGET}"
+               [ $? -ne 42 ] && exit $?
        fi
+
+       # generate signature...
+       SIG=`"${TARGET}"`
+
        /bin/rm -f "${TARGET}"
        if [ -z "${SIG}" ]; then
           echo "unable to collect signature"; exit 1