From 9a70c260e8b7f600c567fe4f09d759f6abe54d02 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Thu, 11 Jul 2019 19:16:13 +0200 Subject: Android: rework build of OpenSSL to get it to build link and run This is squashed commit consisting of a number of subjects, all intended to get our app to build, link and run on device, but as the steps are small (but non-trivial), I document them in this one commit. 1) Do not use OpenSSLs install targets, but simply copy the wanted build artifacts manually. The main reason for this, is that the install targets want to install a lot more than we build, so it also builds parts of the OpenSSL suite that we will never use. 2) As Android does not like shared libraries with embedded versioning (and the used androiddeployqt actively prevents adding versioned libraries to the build), strip all this data from the generated shared libraries. This trick was already there, but its adapted to all possible conflicts. 3) The OpenSSL config script seems rather broken, resulted in failed builds, and calling the underlying Configure is simpler. 4) Finally, parts of the OpenSSL code uses stdio things like stdout, stderr, etc. These showed up as undeclared external on build time. Well, luckily, there was an easy way out using 2 -D(efines). This feels hacky, but does the job (and we are not interested in the output of OpenSSL in our app). Signed-off-by: Jan Mulder --- packaging/android/build.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'packaging/android/build.sh') diff --git a/packaging/android/build.sh b/packaging/android/build.sh index 8b5459980..c47ee4c3d 100755 --- a/packaging/android/build.sh +++ b/packaging/android/build.sh @@ -242,22 +242,29 @@ if [ "$QUICK" = "" ] ; then mkdir -p openssl-build-"$ARCH" cp -r openssl/* openssl-build-"$ARCH" pushd openssl-build-"$ARCH" - perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org perl -pi -e 's/-mandroid//g' Configure + export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT # Use env to make all these temporary, so they don't pollute later builds. - env SYSTEM=android \ - CROSS_COMPILE=${BUILDCHAIN}- \ - MACHINE=$OPENSSL_MACHINE \ - HOSTCC=clang \ + env PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH \ CC=clang \ - ANDROID_DEV="$PREFIX" \ - bash -x ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine no-asm --openssldir="$PREFIX" - # sed -i.bak -e 's/soname=\$\$SHLIB\$\$SHLIB_SOVER\$\$SHLIB_SUFFIX/soname=\$\$SHLIB/g' Makefile.shared + ./Configure android-"$ARCH" no-ssl2 no-ssl3 no-comp no-hw no-engine no-asm --prefix="$PREFIX" -DOPENSSL_NO_UI_CONSOLE -DOPENSSL_NO_STDIO make depend - make - # now fix the reference to libcrypto.so.1.0.0 to be just to libcrypto.so - perl -pi -e 's/libcrypto.so.1.0.0/libcrypto.so\x00\x00\x00\x00\x00\x00/' libssl.so.1.0.0 - make install_sw + make build_libs + + # now fix the reference to libcrypto.so.1.1 and libssl.so.1.1 to be just unversioned + # as androiddeployqt and Android itself does not like versioned shared objects + perl -pi -e 's/libcrypto.so.1.1/libcrypto.so\x00\x00\x00\x00/' libcrypto.so.1.1 + perl -pi -e 's/libcrypto.so.1.1/libcrypto.so\x00\x00\x00\x00/' libssl.so.1.1 + perl -pi -e 's/libssl.so.1.1/libssl.so\x00\x00\x00\x00/' libcrypto.so.1.1 + perl -pi -e 's/libssl.so.1.1/libssl.so\x00\x00\x00\x00/' libssl.so.1.1 + + cp -RL include/openssl $PREFIX/include/openssl + cp libcrypto.a $PREFIX/lib + cp libcrypto.so* $PREFIX/lib + cp libssl.a $PREFIX/lib + cp libssl.so* $PREFIX/lib + cp *.pc $PKG_CONFIG_LIBDIR + popd fi @@ -428,7 +435,7 @@ cmake $MOBILE_CMAKE \ -DANDROID_NATIVE_LIBCRYPT="$BUILDROOT/ndk-$ARCH/sysroot/usr/lib/libcrypto.so" \ -DCMAKE_MAKE_PROGRAM="make" \ "$SUBSURFACE_SOURCE" - + # set up the version number rm -f ssrf-version.h -- cgit v1.2.3-70-g09d2