From d1321464f6c609d106d6af9a4e599661bf6c59b7 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sun, 25 Sep 2011 15:51:57 +0000 Subject: [PATCH] Add crossbuild patch to 1.2 FIPS branch. --- Configure | 15 ++++++++++++--- Makefile.org | 14 ++++++++------ apps/Makefile | 7 ++----- config | 8 ++++---- fips/fipsld | 12 ++++++++++-- fips/sha/Makefile | 6 +++++- 6 files changed, 41 insertions(+), 21 deletions(-) diff --git a/Configure b/Configure index 1997020984..92667a8c0b 100755 --- a/Configure +++ b/Configure @@ -566,7 +566,8 @@ my $idx_arflags = $idx++; my $prefix=""; my $openssldir=""; my $exe_ext=""; -my $install_prefix=""; +my $install_prefix="$ENV{'INSTALL_PREFIX'}"; +my $cross_compile_prefix="$ENV{'CROSS_COMPILE'}"; my $fipslibdir="/usr/local/ssl/lib/fips-1.0/"; my $nofipscanistercheck=0; my $fipsdso=0; @@ -1397,7 +1398,16 @@ while () s/^PLATFORM=.*$/PLATFORM=$target/; s/^OPTIONS=.*$/OPTIONS=$options/; s/^CONFIGURE_ARGS=.*$/CONFIGURE_ARGS=$argvstring/; - s/^CC=.*$/CC= $cc/; + if ($cross_compile_prefix) + { + s/^CC=.*$/CROSS_COMPILE= $cross_compile_prefix\nCC= \$\(CROSS_COMPILE\)$cc/; + s/^AR=\s*/AR= \$\(CROSS_COMPILE\)/; + s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE\)/; + } + else { + s/^CC=.*$/CC= $cc/; + s/^RANLIB=.*/RANLIB= $ranlib/; + } s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc"; s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG= $depflags/; @@ -1416,7 +1426,6 @@ while () s/^SHA1_ASM_OBJ=.*$/SHA1_ASM_OBJ= $sha1_obj/; s/^RMD160_ASM_OBJ=.*$/RMD160_ASM_OBJ= $rmd160_obj/; s/^PROCESSOR=.*/PROCESSOR= $processor/; - s/^RANLIB=.*/RANLIB= $ranlib/; s/^ARFLAGS=.*/ARFLAGS= $arflags/; s/^PERL=.*/PERL= $perl/; s/^KRB5_INCLUDES=.*/KRB5_INCLUDES=$withargs{"krb5-include"}/; diff --git a/Makefile.org b/Makefile.org index d77a3e8762..5b60bb1a26 100644 --- a/Makefile.org +++ b/Makefile.org @@ -512,12 +512,14 @@ dclean: @set -e; target=dclean; $(RECURSIVE_BUILD_CMD) rehash: rehash.time -rehash.time: certs - @(OPENSSL="`pwd`/util/opensslwrap.sh"; \ - OPENSSL_DEBUG_MEMORY=on; \ - export OPENSSL OPENSSL_DEBUG_MEMORY; \ - $(PERL) tools/c_rehash certs) - touch rehash.time +rehash.time: certs apps + @if [ -z "$(CROSS_COMPILE)" ]; then \ + (OPENSSL="`pwd`/util/opensslwrap.sh"; \ + OPENSSL_DEBUG_MEMORY=on; \ + export OPENSSL OPENSSL_DEBUG_MEMORY; \ + $(PERL) tools/c_rehash certs) && \ + touch rehash.time; \ + else :; fi test: tests diff --git a/apps/Makefile b/apps/Makefile index e00e7a6cc5..3aef7fb07b 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -153,17 +153,14 @@ $(EXE): progs.h $(E_OBJ) $(PROGRAM).o $(DLIBCRYPTO) $(DLIBSSL) shlib_target=; if [ -n "$(SHARED_LIBS)" ]; then \ shlib_target="$(SHLIB_TARGET)"; \ elif [ -n "$(FIPSCANLIB)" ]; then \ - FIPSLD_CC=$(CC); CC=$(TOP)/fips/fipsld; export CC FIPSLD_CC; \ + FIPSLD_CC="$(CC)"; CC=$(TOP)/fips/fipsld; export CC FIPSLD_CC; \ fi; \ LIBRARIES="$(LIBSSL) $(LIBKRB5) $(LIBCRYPTO)" ; \ [ "x$(FIPSCANLIB)" = "xlibfips" ] && LIBRARIES="$$LIBRARIES -lfips"; \ $(MAKE) -f $(TOP)/Makefile.shared -e \ - CC=$${CC} APPNAME=$(EXE) OBJECTS="$(PROGRAM).o $(E_OBJ)" \ + CC="$${CC}" APPNAME=$(EXE) OBJECTS="$(PROGRAM).o $(E_OBJ)" \ LIBDEPS="$(PEX_LIBS) $$LIBRARIES $(EX_LIBS)" \ link_app.$${shlib_target} - -(cd ..; \ - OPENSSL="`pwd`/util/opensslwrap.sh"; export OPENSSL; \ - $(PERL) tools/c_rehash certs) progs.h: progs.pl $(PERL) progs.pl $(E_EXE) >progs.h diff --git a/config b/config index 28b52acdc6..91231f98f0 100755 --- a/config +++ b/config @@ -48,10 +48,10 @@ done # First get uname entries that we use below -MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown" -RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown" -SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown" -VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown" +[ "$MACHINE" ] || MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown" +[ "$RELEASE" ] || RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown" +[ "$SYSTEM" ] || SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown" +[ "$BUILD" ] || VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown" # Now test for ISC and SCO, since it is has a braindamaged uname. diff --git a/fips/fipsld b/fips/fipsld index c71d4d95a5..8c26c8596d 100755 --- a/fips/fipsld +++ b/fips/fipsld @@ -117,7 +117,11 @@ lib*|*.dll) # must be linking a shared lib... ${_WL_PREMAIN} "$@" # generate signature... - SIG=`"${THERE}/fips/fips_premain_dso" "${TARGET}"` + if [ -z "${FIPS_SIG}" ]; then + SIG=`"${THERE}/fips/fips_premain_dso" "${TARGET}"` + else + SIG=`"${FIPS_SIG}" -dso "${TARGET}"` + fi /bin/rm -f "${TARGET}" if [ -z "${SIG}" ]; then echo "unable to collect signature"; exit 1 @@ -156,7 +160,11 @@ lib*|*.dll) # must be linking a shared lib... ${_WL_PREMAIN} "$@" # generate signature... - SIG=`"${TARGET}"` + if [ -z "${FIPS_SIG}" ]; then + SIG=`"${TARGET}"` + else + SIG=`"${FIPS_SIG}" -exe "${TARGET}"` + fi /bin/rm -f "${TARGET}" if [ -z "${SIG}" ]; then echo "unable to collect signature"; exit 1 diff --git a/fips/sha/Makefile b/fips/sha/Makefile index ba8eb02baf..5304e50920 100644 --- a/fips/sha/Makefile +++ b/fips/sha/Makefile @@ -47,8 +47,12 @@ lib: $(LIBOBJ) @echo $(LIBOBJ) > lib ../fips_standalone_sha1$(EXE_EXT): fips_standalone_sha1.o + if [ -z "$(HOSTCC)" ] ; then \ FIPS_SHA_ASM=""; for i in $(SHA1_ASM_OBJ) sha1dgst.o ; do FIPS_SHA_ASM="$$FIPS_SHA_ASM ../../crypto/sha/$$i" ; done; \ - $(CC) -o $@ $(CFLAGS) fips_standalone_sha1.o $$FIPS_SHA_ASM + $(CC) -o $@ $(CFLAGS) fips_standalone_sha1.o $$FIPS_SHA_ASM ; \ + else \ + $(HOSTCC) $(HOSTCFLAGS) -o $ $@ -I../../include -I../../crypto fips_standalone_sha1.c ../../crypto/sha/sha1dgst.c ; \ + fi files: $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO -- 2.25.1