commit 0e9c33c9d751a51749c2600b9f681123b8f6f9ec
parent 9709dd912e4b5cabc69cf9832486df86e0b1c200
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon, 28 Apr 2014 20:11:09 +0000
openssl: detect arch properly
and cleanup openssl.mk a bit.
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat:
| M | openssl/openssl.mk |  |  | 87 | ++++++++++++++++++++++++++++++++++++++++++++----------------------------------- | 
1 file changed, 48 insertions(+), 39 deletions(-)
diff --git a/openssl/openssl.mk b/openssl/openssl.mk
@@ -1,18 +1,23 @@
 TARG = openssl
-LIB = libssl.a
-DEPS= zlib
-# TODO: add perl, patch to DEPS
+DEPS = zlib
+# NOTE: requires atleast perl and patch as make dependencies.
 
 <$mkbuild/mk.common-noinst
 
 openssl:QV:
 	# apply patches
-	patch -p1 < ../openssl-1.0.0a-ldflags.patch #327421
-	patch -p1 < ../openssl-1.0.0d-windres.patch #373743
-	patch -p1 < ../openssl-1.0.0h-pkg-config.patch
-	patch -p1 < ../openssl-1.0.1-parallel-build.patch
-	patch -p1 < ../openssl-1.0.1-x32.patch
-	patch -p0 < ../openssl-1.0.1e-ipv6.patch
+	patch --silent --dry-run -N -p1 < ../openssl-1.0.0a-ldflags.patch && \
+		patch -p1 < ../openssl-1.0.0a-ldflags.patch #327421
+	patch --silent --dry-run -N  -p1 < ../openssl-1.0.0d-windres.patch && \
+		patch -p1 < ../openssl-1.0.0d-windres.patch #373743
+	patch --silent --dry-run -N  -p1 < ../openssl-1.0.0h-pkg-config.patch && \
+		patch -p1 < ../openssl-1.0.0h-pkg-config.patch
+	patch --silent --dry-run -N -p1 < ../openssl-1.0.1-parallel-build.patch && \
+		patch -p1 < ../openssl-1.0.1-parallel-build.patch
+	patch --silent --dry-run -N -p1 < ../openssl-1.0.1-x32.patch && \
+		patch -p1 < ../openssl-1.0.1-x32.patch
+	patch --silent --dry-run -N -p0 < ../openssl-1.0.1e-ipv6.patch && \
+		patch -p0 < ../openssl-1.0.1e-ipv6.patch
 	# disable fips in the build
 	# make sure the man pages are suffixed #302165
 	# don't bother building man pages if they're disabled
@@ -21,48 +26,52 @@ openssl:QV:
 		-e '/^MANSUFFIX/s:=.*:=ssl:' \
 		-e '/^MAKEDEPPROG/s:=.*:=$(CC):' \
 		-e '/^MANDIR=/s:=.*:=/share/man:' \
-		Makefile.org \
-		|| die
+		Makefile.org
 	# show the actual commands in the log
 	sed -i '/^SET_X/s:=.*:=set -x:' Makefile.shared
 	#
 	sed -i '1s,^:$,#!/usr/bin/perl,' Configure #141906
-	#./config --test-sanity || die "I AM NOT SANE"
 	#
 	sed -i 's/-DTERMIO/-DTERMIOS/g' Configure
 	sed -i 's/defined(linux)/0/' crypto/ui/ui_openssl.c
-	#
 	# this is asm generated by perl (asm/cast-586.pl) which will cause textrel's that
 	# will require musl's dynlinker to mprotect(PROT_EXEC), which is not allowed by grsec.
 	sed -i 's@cast-586.o:@c_enc.o:@' Configure
 	#
 	export CFLAGS="-fPIC -Wa,--noexecstack -fno-strict-aliasing -D_GNU_SOURCE -Wl,-Bsymbolic \
-	$optcflags $DEPS_CFLAGS"
+		$optcflags $DEPS_CFLAGS"
 	export LDFLAGS="$optldflags $DEPS_LDFLAGS"
-	#
-	#disable_asm=
-	disable_asm=no-asm
-	#
-	./config --prefix="$prefix" --openssldir="$prefix"/etc/ssl \
-	  --libdir="$prefix"/lib no-dso $disable_asm zlib enable-md2 $CFLAGS
-		# Clean out hardcoded flags that openssl uses
-		CFLAG=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
-			-e 's:^CFLAG=::' \
-			-e 's:-fomit-frame-pointer ::g' \
-			-e 's:-O[0-9] ::g' \
-			-e 's:-march=[-a-z0-9]* ::g' \
-			-e 's:-mcpu=[-a-z0-9]* ::g' \
-			-e 's:-m[a-z0-9]* ::g' \
-		)
-		for mak in Makefile ; do
-	#	for mak in Makefile crypto/cast/Makefile ; do
-		sed -i \
-			-e "/^CFLAG/s|=.*|=${CFLAG} ${CFLAGS} ${INCLUDES}|" \
-			-e "/^SHARED_LDFLAGS=/s|$| ${LDFLAGS}|" \
-			"$mak" || die
-		done
-		# second part of our cast-586 fix: CFLAGS need to be picked up by the makefile.
-		sed -i 's@CFLAG=-g@CFLAG=${CFLAG} ${CFLAGS}@' crypto/cast/Makefile
-	#sed -i 's@#include "e_os.h"@#define CAST_LONG unsigned@' crypto/cast/cast_lcl.h
+	# guess arch
+	# NOTE: guess logic in ./config script is weird so set arch here and call
+	#       Configure directly.
+	sslarch="linux-generic32" # default
+	case "$arch" in
+	x86_64)
+		sslarch="linux-generic64"
+		;;
+	arm)
+		sslarch="arm"
+		;;
+	esac
+	./Configure "${sslarch}" --prefix="$prefix" --openssldir="$prefix"/etc/ssl \
+		--libdir="$prefix"/lib no-dso no-asm zlib enable-md2 $CFLAGS
+	# Clean out hardcoded flags that openssl uses
+	CFLAG=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
+		-e 's:^CFLAG=::' \
+		-e 's:-fomit-frame-pointer ::g' \
+		-e 's:-O[0-9] ::g' \
+		-e 's:-march=[-a-z0-9]* ::g' \
+		-e 's:-mcpu=[-a-z0-9]* ::g' \
+		-e 's:-m[a-z0-9]* ::g' \
+	)
+	for mak in Makefile ; do
+	sed -i \
+		-e "/^CFLAG/s|=.*|=${CFLAG} ${CFLAGS} ${INCLUDES}|" \
+		-e "/^SHARED_LDFLAGS=/s|$| ${LDFLAGS}|" \
+		"$mak"
+	done
+	cp crypto/cast/Makefile crypto/cast/Makefile.backup
+	# second part of our cast-586 fix: CFLAGS need to be picked up by the makefile.
+	sed -i 's@CFLAG=-g@CFLAG=${CFLAG} ${CFLAGS}@' crypto/cast/Makefile
 	make -j$nprocs depend
 	make -j$nprocs build_libs