From 4d823359ef544ef3e87aaf69f14b13c2c2be6d14 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 17:12:43 +0200 Subject: [PATCH 01/29] PEMA-107 Move nettle patches application to downloads Makefile --- android/external/arm64-v8a/Makefile | 4 +--- android/external/armeabi-v7a/Makefile | 4 +--- android/external/downloads/Makefile | 8 +++++++- android/external/x86/Makefile | 4 +--- android/external/x86_64/Makefile | 4 +--- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/android/external/arm64-v8a/Makefile b/android/external/arm64-v8a/Makefile index f44569e..dc6954a 100644 --- a/android/external/arm64-v8a/Makefile +++ b/android/external/arm64-v8a/Makefile @@ -256,7 +256,7 @@ gmp-install: $(LOCAL)/lib/libgmp.so #------------------------------------------------------------------------------# # NETTLE -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION).tar.gz $(LOCAL)/lib/libgmp.so +nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so tar xvf $< mv nettle-$(NETTLE_VERSION) nettle touch $@ @@ -268,8 +268,6 @@ nettle-clean: rm -rf nettle.src.stamp nettle/Makefile: nettle.src.stamp - -patch -N -p1 --reject-file=- nettle/configure.ac ../nettle-3.4.1-remove-so-versioning.patch - -patch -N -p1 --reject-file=- nettle/Makefile.in ../nettle-3.4.1-remove-so-versioning-link.patch cd nettle && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure \ diff --git a/android/external/armeabi-v7a/Makefile b/android/external/armeabi-v7a/Makefile index 8c77cca..7eb8edf 100644 --- a/android/external/armeabi-v7a/Makefile +++ b/android/external/armeabi-v7a/Makefile @@ -261,7 +261,7 @@ gmp-install: $(LOCAL)/lib/libgmp.so #------------------------------------------------------------------------------# # NETTLE -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION).tar.gz $(LOCAL)/lib/libgmp.so +nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so tar xvf $< mv nettle-$(NETTLE_VERSION) nettle touch $@ @@ -273,8 +273,6 @@ nettle-clean: rm -rf nettle.src.stamp nettle/Makefile: nettle.src.stamp - -patch -N -p1 --reject-file=- nettle/configure.ac ../nettle-3.4.1-remove-so-versioning.patch - -patch -N -p1 --reject-file=- nettle/Makefile.in ../nettle-3.4.1-remove-so-versioning-link.patch cd nettle && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure \ diff --git a/android/external/downloads/Makefile b/android/external/downloads/Makefile index bc8bdd1..f2b0eff 100644 --- a/android/external/downloads/Makefile +++ b/android/external/downloads/Makefile @@ -23,7 +23,7 @@ download-iconv: libiconv-1.15.tar.gz download-uuid: ossp-uuid_1.6.2.orig.tar.gz download-sequoia-deps: openssl-$(OPENSSL_VERSION).tar.gz gmp-$(GMP_VERSION).tar.bz2 \ - nettle-$(NETTLE_VERSION).tar.gz + nettle-$(NETTLE_VERSION)-patched.tar.gz download-etpan: libetpan.git.stamp @@ -45,6 +45,12 @@ gmp-$(GMP_VERSION).tar.bz2: wget -nc https://gmplib.org/download/gmp/gmp-$(GMP_VERSION).tar.bz2 md5sum -c gmp-$(GMP_VERSION).tar.bz2.md5 +nettle-$(NETTLE_VERSION)-patched.tar.gz: nettle-$(NETTLE_VERSION).tar.gz + tar -xvf $< + -patch -N -p1 --reject-file=- nettle-$(NETTLE_VERSION)/configure.ac ../nettle-3.4.1-remove-so-versioning.patch + -patch -N -p1 --reject-file=- nettle-$(NETTLE_VERSION)/Makefile.in ../nettle-3.4.1-remove-so-versioning-link.patch + tar -czvf $@ nettle-$(NETTLE_VERSION) + nettle-$(NETTLE_VERSION).tar.gz: wget -nc https://ftp.gnu.org/gnu/nettle/nettle-$(NETTLE_VERSION).tar.gz md5sum -c nettle-$(NETTLE_VERSION).tar.gz.md5 diff --git a/android/external/x86/Makefile b/android/external/x86/Makefile index ff3899e..bf42d88 100644 --- a/android/external/x86/Makefile +++ b/android/external/x86/Makefile @@ -257,7 +257,7 @@ gmp-install: $(LOCAL)/lib/libgmp.so #------------------------------------------------------------------------------# # NETTLE -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION).tar.gz $(LOCAL)/lib/libgmp.so +nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so tar xvf $< mv nettle-$(NETTLE_VERSION) nettle touch $@ @@ -269,8 +269,6 @@ nettle-clean: rm -rf nettle.src.stamp nettle/Makefile: nettle.src.stamp - -patch -N -p1 --reject-file=- nettle/configure.ac ../nettle-3.4.1-remove-so-versioning.patch - -patch -N -p1 --reject-file=- nettle/Makefile.in ../nettle-3.4.1-remove-so-versioning-link.patch cd nettle && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure \ diff --git a/android/external/x86_64/Makefile b/android/external/x86_64/Makefile index d99e3d6..40bfcdb 100644 --- a/android/external/x86_64/Makefile +++ b/android/external/x86_64/Makefile @@ -257,7 +257,7 @@ gmp-install: $(LOCAL)/lib/libgmp.so #------------------------------------------------------------------------------# # NETTLE -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION).tar.gz $(LOCAL)/lib/libgmp.so +nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so tar xvf $< mv nettle-$(NETTLE_VERSION) nettle touch $@ @@ -269,8 +269,6 @@ nettle-clean: rm -rf nettle.src.stamp nettle/Makefile: nettle.src.stamp - -patch -N -p1 --reject-file=- nettle/configure.ac ../nettle-3.4.1-remove-so-versioning.patch - -patch -N -p1 --reject-file=- nettle/Makefile.in ../nettle-3.4.1-remove-so-versioning-link.patch cd nettle && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure \ From 77d9585727928f8555e0113beb812f947f53ff58 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 17:17:18 +0200 Subject: [PATCH 02/29] PEMA-107 Move uuid patch application to downloads Makefile --- android/external/arm64-v8a/Makefile | 3 +-- android/external/armeabi-v7a/Makefile | 3 +-- android/external/downloads/Makefile | 7 ++++++- android/external/x86/Makefile | 3 +-- android/external/x86_64/Makefile | 3 +-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/android/external/arm64-v8a/Makefile b/android/external/arm64-v8a/Makefile index dc6954a..dd256f8 100644 --- a/android/external/arm64-v8a/Makefile +++ b/android/external/arm64-v8a/Makefile @@ -130,7 +130,7 @@ libetpan-clean: #------------------------------------------------------------------------------# # uuid -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig.tar.gz +uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz tar xvf $< mv uuid-1.6.2 uuid touch $@ @@ -144,7 +144,6 @@ uuid-clean: uuid/Makefile: uuid.src.stamp $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac cd uuid && autoconf - -patch -N -p1 --reject-file=- uuid/libtool.m4 ../libtool-Add-Android-Linux-support-iconv.patch cp ../config.sub uuid cp ../config.guess uuid cd uuid && \ diff --git a/android/external/armeabi-v7a/Makefile b/android/external/armeabi-v7a/Makefile index 7eb8edf..6a0a594 100644 --- a/android/external/armeabi-v7a/Makefile +++ b/android/external/armeabi-v7a/Makefile @@ -137,7 +137,7 @@ libetpan-clean: # using released package from debian. official ftp wasn't available today -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig.tar.gz +uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz tar xvf $< mv uuid-1.6.2 uuid touch $@ @@ -151,7 +151,6 @@ uuid-clean: uuid/Makefile: uuid.src.stamp $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac cd uuid && autoconf - -patch -N -p1 --reject-file=- uuid/libtool.m4 ../libtool-Add-Android-Linux-support-iconv.patch cp ../config.sub uuid cp ../config.guess uuid cd uuid && \ diff --git a/android/external/downloads/Makefile b/android/external/downloads/Makefile index f2b0eff..4d66ce3 100644 --- a/android/external/downloads/Makefile +++ b/android/external/downloads/Makefile @@ -20,7 +20,7 @@ downloads.stamp: download-iconv download-uuid download-sequoia-deps download-etp download-iconv: libiconv-1.15.tar.gz -download-uuid: ossp-uuid_1.6.2.orig.tar.gz +download-uuid: ossp-uuid_1.6.2.orig-patched.tar.gz download-sequoia-deps: openssl-$(OPENSSL_VERSION).tar.gz gmp-$(GMP_VERSION).tar.bz2 \ nettle-$(NETTLE_VERSION)-patched.tar.gz @@ -33,6 +33,11 @@ download-sequoia: sequoia.git.stamp libiconv-1.15.tar.gz: wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz +ossp-uuid_1.6.2.orig-patched.tar.gz: ossp-uuid_1.6.2.orig.tar.gz + tar -xvf $< + -patch -N -p1 --reject-file=- uuid-1.6.2/libtool.m4 ../libtool-Add-Android-Linux-support-iconv.patch + tar -czvf $@ uuid-1.6.2 + ossp-uuid_1.6.2.orig.tar.gz: wget http://http.debian.net/debian/pool/main/o/ossp-uuid/ossp-uuid_1.6.2.orig.tar.gz md5sum -c ossp-uuid_1.6.2.orig.tar.gz.md5 diff --git a/android/external/x86/Makefile b/android/external/x86/Makefile index bf42d88..3b96355 100644 --- a/android/external/x86/Makefile +++ b/android/external/x86/Makefile @@ -132,7 +132,7 @@ libetpan-clean: #------------------------------------------------------------------------------# # uuid -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig.tar.gz +uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz tar xvf $< mv uuid-1.6.2 uuid touch $@ @@ -146,7 +146,6 @@ uuid-clean: uuid/Makefile: uuid.src.stamp $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac cd uuid && autoconf - -patch -N -p1 --reject-file=- uuid/libtool.m4 ../libtool-Add-Android-Linux-support-iconv.patch cp ../config.sub uuid cp ../config.guess uuid cd uuid && \ diff --git a/android/external/x86_64/Makefile b/android/external/x86_64/Makefile index 40bfcdb..1399e84 100644 --- a/android/external/x86_64/Makefile +++ b/android/external/x86_64/Makefile @@ -132,7 +132,7 @@ libetpan-clean: #------------------------------------------------------------------------------# # uuid -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig.tar.gz +uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz tar xvf $< mv uuid-1.6.2 uuid touch $@ @@ -146,7 +146,6 @@ uuid-clean: uuid/Makefile: uuid.src.stamp $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac cd uuid && autoconf - -patch -N -p1 --reject-file=- uuid/libtool.m4 ../libtool-Add-Android-Linux-support-iconv.patch cp ../config.sub uuid cp ../config.guess uuid cd uuid && \ From 1bd2683d17ef3bf2c1d4121e228bbd532fc39651 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 17:18:26 +0200 Subject: [PATCH 03/29] PEMA-107 Make sure we remove the untared source afterwards --- android/external/downloads/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/external/downloads/Makefile b/android/external/downloads/Makefile index 4d66ce3..cc2bc09 100644 --- a/android/external/downloads/Makefile +++ b/android/external/downloads/Makefile @@ -37,6 +37,7 @@ ossp-uuid_1.6.2.orig-patched.tar.gz: ossp-uuid_1.6.2.orig.tar.gz tar -xvf $< -patch -N -p1 --reject-file=- uuid-1.6.2/libtool.m4 ../libtool-Add-Android-Linux-support-iconv.patch tar -czvf $@ uuid-1.6.2 + rm -rf uuid-1.6.2 ossp-uuid_1.6.2.orig.tar.gz: wget http://http.debian.net/debian/pool/main/o/ossp-uuid/ossp-uuid_1.6.2.orig.tar.gz @@ -55,6 +56,7 @@ nettle-$(NETTLE_VERSION)-patched.tar.gz: nettle-$(NETTLE_VERSION).tar.gz -patch -N -p1 --reject-file=- nettle-$(NETTLE_VERSION)/configure.ac ../nettle-3.4.1-remove-so-versioning.patch -patch -N -p1 --reject-file=- nettle-$(NETTLE_VERSION)/Makefile.in ../nettle-3.4.1-remove-so-versioning-link.patch tar -czvf $@ nettle-$(NETTLE_VERSION) + rm -rf nettle-$(NETTLE_VERSION) nettle-$(NETTLE_VERSION).tar.gz: wget -nc https://ftp.gnu.org/gnu/nettle/nettle-$(NETTLE_VERSION).tar.gz From 9646b376f110a70f9a23d821d2434d4b32b97c0e Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 17:19:27 +0200 Subject: [PATCH 04/29] PEMA-107 Create template with common parts for Makefiles --- android/external/MakefileTemplate | 385 ++++++++++++++++++++++++++++++ 1 file changed, 385 insertions(+) create mode 100644 android/external/MakefileTemplate diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate new file mode 100644 index 0000000..535bca0 --- /dev/null +++ b/android/external/MakefileTemplate @@ -0,0 +1,385 @@ +# Copyright 2019, pEp Foundation +# This file is part of pEpJNIAdapter for Android - [ARCH] build +# This file may be used under the terms of the GNU General Public License version 3 +# see LICENSE.txt + +include ../Makefile.conf + +#------------------------------------------------------------------------------# +# Makefile to build deps for use with pEpEngine +# based on gnupg-for-android/external/Makefile +#------------------------------------------------------------------------------# + +#------------------------------------------------------------------------------# +# Build parameters + +APP_ABI ?= [ARCH] +ANDROID_API ?= [ANDROID_API] + +all: build + +build: showsetup uuid-install sequoia-ffi-install libetpan-build + +#------------------------------------------------------------------------------# +# Manage paths for PREFIX, DESTDIR, LOCAL and PATH + +EXTERNAL_ROOT := $(shell pwd) + +# install root for built files +DESTDIR = $(EXTERNAL_ROOT)/.. +prefix = /output/$(APP_ABI) +LOCAL := $(DESTDIR)$(prefix) + +PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin + +NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot + +HOST = [HOST] +NDK_TOOLCHAIN = $([NDK_TOOLCHAIN_TARGET])-$(NDK_TOOLCHAIN_COMPILER) + +# include Android's build flags +TARGET_ARCH_ABI = $(APP_ABI) +include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk + +CC := $(ANDROID_NDK_HOME)/bin/$(HOST)[EXTRA_FLAGS_API]-clang +CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)[EXTRA_FLAGS_API]-clang++ +AS := $(ANDROID_NDK_HOME)/bin/$(HOST)[EXTRA_FLAGS_API]-clang + +CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 +LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie + +# change 'release' to 'debug' for unoptimized debug builds +CFLAGS += $([ARCH_DEBUG_CFLAGS]) + +#------------------------------------------------------------------------------# +# GNU Tools trickery + +# point pkg-config to the .pc files generated from these builds +export PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig + +# workaround for cross-compiling bug in autoconf +export ac_cv_func_malloc_0_nonnull=yes + +#------------------------------------------------------------------------------# +# debugging stuff + +showsetup: + @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" + @echo "NDK_SYSROOT: $(NDK_SYSROOT)" + @echo "APP_ABI: $(APP_ABI)" + @echo "HOST: $(HOST)" + @echo "CC: $(CC)" + @echo "LD: $(LD)" + @echo "CFLAGS: $(CFLAGS)" + @echo "LDFLAGS: $(LDFLAGS)" + +#------------------------------------------------------------------------------# +# libiconv + +libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz + tar xvf $< + mv libiconv-1.15 libiconv + touch $@ + +libiconv-src: libiconv.src.stamp + +libiconv-clean: + rm -rf libiconv + rm -rf libiconv.src.stamp + +libiconv/Makefile: libiconv.src.stamp + cd libiconv && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --with-lib-path=$(LOCAL)/lib \ + --with-include-path=$(LOCAL)/include \ + --host=$(HOST) \ + --enable-static \ + --disable-shared \ + --prefix=$(LOCAL) + +libiconv/lib/.libs/libiconv.a: libiconv/Makefile + $(MAKE) -C libiconv + +$(LOCAL)/lib/libiconv.a: libiconv/lib/.libs/libiconv.a + $(MAKE) -C libiconv DESTDIR=$(DESTDIR) prefix=$(prefix) install + ls -l $(LOCAL)/lib/libiconv.a + +libiconv-build: libiconv/lib/.libs/libiconv.a + +libiconv-install: $(LOCAL)/lib/libiconv.a + +#------------------------------------------------------------------------------# +# libetpan +libetpan.src.stamp: ../downloads/libetpan.tar.gz + mkdir -p libetpan + cd libetpan && tar xvf ../$< + touch $@ + +libetpan/Makefile: libetpan.src.stamp | libiconv-install + cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh $(APP_ABI) + cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/$(APP_ABI)/lib/* $(LOCAL)/lib/ + cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/include/* $(LOCAL)/include/ + touch $@ + +libetpan-build: libetpan/Makefile + +libetpan-clean: + rm -rf libetpan + rm -rf libetpan.src.stamp + +#------------------------------------------------------------------------------# +# uuid + +uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz + tar xvf $< + mv uuid-1.6.2 uuid + touch $@ + +uuid-src: uuid.src.stamp + +uuid-clean: + rm -rf uuid + rm -rf uuid.src.stamp + +uuid/Makefile: uuid.src.stamp + $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac + cd uuid && autoconf + cp ../config.sub uuid + cp ../config.guess uuid + cd uuid && \ + CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --enable-static \ + --host=$(HOST) \ + --with-gnu-ld \ + --prefix=$(LOCAL) + +uuid/.libs/libuuid.so: uuid/Makefile + $(MAKE) -C uuid + +$(LOCAL)/lib/libuuid.so: uuid/.libs/libuuid.so + # install fails copying uuid cmdline tool, but libs are copied ... + -$(MAKE) -C uuid DESTDIR=$(DESTDIR) prefix=$(prefix) install + echo "****** THIS ERROR WAS WILLINGLY IGNORED ******" + ls -l $(LOCAL)/lib/libuuid.so + +uuid-build: uuid/.libs/libuuid.so + +uuid-prebuild: uuid/jni/Android.mk uuid/Makefile + +uuid-install: $(LOCAL)/lib/libuuid.so | uuid-prebuild + +uuid/jni/Android.mk: uuid.src.stamp + mkdir -p uuid/jni + cp ../libuuid.Android.mk uuid/jni/Android.mk + + +#------------------------------------------------------------------------------# +# Sequoia + +sequoia-deps-build: openssl-install nettle-install + +#------------------------------------------------------------------------------# +# OpenSSL + +openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz + tar xvf $< + mv openssl-$(OPENSSL_VERSION) openssl + touch $@ + +openssl-src: openssl.src.stamp + +openssl-clean: + rm -rf openssl + rm -rf openssl.src.stamp + +OPENSSL_ARCHITECTURE:=[OPENSSL_ARCHITECTURE] + +openssl/Makefile: openssl.src.stamp + cd openssl && \ + PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) +openssl/libssl.so: | openssl/Makefile + PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl + +$(LOCAL)/lib/libssl.so: openssl/libssl.so + cd openssl && \ + cp libcrypto.so $(LOCAL)/lib && \ + cp libcrypto.a $(LOCAL)/lib && \ + cp libssl.so $(LOCAL)/lib && \ + cp libssl.a $(LOCAL)/lib + ls -l $(LOCAL)/lib/libssl.so + +openssl-build: openssl/libssl.so + +openssl-install: $(LOCAL)/lib/libssl.so + + +#------------------------------------------------------------------------------# +# GMP + +gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2 + tar xvf $< + mv gmp-$(GMP_VERSION) gmp + touch $@ + +gmp-src: gmp.src.stamp + +gmp-clean: + rm -rf gmp + rm -rf gmp.src.stamp + +gmp/Makefile: gmp.src.stamp + cd gmp && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --host=$(HOST) \ + --prefix=$(LOCAL) \ + --disable-static[GMP_MAKEFILE_EXTRA] + + +gmp/.libs/libgmp.so: gmp/Makefile + $(MAKE) -C gmp + +$(LOCAL)/lib/libgmp.so: gmp/.libs/libgmp.so + $(MAKE) -C gmp DESTDIR=$(DESTDIR) prefix=$(prefix) install + #gmp/libtool --finish $(LOCAL)/lib/ + ls -l $(LOCAL)/lib/libgmp.so + touch $@ + +gmp-build: gmp/.libs/libgmp.so + +gmp-install: $(LOCAL)/lib/libgmp.so + + +#------------------------------------------------------------------------------# +# NETTLE + +nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so + tar xvf $< + mv nettle-$(NETTLE_VERSION) nettle + touch $@ + +nettle-src: nettle.src.stamp + +nettle-clean: + rm -rf nettle + rm -rf nettle.src.stamp + +nettle/Makefile: nettle.src.stamp gmp-install + cd nettle && \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + ./configure \ + --with-lib-path=$(LOCAL)/lib \ + --with-include-path=$(LOCAL)/include \ + --disable-static \ + --disable-documentation \ + --host=$(HOST) \ + --prefix=$(LOCAL) + +nettle/libnettle.so: nettle/Makefile + $(MAKE) -C nettle + +$(LOCAL)/lib/libnettle.so: nettle/libnettle.so + $(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install + cp nettle/libnettle.so $(LOCAL)/lib/libnettle.so + cp nettle/libhogweed.so $(LOCAL)/lib/libhogweed.so + +nettle-build: nettle/libnettle.so + +nettle-install: $(LOCAL)/lib/libnettle.so + + +#------------------------------------------------------------------------------# +# Sequoia-ffi + +CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build/ + +sequoia.src.stamp: ../downloads/sequoia.tar.gz + mkdir -p sequoia + cd sequoia && tar xvf ../$< + $(SED) -i 's,1.48.0,1.49.0,' sequoia/rust-toolchain + cd sequoia && cargo update -p nettle-sys --precise 2.0.8 + mkdir -p $(LOCAL)/lib/ +# This is a bad fix, we should move this to a common makefile (but not the .conf one) + find -L $(ANDROID_NDK) -name libunwind.a -execdir sh -c 'echo "INPUT(-lunwind)" > $(LOCAL)/lib/libgcc.a' \; + touch $@ + +sequoia-ffi-clean: + rm -rf sequoia + rm -rf sequoia.src.stamp + +$(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build + cd sequoia && PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" \ + CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + LD_LIBRARY_PATH=$(LOCAL)/lib/ \ + PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig \ + PKG_CONFIG_ALLOW_CROSS=1 \ + ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR="$(LOCAL)/lib" \ + ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR="$(LOCAL)/include" \ + ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR="$(LOCAL)/bin" \ + CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --target [SEQUOIA_ARCH] -p sequoia-openpgp-ffi --release + +$(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.so + cp $(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ + cp -r sequoia/openpgp-ffi/include/* $(LOCAL)/include + + +sequoia-ffi-build: $(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.so + +sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so + +#------------------------------------------------------------------------------# +# assets for Android app + +#ASSETS := $(EXTERNAL_ROOT)/assets +# +#assets: clean-assets +# # add the new stuff +# install -d $(ASSETS) +# cp -a $(LOCAL)/* $(ASSETS) +# # remove all the stuff we don't need +# rm -f $(ASSETS)/bin/*-static +# rm -f $(ASSETS)/bin/curl* +# rm -f $(ASSETS)/lib/*.a $(ASSETS)/lib/*.la +# # remove lib symlinks since Android AssetManager copies them as files +# rm -f $(ASSETS)/lib/*.so +# # remove .so.0 symlink and rename the .so.0.12.0 file to it +# for f in $(ASSETS)/lib/*.so.[0-9]*; do \ +# echo $$f; \ +# test ! -L $$f || \ +# (rm $$f && mv $$f.[0-9]* $$f); \ +# done +# rm -rf $(ASSETS)/include +# rm -rf $(ASSETS)/share/man $(ASSETS)/share/info $(ASSETS)/share/doc +# rm -rf $(ASSETS)/tests +# + +#------------------------------------------------------------------------------# +# clean + +clean-assets: + rm -rf $(ASSETS) + +clean-install: + rm -rf $(LOCAL) + +clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-clean + +clean-all: clean + rm -rf *.git + rm -rf *.stamp +#------------------------------------------------------------------------------# + +.PHONY = clean clean-install clean-assets libetpan-clean \ + libiconv-build libiconv-install \ + libetpan-build \ + uuid-build uuid-prebuild uuid-install \ + gmp-build gmp-install \ + sequoia-deps-build \ + openssl-build openssl-install \ + nettle-build nettle-install \ + sequoia-ffi-build sequoia-ffi-install\ + assets \ + $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN)\ + showsetup From cb2139772c471daf96f689285aa95af73e959803 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 18:06:07 +0200 Subject: [PATCH 05/29] PEMA-107 Add script to generate a Makefile for an arch --- android/external/createMakefile.sh | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 android/external/createMakefile.sh diff --git a/android/external/createMakefile.sh b/android/external/createMakefile.sh new file mode 100644 index 0000000..c38dabc --- /dev/null +++ b/android/external/createMakefile.sh @@ -0,0 +1,79 @@ +#!/bin/zsh +#emulate -LR bash +#cd ~code/android/pEpJNIAdapter/external + +ARCH_DEST="$1" +mkdir $ARCH_DEST +cp MakefileTemplate $ARCH_DEST/Makefile +FILE_DEST=$ARCH_DEST/Makefile + +################################################################################ +# Select TEMPLATE FIELDS FOR ARCH # +################################################################################ + +case $ARCH_DEST in + x86) + ANDROID_API=18 + HOST=i686-linux-android + NDK_TOOLCHAIN_TARGET="APP_ABI" + ARCH_DEBUG_CFLAGS=TARGET_x86_debug_CFLAGS + OPENSSL_ARCHITECTURE=android-x86 + SEQUOIA_ARCH=i686-linux-android + ;; + x86_64) + ANDROID_API=21 + HOST=x86_64-linux-android + EXTRA_FLAGS_API="\$(ANDROID_API)" + NDK_TOOLCHAIN_TARGET="APP_ABI" + ARCH_DEBUG_CFLAGS=TARGET_x86_64_debug_CFLAGS + OPENSSL_ARCHITECTURE=android-x86_64 + SEQUOIA_ARCH=x86_64-linux-android + ;; + armeabi-v7a) + ANDROID_API=18 + HOST=arm-linux-androideabi + NDK_TOOLCHAIN_TARGET="HOST" + ARCH_DEBUG_CFLAGS=TARGET_arm_debug_CFLAGS + OPENSSL_ARCHITECTURE=android-arm + SEQUOIA_ARCH=armv7-linux-androideabi + ;; + arm64-v8a) + ANDROID_API=21 + HOST=aarch64-linux-android + NDK_TOOLCHAIN_TARGET="HOST" + ARCH_DEBUG_CFLAGS=TARGET_arm64_debug_CFLAGS + OPENSSL_ARCHITECTURE=android-arm64 + GMP_MAKEFILE_EXTRA=' MPN_PATH=\"arm64 generic\"' + SEQUOIA_ARCH=aarch64-linux-android + ;; + esac + +################################################################################ +# Select GNU SED # +################################################################################ + +OS="$(uname -s)" + +case "${OS}" in + Linux*) SED=sed;; + Darwin*) SED=gsed;; + CYGWIN*) echo "UNSUPORTED YET" && exit;; + MINGW*) echo "UNSUPORTED YET" && exit;; + *) echo "UNKNOWN:${OS}" && exit;; +esac + +################################################################################ +# REPLACE FIELDS IN TEMPLATE # +################################################################################ + +$SED -i 's/\[ARCH\]/'"$ARCH_DEST"'/g' $FILE_DEST +$SED -i 's/\[ANDROID_API\]/'"$ANDROID_API"'/g' $FILE_DEST +$SED -i 's/\[HOST\]/'"$HOST"'/g' $FILE_DEST +$SED -i 's/\[EXTRA_FLAGS_API\]/'"$EXTRA_FLAGS_API"'/g' $FILE_DEST +$SED -i 's/\[NDK_TOOLCHAIN_TARGET\]/'"$NDK_TOOLCHAIN_TARGET"'/g' $FILE_DEST +$SED -i 's/\[ARCH_DEBUG_CFLAGS\]/'"$ARCH_DEBUG_CFLAGS"'/g' $FILE_DEST +$SED -i 's/\[OPENSSL_ARCHITECTURE\]/'"$OPENSSL_ARCHITECTURE"'/g' $FILE_DEST +$SED -i 's/\[GMP_MAKEFILE_EXTRA\]/'"$GMP_MAKEFILE_EXTRA"'/g' $FILE_DEST +$SED -i 's/\[SEQUOIA_ARCH\]/'"$SEQUOIA_ARCH"'/g' $FILE_DEST + +cat $FILE_DEST From 8fce027f48bece8029bba9c4606338398fb6f664 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 18:09:49 +0200 Subject: [PATCH 06/29] PEMA-107 Modify external/Makefile to generate and delete Makefiles --- android/external/Makefile | 40 +++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/android/external/Makefile b/android/external/Makefile index b4691a9..b28aa9e 100644 --- a/android/external/Makefile +++ b/android/external/Makefile @@ -25,31 +25,47 @@ build: all all: build-arm build-arm64 build-x86 build-x86_64 -build-arm: downloads/downloads.stamp +build-arm: armeabi-v7a/Makefile $(MAKE) -C armeabi-v7a -build-arm64: downloads/downloads.stamp +armeabi-v7a/Makefile: downloads/downloads.stamp + sh createMakefile.sh armeabi-v7a + +build-arm64: arm64-v8a/Makefile $(MAKE) -C arm64-v8a -build-x86: downloads/downloads.stamp +arm64-v8a/Makefile: downloads/downloads.stamp + sh createMakefile.sh arm64-v8a + +build-x86: x86/Makefile $(MAKE) -C x86 -build-x86_64: downloads/downloads.stamp +x86/Makefile: downloads/downloads.stamp + sh createMakefile.sh x86 + +build-x86_64: x86_64/Makefile $(MAKE) -C x86_64 +x86_64/Makefile: downloads/downloads.stamp + sh createMakefile.sh x86_64 + clean: - $(MAKE) -C armeabi-v7a clean - $(MAKE) -C arm64-v8a clean - $(MAKE) -C x86 clean - $(MAKE) -C x86_64 clean + -$(MAKE) -C armeabi-v7a clean + -$(MAKE) -C arm64-v8a clean + -$(MAKE) -C x86 clean + -$(MAKE) -C x86_64 clean clean-all: $(MAKE) -C downloads clean - $(MAKE) -C armeabi-v7a clean-all - $(MAKE) -C arm64-v8a clean-all - $(MAKE) -C x86 clean-all - $(MAKE) -C x86_64 clean-all rm -rf build + -$(MAKE) -C armeabi-v7a clean-all + -$(MAKE) -C arm64-v8a clean-all + -$(MAKE) -C x86 clean-all + -$(MAKE) -C x86_64 clean-all + rm -f arm64-v8a/Makefile + rm -f armeabi-v7a/Makefile + rm -f x86/Makefile + rm -f x86_64/Makefile downloads/downloads.stamp: $(MAKE) -C downloads From b3b46b669b99a69281789e258e525f85c7abc4b7 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 18:13:32 +0200 Subject: [PATCH 07/29] PEMA-107 Add clean as prerequisite for clean-all --- android/external/Makefile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/android/external/Makefile b/android/external/Makefile index b28aa9e..7cd5898 100644 --- a/android/external/Makefile +++ b/android/external/Makefile @@ -55,17 +55,13 @@ clean: -$(MAKE) -C x86 clean -$(MAKE) -C x86_64 clean -clean-all: +clean-all: clean $(MAKE) -C downloads clean rm -rf build - -$(MAKE) -C armeabi-v7a clean-all - -$(MAKE) -C arm64-v8a clean-all - -$(MAKE) -C x86 clean-all - -$(MAKE) -C x86_64 clean-all - rm -f arm64-v8a/Makefile - rm -f armeabi-v7a/Makefile - rm -f x86/Makefile - rm -f x86_64/Makefile + rm -rf arm64-v8a + rm -rf armeabi-v7a + rm -rf x86 + rm -rf x86_64 downloads/downloads.stamp: $(MAKE) -C downloads From 1d068ff8448cb1676e898b31af42cb6f3b37e391 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 18:14:50 +0200 Subject: [PATCH 08/29] PEMA-107 Remove unused files --- android/external/arm64-v8a/Makefile | 385 ------------------------- android/external/armeabi-v7a/Makefile | 395 -------------------------- android/external/x86/Makefile | 387 ------------------------- android/external/x86_64/Makefile | 387 ------------------------- 4 files changed, 1554 deletions(-) delete mode 100644 android/external/arm64-v8a/Makefile delete mode 100644 android/external/armeabi-v7a/Makefile delete mode 100644 android/external/x86/Makefile delete mode 100644 android/external/x86_64/Makefile diff --git a/android/external/arm64-v8a/Makefile b/android/external/arm64-v8a/Makefile deleted file mode 100644 index dd256f8..0000000 --- a/android/external/arm64-v8a/Makefile +++ /dev/null @@ -1,385 +0,0 @@ -# Copyright 2019, pEp Foundation -# This file is part of pEpJNIAdapter for Android - ARM64 v8a build -# This file may be used under the terms of the GNU General Public License version 3 -# see LICENSE.txt - -include ../Makefile.conf - -#------------------------------------------------------------------------------# -# Makefile to build deps for use with pEpEngine -# based on gnupg-for-android/external/Makefile -#------------------------------------------------------------------------------# - -#------------------------------------------------------------------------------# -# Build parameters - -APP_ABI ?= arm64-v8a - -all: build - -build: showsetup uuid-install sequoia-ffi-install libetpan-build - -#------------------------------------------------------------------------------# -# Manage paths for PREFIX, DESTDIR, LOCAL and PATH - -EXTERNAL_ROOT := $(shell pwd) - -# install root for built files -DESTDIR = $(EXTERNAL_ROOT)/.. -prefix = /output/$(APP_ABI) -LOCAL := $(DESTDIR)$(prefix) - -PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin - -NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot - -HOST = aarch64-linux-android -NDK_TOOLCHAIN = $(HOST)-$(NDK_TOOLCHAIN_COMPILER) - -# include Android's build flags -TARGET_ARCH_ABI = $(APP_ABI) -include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk - -CC := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang -CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang++ -AS := $(CC) - -CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 -LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie - -# change 'release' to 'debug' for unoptimized debug builds -CFLAGS += $(TARGET_arm64_debug_CFLAGS) - -#------------------------------------------------------------------------------# -# GNU Tools trickery - -# point pkg-config to the .pc files generated from these builds -export PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig - -# workaround for cross-compiling bug in autoconf -export ac_cv_func_malloc_0_nonnull=yes - -#------------------------------------------------------------------------------# -# debugging stuff - -showsetup: - @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" - @echo "NDK_SYSROOT: $(NDK_SYSROOT)" - @echo "APP_ABI: $(APP_ABI)" - @echo "HOST: $(HOST)" - @echo "CC: $(CC)" - @echo "LD: $(LD)" - @echo "CFLAGS: $(CFLAGS)" - @echo "LDFLAGS: $(LDFLAGS)" - -#------------------------------------------------------------------------------# -# libiconv - -libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz - tar xvf $< - mv libiconv-1.15 libiconv - touch $@ - -libiconv-src: libiconv.src.stamp - -libiconv-clean: - rm -rf libiconv - rm -rf libiconv.src.stamp - -libiconv/Makefile: libiconv.src.stamp - cd libiconv && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --host=$(HOST) \ - --enable-static \ - --disable-shared \ - --prefix=$(LOCAL) - -libiconv/lib/.libs/libiconv.a: libiconv/Makefile - $(MAKE) -C libiconv - -$(LOCAL)/lib/libiconv.a: libiconv/lib/.libs/libiconv.a - $(MAKE) -C libiconv DESTDIR=$(DESTDIR) prefix=$(prefix) install - ls -l $(LOCAL)/lib/libiconv.a - -libiconv-build: libiconv/lib/.libs/libiconv.a - -libiconv-install: $(LOCAL)/lib/libiconv.a - -#------------------------------------------------------------------------------# -# libetpan -libetpan.src.stamp: ../downloads/libetpan.tar.gz - mkdir -p libetpan - cd libetpan && tar xvf ../$< - touch $@ - -libetpan/Makefile: libetpan.src.stamp | libiconv-install - cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh $(APP_ABI) - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/$(APP_ABI)/lib/* $(LOCAL)/lib/ - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/include/* $(LOCAL)/include/ - touch $@ - -libetpan-build: libetpan/Makefile - -libetpan-clean: - rm -rf libetpan - rm -rf libetpan.src.stamp - -#------------------------------------------------------------------------------# -# uuid - -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz - tar xvf $< - mv uuid-1.6.2 uuid - touch $@ - -uuid-src: uuid.src.stamp - -uuid-clean: - rm -rf uuid - rm -rf uuid.src.stamp - -uuid/Makefile: uuid.src.stamp - $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac - cd uuid && autoconf - cp ../config.sub uuid - cp ../config.guess uuid - cd uuid && \ - CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --enable-static \ - --host=$(HOST) \ - --with-gnu-ld \ - --prefix=$(LOCAL) - -uuid/.libs/libuuid.so: uuid/Makefile - $(MAKE) -C uuid - -$(LOCAL)/lib/libuuid.so: uuid/.libs/libuuid.so - # install fails copying uuid cmdline tool, but libs are copied ... - -$(MAKE) -C uuid DESTDIR=$(DESTDIR) prefix=$(prefix) install - echo "****** THIS ERROR WAS WILLINGLY IGNORED ******" - ls -l $(LOCAL)/lib/libuuid.so - -uuid-build: uuid/.libs/libuuid.so - -uuid-prebuild: uuid/jni/Android.mk uuid/Makefile - -uuid-install: $(LOCAL)/lib/libuuid.so | uuid-prebuild - -uuid/jni/Android.mk: uuid.src.stamp - mkdir -p uuid/jni - cp ../libuuid.Android.mk uuid/jni/Android.mk - - -#------------------------------------------------------------------------------# -# Sequoia - -sequoia-deps-build: openssl-install nettle-install - -#------------------------------------------------------------------------------# -# OpenSSL - -openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz - tar xvf $< - mv openssl-$(OPENSSL_VERSION) openssl - touch $@ - -openssl-src: openssl.src.stamp - -openssl-clean: - rm -rf openssl - rm -rf openssl.src.stamp - -OPENSSL_ARCHITECTURE:=android-arm64 - -openssl/Makefile: openssl.src.stamp - cd openssl && \ - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) -openssl/libssl.so: | openssl/Makefile - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl - -$(LOCAL)/lib/libssl.so: openssl/libssl.so - cd openssl && \ - cp libcrypto.so $(LOCAL)/lib && \ - cp libcrypto.a $(LOCAL)/lib && \ - cp libssl.so $(LOCAL)/lib && \ - cp libssl.a $(LOCAL)/lib - ls -l $(LOCAL)/lib/libssl.so - -openssl-build: openssl/libssl.so - -openssl-install: $(LOCAL)/lib/libssl.so - - -#------------------------------------------------------------------------------# -# GMP - -gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2 - tar xvf $< - mv gmp-$(GMP_VERSION) gmp - touch $@ - -gmp-src: gmp.src.stamp - -gmp-clean: - rm -rf gmp - rm -rf gmp.src.stamp - -gmp/Makefile: gmp.src.stamp - cd gmp && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --host=$(HOST) \ - --prefix=$(LOCAL) \ - --disable-static \ - MPN_PATH="arm64 generic" - - -gmp/.libs/libgmp.so: gmp/Makefile - $(MAKE) -C gmp - -$(LOCAL)/lib/libgmp.so: gmp/.libs/libgmp.so - $(MAKE) -C gmp DESTDIR=$(DESTDIR) prefix=$(prefix) install - #gmp/libtool --finish $(LOCAL)/lib/ - ls -l $(LOCAL)/lib/libgmp.so - touch $@ - -gmp-build: gmp/.libs/libgmp.so - -gmp-install: $(LOCAL)/lib/libgmp.so - - -#------------------------------------------------------------------------------# -# NETTLE - -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so - tar xvf $< - mv nettle-$(NETTLE_VERSION) nettle - touch $@ - -nettle-src: nettle.src.stamp gmp-install - -nettle-clean: - rm -rf nettle - rm -rf nettle.src.stamp - -nettle/Makefile: nettle.src.stamp - cd nettle && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --disable-static \ - --disable-documentation \ - --host=$(HOST) \ - --prefix=$(LOCAL) - -nettle/libnettle.so: nettle/Makefile - $(MAKE) -C nettle - -$(LOCAL)/lib/libnettle.so: nettle/libnettle.so - $(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install - cp nettle/libnettle.so $(LOCAL)/lib/libnettle.so - cp nettle/libhogweed.so $(LOCAL)/lib/libhogweed.so - -nettle-build: nettle/libnettle.so - -nettle-install: $(LOCAL)/lib/libnettle.so - - -#------------------------------------------------------------------------------# -# Sequoia-ffi - -CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build/ - -sequoia.src.stamp: ../downloads/sequoia.tar.gz - mkdir -p sequoia - cd sequoia && tar xvf ../$< - $(SED) -i 's,1.48.0,1.49.0,' sequoia/rust-toolchain - cd sequoia && cargo update -p nettle-sys --precise 2.0.8 - mkdir -p $(LOCAL)/lib/ -# This is a bad fix, we should move this to a common makefile (but not the .conf one) - find -L $(ANDROID_NDK) -name libunwind.a -execdir sh -c 'echo "INPUT(-lunwind)" > $(LOCAL)/lib/libgcc.a' \; - touch $@ - -sequoia-ffi-clean: - rm -rf sequoia - rm -rf sequoia.src.stamp - -$(CARGO_TARGET_DIR)/aarch64-linux-android/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build - cd sequoia && PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - LD_LIBRARY_PATH=$(LOCAL)/lib/ \ - PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig \ - PKG_CONFIG_ALLOW_CROSS=1 \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR="$(LOCAL)/lib" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR="$(LOCAL)/include" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR="$(LOCAL)/bin" \ - CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --target aarch64-linux-android -p sequoia-openpgp-ffi --release - -$(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/aarch64-linux-android/release/libsequoia_openpgp_ffi.so - cp $(CARGO_TARGET_DIR)/aarch64-linux-android/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ - cp -r sequoia/openpgp-ffi/include/* $(LOCAL)/include - - -sequoia-ffi-build: $(CARGO_TARGET_DIR)/aarch64-linux-android/release/libsequoia_openpgp_ffi.so - -sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so - -#------------------------------------------------------------------------------# -# assets for Android app - -#ASSETS := $(EXTERNAL_ROOT)/assets -# -#assets: clean-assets -# # add the new stuff -# install -d $(ASSETS) -# cp -a $(LOCAL)/* $(ASSETS) -# # remove all the stuff we don't need -# rm -f $(ASSETS)/bin/*-static -# rm -f $(ASSETS)/bin/curl* -# rm -f $(ASSETS)/lib/*.a $(ASSETS)/lib/*.la -# # remove lib symlinks since Android AssetManager copies them as files -# rm -f $(ASSETS)/lib/*.so -# # remove .so.0 symlink and rename the .so.0.12.0 file to it -# for f in $(ASSETS)/lib/*.so.[0-9]*; do \ -# echo $$f; \ -# test ! -L $$f || \ -# (rm $$f && mv $$f.[0-9]* $$f); \ -# done -# rm -rf $(ASSETS)/include -# rm -rf $(ASSETS)/share/man $(ASSETS)/share/info $(ASSETS)/share/doc -# rm -rf $(ASSETS)/tests -# - -#------------------------------------------------------------------------------# -# clean - -clean-assets: - rm -rf $(ASSETS) - -clean-install: - rm -rf $(LOCAL) - -clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-clean - -clean-all: clean - rm -rf *.git - rm -rf *.stamp -#------------------------------------------------------------------------------# - -.PHONY = clean clean-install clean-assets libetpan-clean\ - libiconv-build libiconv-install \ - libetpan-build \ - uuid-build uuid-prebuild uuid-install \ - gmp-build gmp-install \ - sequoia-deps-build \ - openssl-build openssl-install \ - nettle-build nettle-install \ - sequoia-ffi-build sequoia-ffi-install\ - assets \ - $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN)\ - showsetup diff --git a/android/external/armeabi-v7a/Makefile b/android/external/armeabi-v7a/Makefile deleted file mode 100644 index 6a0a594..0000000 --- a/android/external/armeabi-v7a/Makefile +++ /dev/null @@ -1,395 +0,0 @@ -# Copyright 2019, pEp Foundation -# This file is part of pEpJNIAdapter for Android - ARMv7 build -# This file may be used under the terms of the GNU General Public License version 3 -# see LICENSE.txt - -include ../Makefile.conf - -#------------------------------------------------------------------------------# -# Makefile to build deps for use with pEpEngine -# based on gnupg-for-android/external/Makefile -#------------------------------------------------------------------------------# - -#------------------------------------------------------------------------------# -# Build parameters - -APP_ABI ?= armeabi-v7a - -all: build -#assets - -build: showsetup uuid-install sequoia-ffi-install libetpan-build - - -#------------------------------------------------------------------------------# -# Manage paths for PREFIX, DESTDIR, LOCAL and PATH - -EXTERNAL_ROOT := $(shell pwd) - -# install root for built files -DESTDIR = $(EXTERNAL_ROOT)/.. -prefix = /output/$(APP_ABI) -LOCAL := $(DESTDIR)$(prefix) - -PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin - -NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot - -HOST = arm-linux-androideabi -HOST_V7 = armv7a-linux-androideabi -NDK_TOOLCHAIN = $(HOST)-$(NDK_TOOLCHAIN_COMPILER) - -# include Android's build flags -TARGET_ARCH_ABI = $(APP_ABI) -include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk - -ANDROID_NDK_HOME=$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(TOOLCHAIN_ARCH) - -CC := $(ANDROID_NDK_HOME)/bin/$(HOST_V7)$(ANDROID_API)-clang -CXX := $(ANDROID_NDK_HOME)/bin/$(HOST_V7)$(ANDROID_API)-clang++ -AS := $(CC) - -CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 -LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie - -# change 'release' to 'debug' for unoptimized debug builds -CFLAGS += $(TARGET_arm_debug_CFLAGS) - -#------------------------------------------------------------------------------# -# GNU Tools trickery - -# point pkg-config to the .pc files generated from these builds -export PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig - -# workaround for cross-compiling bug in autoconf -export ac_cv_func_malloc_0_nonnull=yes - -#------------------------------------------------------------------------------# -# debugging stuff - -showsetup: - @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" - @echo "NDK_SYSROOT: $(NDK_SYSROOT)" - @echo "APP_ABI: $(APP_ABI)" - @echo "HOST: $(HOST)" - @echo "CC: $(CC)" - @echo "LD: $(LD)" - @echo "CFLAGS: $(CFLAGS)" - @echo "LDFLAGS: $(LDFLAGS)" - -#------------------------------------------------------------------------------# -# libiconv - -libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz - tar xvf $< - mv libiconv-1.15 libiconv - touch $@ - -libiconv-src: libiconv.src.stamp - -libiconv-clean: - rm -rf libiconv - rm -rf libiconv.src.stamp - -libiconv/Makefile: libiconv.src.stamp - cd libiconv && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --host=$(HOST) \ - --enable-static \ - --disable-shared \ - --prefix=$(LOCAL) - -libiconv/lib/.libs/libiconv.a: libiconv/Makefile - $(MAKE) -C libiconv - -$(LOCAL)/lib/libiconv.a: libiconv/lib/.libs/libiconv.a - $(MAKE) -C libiconv DESTDIR=$(DESTDIR) prefix=$(prefix) install - ls -l $(LOCAL)/lib/libiconv.a - -libiconv-build: libiconv/lib/.libs/libiconv.a - -libiconv-install: $(LOCAL)/lib/libiconv.a - -#------------------------------------------------------------------------------# -# libetpan -libetpan.src.stamp: ../downloads/libetpan.tar.gz - mkdir -p libetpan - cd libetpan && tar xvf ../$< - touch $@ - -libetpan/Makefile: libetpan.src.stamp | libiconv-install - cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh $(APP_ABI) - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/$(APP_ABI)/lib/* $(LOCAL)/lib/ - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/include/* $(LOCAL)/include/ - touch $@ - -libetpan-build: libetpan/Makefile - -libetpan-clean: - rm -rf libetpan - rm -rf libetpan.src.stamp - -#------------------------------------------------------------------------------# -# uuid - -# using released package from debian. official ftp wasn't available today - -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz - tar xvf $< - mv uuid-1.6.2 uuid - touch $@ - -uuid-src: uuid.src.stamp - -uuid-clean: - rm -rf uuid - rm -rf uuid.src.stamp - -uuid/Makefile: uuid.src.stamp - $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac - cd uuid && autoconf - cp ../config.sub uuid - cp ../config.guess uuid - cd uuid && \ - CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --enable-static \ - --host=$(HOST) \ - --with-gnu-ld \ - --prefix=$(LOCAL) - -uuid/.libs/libuuid.so: uuid/Makefile - $(MAKE) -C uuid - -$(LOCAL)/lib/libuuid.so: uuid/.libs/libuuid.so - # install fails copying uuid cmdline tool, but libs are copied ... - -$(MAKE) -C uuid DESTDIR=$(DESTDIR) prefix=$(prefix) install - echo "****** THIS ERROR WAS WILLINGLY IGNORED ******" - ls -l $(LOCAL)/lib/libuuid.so - -uuid-build: uuid/.libs/libuuid.so - -uuid-prebuild: uuid/jni/Android.mk uuid/Makefile - -uuid-install: $(LOCAL)/lib/libuuid.so | uuid-prebuild - -uuid/jni/Android.mk: uuid.src.stamp - mkdir -p uuid/jni - cp ../libuuid.Android.mk uuid/jni/Android.mk - - -#------------------------------------------------------------------------------# -# Sequoia - -sequoia-deps-build: openssl-install nettle-install - -#------------------------------------------------------------------------------# -# OpenSSL - -openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz - tar xvf $< - mv openssl-$(OPENSSL_VERSION) openssl - touch $@ - -openssl-src: openssl.src.stamp - -openssl-clean: - rm -rf openssl - rm -rf openssl.src.stamp - - -OPENSSL_ARCHITECTURE:=android-arm - -openssl/Makefile: openssl.src.stamp - cd openssl && \ - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) -openssl/libssl.so: | openssl/Makefile - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl - -$(LOCAL)/lib/libssl.so: openssl/libssl.so - cd openssl && \ - cp libcrypto.so $(LOCAL)/lib && \ - cp libcrypto.a $(LOCAL)/lib && \ - cp libssl.so $(LOCAL)/lib && \ - cp libssl.a $(LOCAL)/lib - ls -l $(LOCAL)/lib/libssl.so - -openssl-build: openssl/libssl.so - -openssl-install: $(LOCAL)/lib/libssl.so - - -#------------------------------------------------------------------------------# -# GMP - -gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2 - tar xvf $< - mv gmp-$(GMP_VERSION) gmp - touch $@ - -gmp-src: gmp.src.stamp - -gmp-clean: - rm -rf gmp - rm -rf gmp.src.stamp - -gmp/Makefile: gmp.src.stamp - cd gmp && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --host=$(HOST) \ - --prefix=$(LOCAL) - -gmp/.libs/libgmp.so: gmp/Makefile - $(MAKE) -C gmp - -$(LOCAL)/lib/libgmp.so: gmp/.libs/libgmp.so - $(MAKE) -C gmp DESTDIR=$(DESTDIR) prefix=$(prefix) install - #gmp/libtool --finish $(LOCAL)/lib/ - ls -l $(LOCAL)/lib/libgmp.so - touch $@ - -gmp-build: gmp/.libs/libgmp.so - -gmp-install: $(LOCAL)/lib/libgmp.so - - -#------------------------------------------------------------------------------# -# NETTLE - -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so - tar xvf $< - mv nettle-$(NETTLE_VERSION) nettle - touch $@ - -nettle-src: nettle.src.stamp - -nettle-clean: - rm -rf nettle - rm -rf nettle.src.stamp - -nettle/Makefile: nettle.src.stamp - cd nettle && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --disable-static \ - --disable-documentation \ - --host=$(HOST) \ - --prefix=$(LOCAL) - -nettle/libnettle.so: nettle/Makefile - $(MAKE) -C nettle - -$(LOCAL)/lib/libnettle.so: nettle/libnettle.so - $(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install - cp nettle/libnettle.so $(LOCAL)/lib/libnettle.so - cp nettle/libhogweed.so $(LOCAL)/lib/libhogweed.so - -nettle-build: nettle/libnettle.so - -nettle-install: $(LOCAL)/lib/libnettle.so - - -#------------------------------------------------------------------------------# -# Sequoia-ffi -CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build - -sequoia.src.stamp: ../downloads/sequoia.tar.gz - mkdir -p sequoia - cd sequoia && tar xvf ../$< - $(SED) -i 's,1.48.0,1.49.0,' sequoia/rust-toolchain - cd sequoia && cargo update -p nettle-sys --precise 2.0.8 - mkdir -p $(LOCAL)/lib/ -# This is a bad fix, we should move this to a common makefile (but not the .conf one) - find -L $(ANDROID_NDK) -name libunwind.a -execdir sh -c 'echo "INPUT(-lunwind)" > $(LOCAL)/lib/libgcc.a' \; - touch $@ - -sequoia-ffi-clean: - rm -rf sequoia - rm -rf sequoia.src.stamp - -$(CARGO_TARGET_DIR)/armv7-linux-androideabi/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build - cd sequoia && PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - LD_LIBRARY_PATH=$(LOCAL)/lib/ \ - PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig \ - PKG_CONFIG_ALLOW_CROSS=1 \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR="$(LOCAL)/lib" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR="$(LOCAL)/include" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR="$(LOCAL)/bin" \ - CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --target armv7-linux-androideabi -p sequoia-openpgp-ffi --release - - -$(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/armv7-linux-androideabi/release/libsequoia_openpgp_ffi.so - cp $(CARGO_TARGET_DIR)/armv7-linux-androideabi/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ - cp -r sequoia/openpgp-ffi/include/* $(LOCAL)/include - - -sequoia-ffi-build: $(CARGO_TARGET_DIR)/armv7-linux-androideabi/release/libsequoia_openpgp_ffi.so - -sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so - -#------------------------------------------------------------------------------# -# assets for Android app - -#ASSETS := $(EXTERNAL_ROOT)/assets -# -#assets: clean-assets -# # add the new stuff -# install -d $(ASSETS) -# cp -a $(LOCAL)/* $(ASSETS) -# # remove all the stuff we don't need -# rm -f $(ASSETS)/bin/*-static -# rm -f $(ASSETS)/bin/curl* -# rm -f $(ASSETS)/lib/*.a $(ASSETS)/lib/*.la -# # remove lib symlinks since Android AssetManager copies them as files -# rm -f $(ASSETS)/lib/*.so -# # remove .so.0 symlink and rename the .so.0.12.0 file to it -# for f in $(ASSETS)/lib/*.so.[0-9]*; do \ -# echo $$f; \ -# test ! -L $$f || \ -# (rm $$f && mv $$f.[0-9]* $$f); \ -# done -# rm -rf $(ASSETS)/include -# rm -rf $(ASSETS)/share/man $(ASSETS)/share/info $(ASSETS)/share/doc -# rm -rf $(ASSETS)/tests -# - -#------------------------------------------------------------------------------# -# Clone update and archive external projects GIT repos -# Local clone is in external/$project.git while -# selected commit is archived in external/$project - -#------------------------------------------------------------------------------# -# clean - -clean-assets: - rm -rf $(ASSETS) - -clean-install: - rm -rf $(LOCAL) - -clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-clean - -clean-all: clean - rm -rf *.git - rm -rf *.stamp -#------------------------------------------------------------------------------# - -.PHONY = clean clean-install clean-assets libetpan-clean \ - libiconv-build libiconv-install \ - libetpan-build \ - uuid-build uuid-prebuild uuid-install \ - gmp-build gmp-install \ - sequoia-deps-build \ - openssl-build openssl-install \ - nettle-build nettle-install \ - sequoia-ffi-build sequoia-ffi-install\ - assets \ - $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN)\ - showsetup diff --git a/android/external/x86/Makefile b/android/external/x86/Makefile deleted file mode 100644 index 3b96355..0000000 --- a/android/external/x86/Makefile +++ /dev/null @@ -1,387 +0,0 @@ -# Copyright 2019, pEp Foundation -# This file is part of pEpJNIAdapter for Android - x86 build -# This file may be used under the terms of the GNU General Public License version 3 -# see LICENSE.txt - -include ../Makefile.conf - -#------------------------------------------------------------------------------# -# Makefile to build deps for use with pEpEngine -# based on gnupg-for-android/external/Makefile -#------------------------------------------------------------------------------# - -#------------------------------------------------------------------------------# -# Build parameters - -APP_ABI ?= x86 - -all: build - -build: showsetup uuid-install sequoia-ffi-install libetpan-build - -#------------------------------------------------------------------------------# -# Manage paths for PREFIX, DESTDIR, LOCAL and PATH - -EXTERNAL_ROOT := $(shell pwd) - -# install root for built files -DESTDIR = $(EXTERNAL_ROOT)/.. -prefix = /output/$(APP_ABI) -LOCAL := $(DESTDIR)$(prefix) - -PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin - -NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot - -HOST = i686-linux-android -NDK_TOOLCHAIN = $(APP_ABI)-$(NDK_TOOLCHAIN_COMPILER) - -# include Android's build flags -TARGET_ARCH_ABI = $(APP_ABI) -include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk - -ANDROID_NDK_HOME=$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(TOOLCHAIN_ARCH) - -CC := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang -CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang++ -AS := $(CC) - -CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 -LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie - -# change 'release' to 'debug' for unoptimized debug builds -CFLAGS += $(TARGET_x86_debug_CFLAGS) - -#------------------------------------------------------------------------------# -# GNU Tools trickery - -# point pkg-config to the .pc files generated from these builds -export PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig - -# workaround for cross-compiling bug in autoconf -export ac_cv_func_malloc_0_nonnull=yes - -#------------------------------------------------------------------------------# -# debugging stuff - -showsetup: - @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" - @echo "NDK_SYSROOT: $(NDK_SYSROOT)" - @echo "APP_ABI: $(APP_ABI)" - @echo "HOST: $(HOST)" - @echo "CC: $(CC)" - @echo "LD: $(LD)" - @echo "CFLAGS: $(CFLAGS)" - @echo "LDFLAGS: $(LDFLAGS)" - -#------------------------------------------------------------------------------# -# libiconv - -libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz - tar xvf $< - mv libiconv-1.15 libiconv - touch $@ - -libiconv-src: libiconv.src.stamp - -libiconv-clean: - rm -rf libiconv - rm -rf libiconv.src.stamp - -libiconv/Makefile: libiconv.src.stamp - cd libiconv && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --host=$(HOST) \ - --enable-static \ - --disable-shared \ - --prefix=$(LOCAL) - -libiconv/lib/.libs/libiconv.a: libiconv/Makefile - $(MAKE) -C libiconv - -$(LOCAL)/lib/libiconv.a: libiconv/lib/.libs/libiconv.a - $(MAKE) -C libiconv DESTDIR=$(DESTDIR) prefix=$(prefix) install - ls -l $(LOCAL)/lib/libiconv.a - -libiconv-build: libiconv/lib/.libs/libiconv.a - -libiconv-install: $(LOCAL)/lib/libiconv.a - -#------------------------------------------------------------------------------# -# libetpan -libetpan.src.stamp: ../downloads/libetpan.tar.gz - mkdir -p libetpan - cd libetpan && tar xvf ../$< - touch $@ - -libetpan/Makefile: libetpan.src.stamp | libiconv-install - cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh $(APP_ABI) - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/$(APP_ABI)/lib/* $(LOCAL)/lib/ - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/include/* $(LOCAL)/include/ - touch $@ - -libetpan-build: libetpan/Makefile - -libetpan-clean: - rm -rf libetpan - rm -rf libetpan.src.stamp - -#------------------------------------------------------------------------------# -# uuid - -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz - tar xvf $< - mv uuid-1.6.2 uuid - touch $@ - -uuid-src: uuid.src.stamp - -uuid-clean: - rm -rf uuid - rm -rf uuid.src.stamp - -uuid/Makefile: uuid.src.stamp - $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac - cd uuid && autoconf - cp ../config.sub uuid - cp ../config.guess uuid - cd uuid && \ - CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --enable-static \ - --host=$(HOST) \ - --with-gnu-ld \ - --prefix=$(LOCAL) - -uuid/.libs/libuuid.so: uuid/Makefile - $(MAKE) -C uuid - -$(LOCAL)/lib/libuuid.so: uuid/.libs/libuuid.so - # install fails copying uuid cmdline tool, but libs are copied ... - -$(MAKE) -C uuid DESTDIR=$(DESTDIR) prefix=$(prefix) install - echo "****** THIS ERROR WAS WILLINGLY IGNORED ******" - ls -l $(LOCAL)/lib/libuuid.so - -uuid-build: uuid/.libs/libuuid.so - -uuid-prebuild: uuid/jni/Android.mk uuid/Makefile - -uuid-install: $(LOCAL)/lib/libuuid.so | uuid-prebuild - -uuid/jni/Android.mk: uuid.src.stamp - mkdir -p uuid/jni - cp ../libuuid.Android.mk uuid/jni/Android.mk - - -#------------------------------------------------------------------------------# -# Sequoia - -sequoia-deps-build: openssl-install nettle-install - -#------------------------------------------------------------------------------# -# OpenSSL - -openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz - tar xvf $< - mv openssl-$(OPENSSL_VERSION) openssl - touch $@ - -openssl-src: openssl.src.stamp - -openssl-clean: - rm -rf openssl - rm -rf openssl.src.stamp - -OPENSSL_ARCHITECTURE:=android-x86 - -openssl/Makefile: openssl.src.stamp - cd openssl && \ - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) -openssl/libssl.so: | openssl/Makefile - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl - -$(LOCAL)/lib/libssl.so: openssl/libssl.so - cd openssl && \ - cp libcrypto.so $(LOCAL)/lib && \ - cp libcrypto.a $(LOCAL)/lib && \ - cp libssl.so $(LOCAL)/lib && \ - cp libssl.a $(LOCAL)/lib - ls -l $(LOCAL)/lib/libssl.so - -openssl-build: openssl/libssl.so - -openssl-install: $(LOCAL)/lib/libssl.so - - -#------------------------------------------------------------------------------# -# GMP - -gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2 - tar xvf $< - mv gmp-$(GMP_VERSION) gmp - touch $@ - -gmp-src: gmp.src.stamp - -gmp-clean: - rm -rf gmp - rm -rf gmp.src.stamp - -gmp/Makefile: gmp.src.stamp - cd gmp && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --host=$(HOST) \ - --prefix=$(LOCAL) \ - --disable-static - - -gmp/.libs/libgmp.so: gmp/Makefile - $(MAKE) -C gmp - -$(LOCAL)/lib/libgmp.so: gmp/.libs/libgmp.so - $(MAKE) -C gmp DESTDIR=$(DESTDIR) prefix=$(prefix) install - #gmp/libtool --finish $(LOCAL)/lib/ - ls -l $(LOCAL)/lib/libgmp.so - touch $@ - -gmp-build: gmp/.libs/libgmp.so - -gmp-install: $(LOCAL)/lib/libgmp.so - - -#------------------------------------------------------------------------------# -# NETTLE - -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so - tar xvf $< - mv nettle-$(NETTLE_VERSION) nettle - touch $@ - -nettle-src: nettle.src.stamp gmp-install - -nettle-clean: - rm -rf nettle - rm -rf nettle.src.stamp - -nettle/Makefile: nettle.src.stamp - cd nettle && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --disable-static \ - --disable-documentation \ - --host=$(HOST) \ - --prefix=$(LOCAL) - -nettle/libnettle.so nettle/libhogweed.so: nettle/Makefile - $(MAKE) -C nettle - -$(LOCAL)/lib/libnettle.so $(LOCAL)/lib/libhogweed.so: nettle/libnettle.so nettle/libhogweed.so - $(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install - cp nettle/libnettle.so $(LOCAL)/lib/libnettle.so - cp nettle/libhogweed.so $(LOCAL)/lib/libhogweed.so - -nettle-build: nettle/libnettle.so nettle/libhogweed.so - -nettle-install: $(LOCAL)/lib/libnettle.so $(LOCAL)/lib/libhogweed.so - - -#------------------------------------------------------------------------------# -# Sequoia-ffi - -CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build/ - -sequoia.src.stamp: ../downloads/sequoia.tar.gz - mkdir -p sequoia - cd sequoia && tar xvf ../$< - $(SED) -i 's,1.48.0,1.49.0,' sequoia/rust-toolchain - cd sequoia && cargo update -p nettle-sys --precise 2.0.8 - mkdir -p $(LOCAL)/lib/ -# This is a bad fix, we should move this to a common makefile (but not the .conf one) - find -L $(ANDROID_NDK) -name libunwind.a -execdir sh -c 'echo "INPUT(-lunwind)" > $(LOCAL)/lib/libgcc.a' \; - touch $@ - -sequoia-ffi-clean: - rm -rf sequoia - rm -rf sequoia.src.stamp - -$(CARGO_TARGET_DIR)/i686-linux-android/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build - cd sequoia && PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - LD_LIBRARY_PATH=$(LOCAL)/lib/ \ - PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig \ - PKG_CONFIG_ALLOW_CROSS=1 \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR="$(LOCAL)/lib" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR="$(LOCAL)/include" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR="$(LOCAL)/bin" \ - CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --target i686-linux-android -p sequoia-openpgp-ffi --release - - -$(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/i686-linux-android/release/libsequoia_openpgp_ffi.so - cp $(CARGO_TARGET_DIR)/i686-linux-android/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ - cp -r sequoia/openpgp-ffi/include/* $(LOCAL)/include - - -sequoia-ffi-build: $(CARGO_TARGET_DIR)/i686-linux-android/release/libsequoia_openpgp_ffi.so - -sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so - -#------------------------------------------------------------------------------# -# assets for Android app - -#ASSETS := $(EXTERNAL_ROOT)/assets -# -#assets: clean-assets -# # add the new stuff -# install -d $(ASSETS) -# cp -a $(LOCAL)/* $(ASSETS) -# # remove all the stuff we don't need -# rm -f $(ASSETS)/bin/*-static -# rm -f $(ASSETS)/bin/curl* -# rm -f $(ASSETS)/lib/*.a $(ASSETS)/lib/*.la -# # remove lib symlinks since Android AssetManager copies them as files -# rm -f $(ASSETS)/lib/*.so -# # remove .so.0 symlink and rename the .so.0.12.0 file to it -# for f in $(ASSETS)/lib/*.so.[0-9]*; do \ -# echo $$f; \ -# test ! -L $$f || \ -# (rm $$f && mv $$f.[0-9]* $$f); \ -# done -# rm -rf $(ASSETS)/include -# rm -rf $(ASSETS)/share/man $(ASSETS)/share/info $(ASSETS)/share/doc -# rm -rf $(ASSETS)/tests -# - -#------------------------------------------------------------------------------# -# clean - -clean-assets: - rm -rf $(ASSETS) - -clean-install: - rm -rf $(LOCAL) - -clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-clean - -clean-all: clean - rm -rf *.git - rm -rf *.stamp -#------------------------------------------------------------------------------# - -.PHONY = clean clean-install clean-assets libetpan-clean \ - libiconv-build libiconv-install \ - libetpan-build \ - uuid-build uuid-prebuild uuid-install \ - gmp-build gmp-install \ - sequoia-deps-build \ - openssl-build openssl-install \ - nettle-build nettle-install \ - sequoia-ffi-build sequoia-ffi-install\ - assets \ - $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN)\ - showsetup diff --git a/android/external/x86_64/Makefile b/android/external/x86_64/Makefile deleted file mode 100644 index 1399e84..0000000 --- a/android/external/x86_64/Makefile +++ /dev/null @@ -1,387 +0,0 @@ -# Copyright 2019, pEp Foundation -# This file is part of pEpJNIAdapter for Android - x86_64 build -# This file may be used under the terms of the GNU General Public License version 3 -# see LICENSE.txt - -include ../Makefile.conf - -#------------------------------------------------------------------------------# -# Makefile to build deps for use with pEpEngine -# based on gnupg-for-android/external/Makefile -#------------------------------------------------------------------------------# - -#------------------------------------------------------------------------------# -# Build parameters - -APP_ABI ?= x86_64 - -all: build - -build:showsetup uuid-install sequoia-ffi-install libetpan-build - -#------------------------------------------------------------------------------# -# Manage paths for PREFIX, DESTDIR, LOCAL and PATH - -EXTERNAL_ROOT := $(shell pwd) - -# install root for built files -DESTDIR = $(EXTERNAL_ROOT)/.. -prefix = /output/$(APP_ABI) -LOCAL := $(DESTDIR)$(prefix) - -PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin - -NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot - -HOST = x86_64-linux-android -NDK_TOOLCHAIN = $(APP_ABI)-$(NDK_TOOLCHAIN_COMPILER) - -# include Android's build flags -TARGET_ARCH_ABI = $(APP_ABI) -include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk - -ANDROID_NDK_HOME=$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(TOOLCHAIN_ARCH) - -CC := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang -CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang++ -AS := $(CC) - -CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 -LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie - -# change 'release' to 'debug' for unoptimized debug builds -CFLAGS += $(TARGET_x86_64_debug_CFLAGS) - -#------------------------------------------------------------------------------# -# GNU Tools trickery - -# point pkg-config to the .pc files generated from these builds -export PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig - -# workaround for cross-compiling bug in autoconf -export ac_cv_func_malloc_0_nonnull=yes - -#------------------------------------------------------------------------------# -# debugging stuff - -showsetup: - @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" - @echo "NDK_SYSROOT: $(NDK_SYSROOT)" - @echo "APP_ABI: $(APP_ABI)" - @echo "HOST: $(HOST)" - @echo "CC: $(CC)" - @echo "LD: $(LD)" - @echo "CFLAGS: $(CFLAGS)" - @echo "LDFLAGS: $(LDFLAGS)" - -#------------------------------------------------------------------------------# -# libiconv - -libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz - tar xvf $< - mv libiconv-1.15 libiconv - touch $@ - -libiconv-src: libiconv.src.stamp - -libiconv-clean: - rm -rf libiconv - rm -rf libiconv.src.stamp - -libiconv/Makefile: libiconv.src.stamp - cd libiconv && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --host=$(HOST) \ - --enable-static \ - --disable-shared \ - --prefix=$(LOCAL) - -libiconv/lib/.libs/libiconv.a: libiconv/Makefile - $(MAKE) -C libiconv - -$(LOCAL)/lib/libiconv.a: libiconv/lib/.libs/libiconv.a - $(MAKE) -C libiconv DESTDIR=$(DESTDIR) prefix=$(prefix) install - ls -l $(LOCAL)/lib/libiconv.a - -libiconv-build: libiconv/lib/.libs/libiconv.a - -libiconv-install: $(LOCAL)/lib/libiconv.a - -#------------------------------------------------------------------------------# -# libetpan -libetpan.src.stamp: ../downloads/libetpan.tar.gz - mkdir -p libetpan - cd libetpan && tar xvf ../$< - touch $@ - -libetpan/Makefile: libetpan.src.stamp | libiconv-install - cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh $(APP_ABI) - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/$(APP_ABI)/lib/* $(LOCAL)/lib/ - cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/include/* $(LOCAL)/include/ - touch $@ - -libetpan-build: libetpan/Makefile - -libetpan-clean: - rm -rf libetpan - rm -rf libetpan.src.stamp - -#------------------------------------------------------------------------------# -# uuid - -uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz - tar xvf $< - mv uuid-1.6.2 uuid - touch $@ - -uuid-src: uuid.src.stamp - -uuid-clean: - rm -rf uuid - rm -rf uuid.src.stamp - -uuid/Makefile: uuid.src.stamp - $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac - cd uuid && autoconf - cp ../config.sub uuid - cp ../config.guess uuid - cd uuid && \ - CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --enable-static \ - --host=$(HOST) \ - --with-gnu-ld \ - --prefix=$(LOCAL) - -uuid/.libs/libuuid.so: uuid/Makefile - $(MAKE) -C uuid - -$(LOCAL)/lib/libuuid.so: uuid/.libs/libuuid.so - # install fails copying uuid cmdline tool, but libs are copied ... - -$(MAKE) -C uuid DESTDIR=$(DESTDIR) prefix=$(prefix) install - echo "****** THIS ERROR WAS WILLINGLY IGNORED ******" - ls -l $(LOCAL)/lib/libuuid.so - -uuid-build: uuid/.libs/libuuid.so - -uuid-prebuild: uuid/jni/Android.mk uuid/Makefile - -uuid-install: $(LOCAL)/lib/libuuid.so | uuid-prebuild - -uuid/jni/Android.mk: uuid.src.stamp - mkdir -p uuid/jni - cp ../libuuid.Android.mk uuid/jni/Android.mk - - -#------------------------------------------------------------------------------# -# Sequoia - -sequoia-deps-build: openssl-install nettle-install - -#------------------------------------------------------------------------------# -# OpenSSL - -openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz - tar xvf $< - mv openssl-$(OPENSSL_VERSION) openssl - touch $@ - -openssl-src: openssl.src.stamp - -openssl-clean: - rm -rf openssl - rm -rf openssl.src.stamp - -OPENSSL_ARCHITECTURE:=android-x86_64 - -openssl/Makefile: openssl.src.stamp - cd openssl && \ - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) -openssl/libssl.so: | openssl/Makefile - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl - -$(LOCAL)/lib/libssl.so: openssl/libssl.so - cd openssl && \ - cp libcrypto.so $(LOCAL)/lib && \ - cp libcrypto.a $(LOCAL)/lib && \ - cp libssl.so $(LOCAL)/lib && \ - cp libssl.a $(LOCAL)/lib - ls -l $(LOCAL)/lib/libssl.so - -openssl-build: openssl/libssl.so - -openssl-install: $(LOCAL)/lib/libssl.so - - -#------------------------------------------------------------------------------# -# GMP - -gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2 - tar xvf $< - mv gmp-$(GMP_VERSION) gmp - touch $@ - -gmp-src: gmp.src.stamp - -gmp-clean: - rm -rf gmp - rm -rf gmp.src.stamp - -gmp/Makefile: gmp.src.stamp - cd gmp && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --host=$(HOST) \ - --prefix=$(LOCAL) \ - --disable-static - - -gmp/.libs/libgmp.so: gmp/Makefile - $(MAKE) -C gmp - -$(LOCAL)/lib/libgmp.so: gmp/.libs/libgmp.so - $(MAKE) -C gmp DESTDIR=$(DESTDIR) prefix=$(prefix) install - #gmp/libtool --finish $(LOCAL)/lib/ - ls -l $(LOCAL)/lib/libgmp.so - touch $@ - -gmp-build: gmp/.libs/libgmp.so - -gmp-install: $(LOCAL)/lib/libgmp.so - - -#------------------------------------------------------------------------------# -# NETTLE - -nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/lib/libgmp.so - tar xvf $< - mv nettle-$(NETTLE_VERSION) nettle - touch $@ - -nettle-src: nettle.src.stamp gmp-install - -nettle-clean: - rm -rf nettle - rm -rf nettle.src.stamp - -nettle/Makefile: nettle.src.stamp - cd nettle && \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - ./configure \ - --with-lib-path=$(LOCAL)/lib \ - --with-include-path=$(LOCAL)/include \ - --disable-static \ - --disable-documentation \ - --host=$(HOST) \ - --prefix=$(LOCAL) - -nettle/libnettle.so: nettle/Makefile - $(MAKE) -C nettle - -$(LOCAL)/lib/libnettle.so: nettle/libnettle.so - $(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install - cp nettle/libnettle.so $(LOCAL)/lib/libnettle.so - cp nettle/libhogweed.so $(LOCAL)/lib/libhogweed.so - -nettle-build: nettle/libnettle.so - -nettle-install: $(LOCAL)/lib/libnettle.so - - -#------------------------------------------------------------------------------# -# Sequoia-ffi - -CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build/ - -sequoia.src.stamp: ../downloads/sequoia.tar.gz - mkdir -p sequoia - cd sequoia && tar xvf ../$< - $(SED) -i 's,1.48.0,1.49.0,' sequoia/rust-toolchain - cd sequoia && cargo update -p nettle-sys --precise 2.0.8 - mkdir -p $(LOCAL)/lib/ -# This is a bad fix, we should move this to a common makefile (but not the .conf one) - find -L $(ANDROID_NDK) -name libunwind.a -execdir sh -c 'echo "INPUT(-lunwind)" > $(LOCAL)/lib/libgcc.a' \; - touch $@ - -sequoia-ffi-clean: - rm -rf sequoia - rm -rf sequoia.src.stamp - -$(CARGO_TARGET_DIR)/x86_64-linux-android/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build - cd sequoia && PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" \ - CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ - LD_LIBRARY_PATH=$(LOCAL)/lib/ \ - PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig \ - PKG_CONFIG_ALLOW_CROSS=1 \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR="$(LOCAL)/lib" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR="$(LOCAL)/include" \ - ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR="$(LOCAL)/bin" \ - CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --target x86_64-linux-android -p sequoia-openpgp-ffi --release - - -$(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/x86_64-linux-android/release/libsequoia_openpgp_ffi.so - cp $(CARGO_TARGET_DIR)/x86_64-linux-android/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ - cp -r sequoia/openpgp-ffi/include/* $(LOCAL)/include - - -sequoia-ffi-build: $(CARGO_TARGET_DIR)/x86_64-linux-android/release/libsequoia_openpgp_ffi.so - -sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so - -#------------------------------------------------------------------------------# -# assets for Android app - -#ASSETS := $(EXTERNAL_ROOT)/assets -# -#assets: clean-assets -# # add the new stuff -# install -d $(ASSETS) -# cp -a $(LOCAL)/* $(ASSETS) -# # remove all the stuff we don't need -# rm -f $(ASSETS)/bin/*-static -# rm -f $(ASSETS)/bin/curl* -# rm -f $(ASSETS)/lib/*.a $(ASSETS)/lib/*.la -# # remove lib symlinks since Android AssetManager copies them as files -# rm -f $(ASSETS)/lib/*.so -# # remove .so.0 symlink and rename the .so.0.12.0 file to it -# for f in $(ASSETS)/lib/*.so.[0-9]*; do \ -# echo $$f; \ -# test ! -L $$f || \ -# (rm $$f && mv $$f.[0-9]* $$f); \ -# done -# rm -rf $(ASSETS)/include -# rm -rf $(ASSETS)/share/man $(ASSETS)/share/info $(ASSETS)/share/doc -# rm -rf $(ASSETS)/tests -# - -#------------------------------------------------------------------------------# -# clean - -clean-assets: - rm -rf $(ASSETS) - -clean-install: - rm -rf $(LOCAL) - -clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-clean - -clean-all: clean - rm -rf *.git - rm -rf *.stamp -#------------------------------------------------------------------------------# - -.PHONY = clean clean-install clean-assets libetpan-clean \ - libiconv-build libiconv-install \ - libetpan-build \ - uuid-build uuid-prebuild uuid-install \ - gmp-build gmp-install \ - sequoia-deps-build \ - openssl-build openssl-install \ - nettle-build nettle-install \ - sequoia-ffi-build sequoia-ffi-install\ - assets \ - $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN)\ - showsetup From 334c0d5cec744b5c49cdb75868e2cd564efc5b61 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 18:26:33 +0200 Subject: [PATCH 09/29] PEMA-107 Use toolchains installed by default with the NDK Change binutils tools prefix for arm architecture. Slightly improve script formatting. --- android/external/MakefileTemplate | 11 ++++--- android/external/createMakefile.sh | 29 ++++++++++--------- .../generate-standalone-ndk-toolchain.sh | 21 -------------- 3 files changed, 21 insertions(+), 40 deletions(-) delete mode 100755 android/external/generate-standalone-ndk-toolchain.sh diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 535bca0..3c93871 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -32,18 +32,17 @@ LOCAL := $(DESTDIR)$(prefix) PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin -NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot - HOST = [HOST] NDK_TOOLCHAIN = $([NDK_TOOLCHAIN_TARGET])-$(NDK_TOOLCHAIN_COMPILER) +COMPILER_PREFIX = [COMPILER_PREFIX] # include Android's build flags TARGET_ARCH_ABI = $(APP_ABI) include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk -CC := $(ANDROID_NDK_HOME)/bin/$(HOST)[EXTRA_FLAGS_API]-clang -CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)[EXTRA_FLAGS_API]-clang++ -AS := $(ANDROID_NDK_HOME)/bin/$(HOST)[EXTRA_FLAGS_API]-clang +CC := $(ANDROID_NDK_HOME)/bin/$(COMPILER_PREFIX)$(ANDROID_API)-clang +CXX := $(ANDROID_NDK_HOME)/bin/$(COMPILER_PREFIX)$(ANDROID_API)-clang++ +AS := $(CC) CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie @@ -65,9 +64,9 @@ export ac_cv_func_malloc_0_nonnull=yes showsetup: @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" - @echo "NDK_SYSROOT: $(NDK_SYSROOT)" @echo "APP_ABI: $(APP_ABI)" @echo "HOST: $(HOST)" + @echo "COMPILER_PREFIX: $(COMPILER_PREFIX)" @echo "CC: $(CC)" @echo "LD: $(LD)" @echo "CFLAGS: $(CFLAGS)" diff --git a/android/external/createMakefile.sh b/android/external/createMakefile.sh index c38dabc..a85850a 100644 --- a/android/external/createMakefile.sh +++ b/android/external/createMakefile.sh @@ -3,8 +3,8 @@ #cd ~code/android/pEpJNIAdapter/external ARCH_DEST="$1" -mkdir $ARCH_DEST -cp MakefileTemplate $ARCH_DEST/Makefile +mkdir "$ARCH_DEST" +cp MakefileTemplate "$ARCH_DEST"/Makefile FILE_DEST=$ARCH_DEST/Makefile ################################################################################ @@ -15,6 +15,7 @@ case $ARCH_DEST in x86) ANDROID_API=18 HOST=i686-linux-android + COMPILER_PREFIX="$HOST" NDK_TOOLCHAIN_TARGET="APP_ABI" ARCH_DEBUG_CFLAGS=TARGET_x86_debug_CFLAGS OPENSSL_ARCHITECTURE=android-x86 @@ -23,7 +24,7 @@ case $ARCH_DEST in x86_64) ANDROID_API=21 HOST=x86_64-linux-android - EXTRA_FLAGS_API="\$(ANDROID_API)" + COMPILER_PREFIX="$HOST" NDK_TOOLCHAIN_TARGET="APP_ABI" ARCH_DEBUG_CFLAGS=TARGET_x86_64_debug_CFLAGS OPENSSL_ARCHITECTURE=android-x86_64 @@ -32,6 +33,7 @@ case $ARCH_DEST in armeabi-v7a) ANDROID_API=18 HOST=arm-linux-androideabi + COMPILER_PREFIX=armv7a-linux-androideabi NDK_TOOLCHAIN_TARGET="HOST" ARCH_DEBUG_CFLAGS=TARGET_arm_debug_CFLAGS OPENSSL_ARCHITECTURE=android-arm @@ -40,6 +42,7 @@ case $ARCH_DEST in arm64-v8a) ANDROID_API=21 HOST=aarch64-linux-android + COMPILER_PREFIX="$HOST" NDK_TOOLCHAIN_TARGET="HOST" ARCH_DEBUG_CFLAGS=TARGET_arm64_debug_CFLAGS OPENSSL_ARCHITECTURE=android-arm64 @@ -66,14 +69,14 @@ esac # REPLACE FIELDS IN TEMPLATE # ################################################################################ -$SED -i 's/\[ARCH\]/'"$ARCH_DEST"'/g' $FILE_DEST -$SED -i 's/\[ANDROID_API\]/'"$ANDROID_API"'/g' $FILE_DEST -$SED -i 's/\[HOST\]/'"$HOST"'/g' $FILE_DEST -$SED -i 's/\[EXTRA_FLAGS_API\]/'"$EXTRA_FLAGS_API"'/g' $FILE_DEST -$SED -i 's/\[NDK_TOOLCHAIN_TARGET\]/'"$NDK_TOOLCHAIN_TARGET"'/g' $FILE_DEST -$SED -i 's/\[ARCH_DEBUG_CFLAGS\]/'"$ARCH_DEBUG_CFLAGS"'/g' $FILE_DEST -$SED -i 's/\[OPENSSL_ARCHITECTURE\]/'"$OPENSSL_ARCHITECTURE"'/g' $FILE_DEST -$SED -i 's/\[GMP_MAKEFILE_EXTRA\]/'"$GMP_MAKEFILE_EXTRA"'/g' $FILE_DEST -$SED -i 's/\[SEQUOIA_ARCH\]/'"$SEQUOIA_ARCH"'/g' $FILE_DEST +$SED -i 's/\[ARCH\]/'"$ARCH_DEST"'/g' "$FILE_DEST" +$SED -i 's/\[ANDROID_API\]/'"$ANDROID_API"'/g' "$FILE_DEST" +$SED -i 's/\[HOST\]/'"$HOST"'/g' "$FILE_DEST" +$SED -i 's/\[COMPILER_PREFIX\]/'"$COMPILER_PREFIX"'/g' "$FILE_DEST" +$SED -i 's/\[NDK_TOOLCHAIN_TARGET\]/'"$NDK_TOOLCHAIN_TARGET"'/g' "$FILE_DEST" +$SED -i 's/\[ARCH_DEBUG_CFLAGS\]/'"$ARCH_DEBUG_CFLAGS"'/g' "$FILE_DEST" +$SED -i 's/\[OPENSSL_ARCHITECTURE\]/'"$OPENSSL_ARCHITECTURE"'/g' "$FILE_DEST" +$SED -i 's/\[GMP_MAKEFILE_EXTRA\]/'"$GMP_MAKEFILE_EXTRA"'/g' "$FILE_DEST" +$SED -i 's/\[SEQUOIA_ARCH\]/'"$SEQUOIA_ARCH"'/g' "$FILE_DEST" -cat $FILE_DEST +cat "$FILE_DEST" diff --git a/android/external/generate-standalone-ndk-toolchain.sh b/android/external/generate-standalone-ndk-toolchain.sh deleted file mode 100755 index 487ff77..0000000 --- a/android/external/generate-standalone-ndk-toolchain.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -usage="Usage: $(basename "$0") [-h][--force] -- Script to generate android standalone toolchain to build pEp for Android. - -where: - -h Show this help text - --force Force generating the toolchain" - - -if [ "$1" == "-h" ]; then -echo "$usage" - exit 0 -fi - -if [ -z "$ANDROID_NDK" ]; then - echo "Please define \$ANDROID_NDK" - exit 1 -fi - -$ANDROID_NDK/build/tools/make_standalone_toolchain.py $1 --arch arm --api 18 --install-dir=ndk-18-arm -exit 0 - From e106a10258b1fe8fdd762ecfe1afa8d16cc5aacf Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 13:32:02 +0200 Subject: [PATCH 10/29] PEMA-107 Make all -clean targets work with a pattern (except sequoia-ffi) --- android/external/MakefileTemplate | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 3c93871..8d06afe 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -82,10 +82,6 @@ libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz libiconv-src: libiconv.src.stamp -libiconv-clean: - rm -rf libiconv - rm -rf libiconv.src.stamp - libiconv/Makefile: libiconv.src.stamp cd libiconv && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ @@ -123,10 +119,6 @@ libetpan/Makefile: libetpan.src.stamp | libiconv-install libetpan-build: libetpan/Makefile -libetpan-clean: - rm -rf libetpan - rm -rf libetpan.src.stamp - #------------------------------------------------------------------------------# # uuid @@ -137,10 +129,6 @@ uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz uuid-src: uuid.src.stamp -uuid-clean: - rm -rf uuid - rm -rf uuid.src.stamp - uuid/Makefile: uuid.src.stamp $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac cd uuid && autoconf @@ -189,10 +177,6 @@ openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz openssl-src: openssl.src.stamp -openssl-clean: - rm -rf openssl - rm -rf openssl.src.stamp - OPENSSL_ARCHITECTURE:=[OPENSSL_ARCHITECTURE] openssl/Makefile: openssl.src.stamp @@ -224,10 +208,6 @@ gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2 gmp-src: gmp.src.stamp -gmp-clean: - rm -rf gmp - rm -rf gmp.src.stamp - gmp/Makefile: gmp.src.stamp cd gmp && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ @@ -261,10 +241,6 @@ nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/ nettle-src: nettle.src.stamp -nettle-clean: - rm -rf nettle - rm -rf nettle.src.stamp - nettle/Makefile: nettle.src.stamp gmp-install cd nettle && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ @@ -356,6 +332,9 @@ sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so #------------------------------------------------------------------------------# # clean +%-clean: + rm -rf $* + rm -rf $*.src.stamp clean-assets: rm -rf $(ASSETS) From ebcadf16f0265df1aeb973445f914619519f53bc Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 18:37:02 +0200 Subject: [PATCH 11/29] PEMA-107 Make all -src targets work with a pattern --- android/external/MakefileTemplate | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 8d06afe..9555530 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -80,8 +80,6 @@ libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz mv libiconv-1.15 libiconv touch $@ -libiconv-src: libiconv.src.stamp - libiconv/Makefile: libiconv.src.stamp cd libiconv && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ @@ -127,8 +125,6 @@ uuid.src.stamp: ../downloads/ossp-uuid_1.6.2.orig-patched.tar.gz mv uuid-1.6.2 uuid touch $@ -uuid-src: uuid.src.stamp - uuid/Makefile: uuid.src.stamp $(SED) -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac cd uuid && autoconf @@ -175,8 +171,6 @@ openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz mv openssl-$(OPENSSL_VERSION) openssl touch $@ -openssl-src: openssl.src.stamp - OPENSSL_ARCHITECTURE:=[OPENSSL_ARCHITECTURE] openssl/Makefile: openssl.src.stamp @@ -206,8 +200,6 @@ gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2 mv gmp-$(GMP_VERSION) gmp touch $@ -gmp-src: gmp.src.stamp - gmp/Makefile: gmp.src.stamp cd gmp && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ @@ -239,8 +231,6 @@ nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/ mv nettle-$(NETTLE_VERSION) nettle touch $@ -nettle-src: nettle.src.stamp - nettle/Makefile: nettle.src.stamp gmp-install cd nettle && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ @@ -361,3 +351,10 @@ clean-all: clean assets \ $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN)\ showsetup + +#------------------------------------------------------------------------------# + +.SECONDEXPANSION: +# src +%-src: %.src.stamp + @echo $< \ No newline at end of file From 3179352d70794bbb5548dc20fc60b36782a0229e Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Wed, 26 Oct 2022 18:40:00 +0200 Subject: [PATCH 12/29] PEMA-107 Replace sed tag for real variable --- android/external/MakefileTemplate | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 9555530..d274919 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -35,6 +35,7 @@ PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin HOST = [HOST] NDK_TOOLCHAIN = $([NDK_TOOLCHAIN_TARGET])-$(NDK_TOOLCHAIN_COMPILER) COMPILER_PREFIX = [COMPILER_PREFIX] +SEQUOIA_ARCH = [SEQUOIA_ARCH] # include Android's build flags TARGET_ARCH_ABI = $(APP_ABI) @@ -274,7 +275,7 @@ sequoia-ffi-clean: rm -rf sequoia rm -rf sequoia.src.stamp -$(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build +$(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build cd sequoia && PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ LD_LIBRARY_PATH=$(LOCAL)/lib/ \ @@ -283,14 +284,14 @@ $(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.so: sequoia.s ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR="$(LOCAL)/lib" \ ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR="$(LOCAL)/include" \ ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR="$(LOCAL)/bin" \ - CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --target [SEQUOIA_ARCH] -p sequoia-openpgp-ffi --release + CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --target $(SEQUOIA_ARCH) -p sequoia-openpgp-ffi --release -$(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.so - cp $(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ +$(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so + cp $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ cp -r sequoia/openpgp-ffi/include/* $(LOCAL)/include -sequoia-ffi-build: $(CARGO_TARGET_DIR)/[SEQUOIA_ARCH]/release/libsequoia_openpgp_ffi.so +sequoia-ffi-build: $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so From ad6bd72f1c436de86be2fe9cf38f9e5bb03afabf Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 09:15:58 +0200 Subject: [PATCH 13/29] PEMA-107 Move some code to Makefile.conf and createMakefile.sh --- android/external/Makefile.conf | 5 +++-- android/external/MakefileTemplate | 33 +++++++++++++----------------- android/external/createMakefile.sh | 23 +++++++++++++++------ 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/android/external/Makefile.conf b/android/external/Makefile.conf index a0fee8d..eb52044 100644 --- a/android/external/Makefile.conf +++ b/android/external/Makefile.conf @@ -51,5 +51,6 @@ EXTERNAL_SRCS_CLEAN += sequoia-ffi-clean ### Other variables ANDROID_ETPAN_BUILD_VERSION=2 - - +# install root for built files +EXTERNAL_ROOT = $(shell pwd) +DESTDIR = $(EXTERNAL_ROOT)/.. diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index d274919..8e7bddd 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -21,35 +21,27 @@ all: build build: showsetup uuid-install sequoia-ffi-install libetpan-build #------------------------------------------------------------------------------# -# Manage paths for PREFIX, DESTDIR, LOCAL and PATH +# Manage paths for PREFIX, LOCAL and PATH -EXTERNAL_ROOT := $(shell pwd) - -# install root for built files -DESTDIR = $(EXTERNAL_ROOT)/.. -prefix = /output/$(APP_ABI) +prefix := [prefix] LOCAL := $(DESTDIR)$(prefix) PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin HOST = [HOST] -NDK_TOOLCHAIN = $([NDK_TOOLCHAIN_TARGET])-$(NDK_TOOLCHAIN_COMPILER) -COMPILER_PREFIX = [COMPILER_PREFIX] +NDK_TOOLCHAIN := [NDK_TOOLCHAIN] SEQUOIA_ARCH = [SEQUOIA_ARCH] +OPENSSL_ARCHITECTURE:=[OPENSSL_ARCHITECTURE] # include Android's build flags -TARGET_ARCH_ABI = $(APP_ABI) include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk -CC := $(ANDROID_NDK_HOME)/bin/$(COMPILER_PREFIX)$(ANDROID_API)-clang -CXX := $(ANDROID_NDK_HOME)/bin/$(COMPILER_PREFIX)$(ANDROID_API)-clang++ +CC := [CC] +CXX := [CXX] AS := $(CC) -CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 -LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie - -# change 'release' to 'debug' for unoptimized debug builds -CFLAGS += $([ARCH_DEBUG_CFLAGS]) +CFLAGS += [CFLAGS] +LDFLAGS += [LDFLAGS] #------------------------------------------------------------------------------# # GNU Tools trickery @@ -65,11 +57,16 @@ export ac_cv_func_malloc_0_nonnull=yes showsetup: @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" + @echo "NDK_TOOLCHAIN_COMPILER: $(NDK_TOOLCHAIN_COMPILER)" @echo "APP_ABI: $(APP_ABI)" @echo "HOST: $(HOST)" - @echo "COMPILER_PREFIX: $(COMPILER_PREFIX)" + @echo "SEQUOIA_ARCH: $(SEQUOIA_ARCH)" @echo "CC: $(CC)" @echo "LD: $(LD)" + @echo "AR: $(AR)" + @echo "AS: $(AS)" + @echo "STRIP: $(STRIP)" + @echo "RANLIB: $(RANLIB)" @echo "CFLAGS: $(CFLAGS)" @echo "LDFLAGS: $(LDFLAGS)" @@ -172,8 +169,6 @@ openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz mv openssl-$(OPENSSL_VERSION) openssl touch $@ -OPENSSL_ARCHITECTURE:=[OPENSSL_ARCHITECTURE] - openssl/Makefile: openssl.src.stamp cd openssl && \ PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) diff --git a/android/external/createMakefile.sh b/android/external/createMakefile.sh index a85850a..f520d35 100644 --- a/android/external/createMakefile.sh +++ b/android/external/createMakefile.sh @@ -16,7 +16,7 @@ case $ARCH_DEST in ANDROID_API=18 HOST=i686-linux-android COMPILER_PREFIX="$HOST" - NDK_TOOLCHAIN_TARGET="APP_ABI" + NDK_TOOLCHAIN_TARGET="$ARCH_DEST" ARCH_DEBUG_CFLAGS=TARGET_x86_debug_CFLAGS OPENSSL_ARCHITECTURE=android-x86 SEQUOIA_ARCH=i686-linux-android @@ -25,7 +25,7 @@ case $ARCH_DEST in ANDROID_API=21 HOST=x86_64-linux-android COMPILER_PREFIX="$HOST" - NDK_TOOLCHAIN_TARGET="APP_ABI" + NDK_TOOLCHAIN_TARGET="$ARCH_DEST" ARCH_DEBUG_CFLAGS=TARGET_x86_64_debug_CFLAGS OPENSSL_ARCHITECTURE=android-x86_64 SEQUOIA_ARCH=x86_64-linux-android @@ -34,7 +34,7 @@ case $ARCH_DEST in ANDROID_API=18 HOST=arm-linux-androideabi COMPILER_PREFIX=armv7a-linux-androideabi - NDK_TOOLCHAIN_TARGET="HOST" + NDK_TOOLCHAIN_TARGET="$HOST" ARCH_DEBUG_CFLAGS=TARGET_arm_debug_CFLAGS OPENSSL_ARCHITECTURE=android-arm SEQUOIA_ARCH=armv7-linux-androideabi @@ -43,7 +43,7 @@ case $ARCH_DEST in ANDROID_API=21 HOST=aarch64-linux-android COMPILER_PREFIX="$HOST" - NDK_TOOLCHAIN_TARGET="HOST" + NDK_TOOLCHAIN_TARGET="$HOST" ARCH_DEBUG_CFLAGS=TARGET_arm64_debug_CFLAGS OPENSSL_ARCHITECTURE=android-arm64 GMP_MAKEFILE_EXTRA=' MPN_PATH=\"arm64 generic\"' @@ -51,6 +51,13 @@ case $ARCH_DEST in ;; esac +prefix="/output/$ARCH_DEST" +CC="\$(ANDROID_NDK_HOME)/bin/$COMPILER_PREFIX$ANDROID_API-clang" +CXX="\$(ANDROID_NDK_HOME)/bin/$COMPILER_PREFIX$ANDROID_API-clang++" +NDK_TOOLCHAIN="$NDK_TOOLCHAIN_TARGET-\$(NDK_TOOLCHAIN_COMPILER)" +CFLAGS="-DANDROID -I\$(LOCAL)/include \$(TARGET_CFLAGS) -fPIE -fPIC -std=c99 \$($ARCH_DEBUG_CFLAGS)" # change 'release' to 'debug' for unoptimized debug builds +LDFLAGS="-llog -L\$(LOCAL)/lib \$(TARGET_LDFLAGS) -pie" + ################################################################################ # Select GNU SED # ################################################################################ @@ -72,11 +79,15 @@ esac $SED -i 's/\[ARCH\]/'"$ARCH_DEST"'/g' "$FILE_DEST" $SED -i 's/\[ANDROID_API\]/'"$ANDROID_API"'/g' "$FILE_DEST" $SED -i 's/\[HOST\]/'"$HOST"'/g' "$FILE_DEST" -$SED -i 's/\[COMPILER_PREFIX\]/'"$COMPILER_PREFIX"'/g' "$FILE_DEST" -$SED -i 's/\[NDK_TOOLCHAIN_TARGET\]/'"$NDK_TOOLCHAIN_TARGET"'/g' "$FILE_DEST" +$SED -i 's@\[prefix\]@'"$prefix"'@g' "$FILE_DEST" +$SED -i 's@\[NDK_TOOLCHAIN\]@'"$NDK_TOOLCHAIN"'@g' "$FILE_DEST" $SED -i 's/\[ARCH_DEBUG_CFLAGS\]/'"$ARCH_DEBUG_CFLAGS"'/g' "$FILE_DEST" $SED -i 's/\[OPENSSL_ARCHITECTURE\]/'"$OPENSSL_ARCHITECTURE"'/g' "$FILE_DEST" $SED -i 's/\[GMP_MAKEFILE_EXTRA\]/'"$GMP_MAKEFILE_EXTRA"'/g' "$FILE_DEST" $SED -i 's/\[SEQUOIA_ARCH\]/'"$SEQUOIA_ARCH"'/g' "$FILE_DEST" +$SED -i 's@\[CC\]@'"$CC"'@g' "$FILE_DEST" +$SED -i 's@\[CXX\]@'"$CXX"'@g' "$FILE_DEST" +$SED -i 's@\[CFLAGS\]@'"$CFLAGS"'@g' "$FILE_DEST" +$SED -i 's@\[LDFLAGS\]@'"$LDFLAGS"'@g' "$FILE_DEST" cat "$FILE_DEST" From 2d47bf150048584ede8ea1aa270d371e2b34f5ba Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 09:22:52 +0200 Subject: [PATCH 14/29] PEMA-107 Use uuid-prebuild instead of uuid-install Done since uuid-install is not used anywhere, instead we just copy uuid.h file to external/output/arch/include. --- android/external/MakefileTemplate | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 8e7bddd..7e2c752 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -18,7 +18,7 @@ ANDROID_API ?= [ANDROID_API] all: build -build: showsetup uuid-install sequoia-ffi-install libetpan-build +build: showsetup uuid-prebuild sequoia-ffi-install libetpan-build #------------------------------------------------------------------------------# # Manage paths for PREFIX, LOCAL and PATH @@ -139,17 +139,12 @@ uuid/Makefile: uuid.src.stamp uuid/.libs/libuuid.so: uuid/Makefile $(MAKE) -C uuid -$(LOCAL)/lib/libuuid.so: uuid/.libs/libuuid.so - # install fails copying uuid cmdline tool, but libs are copied ... - -$(MAKE) -C uuid DESTDIR=$(DESTDIR) prefix=$(prefix) install - echo "****** THIS ERROR WAS WILLINGLY IGNORED ******" - ls -l $(LOCAL)/lib/libuuid.so - uuid-build: uuid/.libs/libuuid.so -uuid-prebuild: uuid/jni/Android.mk uuid/Makefile +$(LOCAL)/include/uuid.h: uuid/Makefile + mkdir -p $(LOCAL)/include && cd uuid && cp uuid.h $(LOCAL)/include -uuid-install: $(LOCAL)/lib/libuuid.so | uuid-prebuild +uuid-prebuild: uuid/jni/Android.mk $(LOCAL)/include/uuid.h uuid/jni/Android.mk: uuid.src.stamp mkdir -p uuid/jni @@ -176,7 +171,7 @@ openssl/libssl.so: | openssl/Makefile PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl $(LOCAL)/lib/libssl.so: openssl/libssl.so - cd openssl && \ + mkdir -p $(LOCAL)/lib && cd openssl && \ cp libcrypto.so $(LOCAL)/lib && \ cp libcrypto.a $(LOCAL)/lib && \ cp libssl.so $(LOCAL)/lib && \ @@ -338,7 +333,7 @@ clean-all: clean .PHONY = clean clean-install clean-assets libetpan-clean \ libiconv-build libiconv-install \ libetpan-build \ - uuid-build uuid-prebuild uuid-install \ + uuid-build uuid-prebuild \ gmp-build gmp-install \ sequoia-deps-build \ openssl-build openssl-install \ From 6460ad117aa4fb6ecc0ab7a42527baa7431f8859 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 09:26:07 +0200 Subject: [PATCH 15/29] PEMA-107 Add some convenient methods in external/Makefile --- android/external/Makefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android/external/Makefile b/android/external/Makefile index 7cd5898..db81789 100644 --- a/android/external/Makefile +++ b/android/external/Makefile @@ -67,3 +67,19 @@ downloads/downloads.stamp: $(MAKE) -C downloads assets: + +showAllSetups: showx86Setup showx86_64Setup showArmSetup showArm64Setup + +showx86Setup: + $(MAKE) -C x86 showsetup + +showx86_64Setup: + $(MAKE) -C x86_64 showsetup + +showArmSetup: + $(MAKE) -C armeabi-v7a showsetup + +showArm64Setup: + $(MAKE) -C arm64-v8a showsetup + +createMakefiles: armeabi-v7a/Makefile arm64-v8a/Makefile x86/Makefile x86_64/Makefile From 8c80c9794de562d0b1a90010b17202d840be6ea2 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 10:14:22 +0200 Subject: [PATCH 16/29] PEMA-107 Move common variables to Makefile.conf Done so that we do not need to repeat much generated code. --- android/external/Makefile.conf | 11 +++++++++ android/external/MakefileTemplate | 39 ++++++++++++------------------ android/external/createMakefile.sh | 15 ++---------- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/android/external/Makefile.conf b/android/external/Makefile.conf index eb52044..f9102f8 100644 --- a/android/external/Makefile.conf +++ b/android/external/Makefile.conf @@ -54,3 +54,14 @@ ANDROID_ETPAN_BUILD_VERSION=2 # install root for built files EXTERNAL_ROOT = $(shell pwd) DESTDIR = $(EXTERNAL_ROOT)/.. +prefix = /output/$(APP_ABI) +LOCAL = $(DESTDIR)$(prefix) +NDK_TOOLCHAIN = $(NDK_TOOLCHAIN_TARGET)-$(NDK_TOOLCHAIN_COMPILER) +TEMP_WORK_PATH = $(ANDROID_NDK_HOME)/bin:${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin + +CC = $(ANDROID_NDK_HOME)/bin/$(COMPILER_PREFIX)$(ANDROID_API)-clang +AS = $(CC) +CXX = $(ANDROID_NDK_HOME)/bin/$(COMPILER_PREFIX)$(ANDROID_API)-clang++ + +MYCFLAGS = -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -std=c99 $($ARCH_DEBUG_CFLAGS) # change 'release' to 'debug' for unoptimized debug builds +MYLDFLAGS = -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie \ No newline at end of file diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 7e2c752..e882ec4 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -3,6 +3,15 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt +# Build parameters +APP_ABI ?= [ARCH] +ANDROID_API ?= [ANDROID_API] +HOST ?= [HOST] +NDK_TOOLCHAIN_TARGET ?= [NDK_TOOLCHAIN_TARGET] +SEQUOIA_ARCH ?= [SEQUOIA_ARCH] +OPENSSL_ARCHITECTURE ?= [OPENSSL_ARCHITECTURE] +COMPILER_PREFIX ?= [COMPILER_PREFIX] + include ../Makefile.conf #------------------------------------------------------------------------------# @@ -11,10 +20,6 @@ include ../Makefile.conf #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# -# Build parameters - -APP_ABI ?= [ARCH] -ANDROID_API ?= [ANDROID_API] all: build @@ -23,25 +28,11 @@ build: showsetup uuid-prebuild sequoia-ffi-install libetpan-build #------------------------------------------------------------------------------# # Manage paths for PREFIX, LOCAL and PATH -prefix := [prefix] -LOCAL := $(DESTDIR)$(prefix) - -PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin - -HOST = [HOST] -NDK_TOOLCHAIN := [NDK_TOOLCHAIN] -SEQUOIA_ARCH = [SEQUOIA_ARCH] -OPENSSL_ARCHITECTURE:=[OPENSSL_ARCHITECTURE] - # include Android's build flags include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk -CC := [CC] -CXX := [CXX] -AS := $(CC) - -CFLAGS += [CFLAGS] -LDFLAGS += [LDFLAGS] +CFLAGS += $(MYCFLAGS) +LDFLAGS += $(MYLDFLAGS) #------------------------------------------------------------------------------# # GNU Tools trickery @@ -58,6 +49,8 @@ export ac_cv_func_malloc_0_nonnull=yes showsetup: @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" @echo "NDK_TOOLCHAIN_COMPILER: $(NDK_TOOLCHAIN_COMPILER)" + @echo "NDK_TOOLCHAIN_TARGET: $(NDK_TOOLCHAIN_TARGET)" + @echo "TEMP_WORK_PATH: $(TEMP_WORK_PATH)" @echo "APP_ABI: $(APP_ABI)" @echo "HOST: $(HOST)" @echo "SEQUOIA_ARCH: $(SEQUOIA_ARCH)" @@ -166,9 +159,9 @@ openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz openssl/Makefile: openssl.src.stamp cd openssl && \ - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) + PATH=$(TEMP_WORK_PATH) ../../configure_openssl.sh ${OPENSSL_ARCHITECTURE} $(ANDROID_API) $(LOCAL) openssl/libssl.so: | openssl/Makefile - PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl + PATH=$(TEMP_WORK_PATH) $(MAKE) -C openssl $(LOCAL)/lib/libssl.so: openssl/libssl.so mkdir -p $(LOCAL)/lib && cd openssl && \ @@ -266,7 +259,7 @@ sequoia-ffi-clean: rm -rf sequoia.src.stamp $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build - cd sequoia && PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" \ + cd sequoia && PATH=$(TEMP_WORK_PATH) \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ LD_LIBRARY_PATH=$(LOCAL)/lib/ \ PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig \ diff --git a/android/external/createMakefile.sh b/android/external/createMakefile.sh index f520d35..ee95864 100644 --- a/android/external/createMakefile.sh +++ b/android/external/createMakefile.sh @@ -51,13 +51,6 @@ case $ARCH_DEST in ;; esac -prefix="/output/$ARCH_DEST" -CC="\$(ANDROID_NDK_HOME)/bin/$COMPILER_PREFIX$ANDROID_API-clang" -CXX="\$(ANDROID_NDK_HOME)/bin/$COMPILER_PREFIX$ANDROID_API-clang++" -NDK_TOOLCHAIN="$NDK_TOOLCHAIN_TARGET-\$(NDK_TOOLCHAIN_COMPILER)" -CFLAGS="-DANDROID -I\$(LOCAL)/include \$(TARGET_CFLAGS) -fPIE -fPIC -std=c99 \$($ARCH_DEBUG_CFLAGS)" # change 'release' to 'debug' for unoptimized debug builds -LDFLAGS="-llog -L\$(LOCAL)/lib \$(TARGET_LDFLAGS) -pie" - ################################################################################ # Select GNU SED # ################################################################################ @@ -79,15 +72,11 @@ esac $SED -i 's/\[ARCH\]/'"$ARCH_DEST"'/g' "$FILE_DEST" $SED -i 's/\[ANDROID_API\]/'"$ANDROID_API"'/g' "$FILE_DEST" $SED -i 's/\[HOST\]/'"$HOST"'/g' "$FILE_DEST" -$SED -i 's@\[prefix\]@'"$prefix"'@g' "$FILE_DEST" -$SED -i 's@\[NDK_TOOLCHAIN\]@'"$NDK_TOOLCHAIN"'@g' "$FILE_DEST" +$SED -i 's@\[COMPILER_PREFIX\]@'"$COMPILER_PREFIX"'@g' "$FILE_DEST" +$SED -i 's@\[NDK_TOOLCHAIN_TARGET\]@'"$NDK_TOOLCHAIN_TARGET"'@g' "$FILE_DEST" $SED -i 's/\[ARCH_DEBUG_CFLAGS\]/'"$ARCH_DEBUG_CFLAGS"'/g' "$FILE_DEST" $SED -i 's/\[OPENSSL_ARCHITECTURE\]/'"$OPENSSL_ARCHITECTURE"'/g' "$FILE_DEST" $SED -i 's/\[GMP_MAKEFILE_EXTRA\]/'"$GMP_MAKEFILE_EXTRA"'/g' "$FILE_DEST" $SED -i 's/\[SEQUOIA_ARCH\]/'"$SEQUOIA_ARCH"'/g' "$FILE_DEST" -$SED -i 's@\[CC\]@'"$CC"'@g' "$FILE_DEST" -$SED -i 's@\[CXX\]@'"$CXX"'@g' "$FILE_DEST" -$SED -i 's@\[CFLAGS\]@'"$CFLAGS"'@g' "$FILE_DEST" -$SED -i 's@\[LDFLAGS\]@'"$LDFLAGS"'@g' "$FILE_DEST" cat "$FILE_DEST" From a9c2bf98fc8fd68151dadfd6a9933e1d2d219ae3 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 10:49:18 +0200 Subject: [PATCH 17/29] PEMA-107 Remove duplicate ANDROID_API variable --- android/external/MakefileTemplate | 1 - android/external/createMakefile.sh | 5 ----- 2 files changed, 6 deletions(-) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index e882ec4..4e6bfc9 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -5,7 +5,6 @@ # Build parameters APP_ABI ?= [ARCH] -ANDROID_API ?= [ANDROID_API] HOST ?= [HOST] NDK_TOOLCHAIN_TARGET ?= [NDK_TOOLCHAIN_TARGET] SEQUOIA_ARCH ?= [SEQUOIA_ARCH] diff --git a/android/external/createMakefile.sh b/android/external/createMakefile.sh index ee95864..4bdc8f9 100644 --- a/android/external/createMakefile.sh +++ b/android/external/createMakefile.sh @@ -13,7 +13,6 @@ FILE_DEST=$ARCH_DEST/Makefile case $ARCH_DEST in x86) - ANDROID_API=18 HOST=i686-linux-android COMPILER_PREFIX="$HOST" NDK_TOOLCHAIN_TARGET="$ARCH_DEST" @@ -22,7 +21,6 @@ case $ARCH_DEST in SEQUOIA_ARCH=i686-linux-android ;; x86_64) - ANDROID_API=21 HOST=x86_64-linux-android COMPILER_PREFIX="$HOST" NDK_TOOLCHAIN_TARGET="$ARCH_DEST" @@ -31,7 +29,6 @@ case $ARCH_DEST in SEQUOIA_ARCH=x86_64-linux-android ;; armeabi-v7a) - ANDROID_API=18 HOST=arm-linux-androideabi COMPILER_PREFIX=armv7a-linux-androideabi NDK_TOOLCHAIN_TARGET="$HOST" @@ -40,7 +37,6 @@ case $ARCH_DEST in SEQUOIA_ARCH=armv7-linux-androideabi ;; arm64-v8a) - ANDROID_API=21 HOST=aarch64-linux-android COMPILER_PREFIX="$HOST" NDK_TOOLCHAIN_TARGET="$HOST" @@ -70,7 +66,6 @@ esac ################################################################################ $SED -i 's/\[ARCH\]/'"$ARCH_DEST"'/g' "$FILE_DEST" -$SED -i 's/\[ANDROID_API\]/'"$ANDROID_API"'/g' "$FILE_DEST" $SED -i 's/\[HOST\]/'"$HOST"'/g' "$FILE_DEST" $SED -i 's@\[COMPILER_PREFIX\]@'"$COMPILER_PREFIX"'@g' "$FILE_DEST" $SED -i 's@\[NDK_TOOLCHAIN_TARGET\]@'"$NDK_TOOLCHAIN_TARGET"'@g' "$FILE_DEST" From f69f322a8b1521384aa133c7328ec298cd4f9075 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 13:54:29 +0200 Subject: [PATCH 18/29] PEMA-107 Add PerArchMakefile.conf This file is meant to hold common variables for *only* architectures' Makefiles. Organize Makefile.conf. --- android/external/MakefileTemplate | 5 ++++- android/external/PerArchMakefile.conf | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 android/external/PerArchMakefile.conf diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 4e6bfc9..a4cfff1 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -3,6 +3,8 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt +include ../Makefile.conf + # Build parameters APP_ABI ?= [ARCH] HOST ?= [HOST] @@ -11,7 +13,8 @@ SEQUOIA_ARCH ?= [SEQUOIA_ARCH] OPENSSL_ARCHITECTURE ?= [OPENSSL_ARCHITECTURE] COMPILER_PREFIX ?= [COMPILER_PREFIX] -include ../Makefile.conf +# This include is dependent on the *build parameters* defined above and needs to be declared after them +include ../PerArchMakefile.conf #------------------------------------------------------------------------------# # Makefile to build deps for use with pEpEngine diff --git a/android/external/PerArchMakefile.conf b/android/external/PerArchMakefile.conf new file mode 100644 index 0000000..e395f7b --- /dev/null +++ b/android/external/PerArchMakefile.conf @@ -0,0 +1,9 @@ +# This file holds variables that *should only be accessed from the Makefiles in each architecture*, which are generated from MakefileTemplate. + +# install root for built files +EXTERNAL_ROOT = $(shell pwd) +DESTDIR = $(EXTERNAL_ROOT)/.. +prefix = /output/$(APP_ABI) +LOCAL = $(DESTDIR)$(prefix) +NDK_TOOLCHAIN = $(NDK_TOOLCHAIN_TARGET)-$(NDK_TOOLCHAIN_COMPILER) +TEMP_WORK_PATH = "$(ANDROID_NDK_HOME)/bin:${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin" From ed66af9de2459eeb3488f87c4122892167c428c8 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 14:10:59 +0200 Subject: [PATCH 19/29] PEMA-107 Improve showsetup clarity --- android/external/MakefileTemplate | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index a4cfff1..0251b67 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -49,10 +49,12 @@ export ac_cv_func_malloc_0_nonnull=yes # debugging stuff showsetup: + @echo "============================================== CURRENT SETUP ====================================================" @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" @echo "NDK_TOOLCHAIN_COMPILER: $(NDK_TOOLCHAIN_COMPILER)" @echo "NDK_TOOLCHAIN_TARGET: $(NDK_TOOLCHAIN_TARGET)" @echo "TEMP_WORK_PATH: $(TEMP_WORK_PATH)" + @echo "LOCAL: $(LOCAL)" @echo "APP_ABI: $(APP_ABI)" @echo "HOST: $(HOST)" @echo "SEQUOIA_ARCH: $(SEQUOIA_ARCH)" @@ -64,6 +66,7 @@ showsetup: @echo "RANLIB: $(RANLIB)" @echo "CFLAGS: $(CFLAGS)" @echo "LDFLAGS: $(LDFLAGS)" + @echo "============================================== CURRENT SETUP END ====================================================" #------------------------------------------------------------------------------# # libiconv From 8ea8972f9ab6a03363b7e740da56e296003bc160 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 11:07:49 +0200 Subject: [PATCH 20/29] PEMA-107 Allow to pass abi(s) to build for as parameter --- android/external/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/external/Makefile b/android/external/Makefile index db81789..6c97e1f 100644 --- a/android/external/Makefile +++ b/android/external/Makefile @@ -21,7 +21,7 @@ endif .PHONY: all build clean clean-all build-arm build-arm64 build-x86 build-x86_64 -build: all +build: $(if $(archs),$(foreach wrd, $(archs), build-$(wrd)), all) all: build-arm build-arm64 build-x86 build-x86_64 From a3f85050172abf091cb29759f46e02d8e943991f Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 11:14:30 +0200 Subject: [PATCH 21/29] PEMA-107 Allow to modify abis to build for in build.gradle --- android/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 5470831..1ba4235 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,6 +8,7 @@ def buildAutomatic = hasProperty('buildAutomatic') ? buildAutomatic : "true" def threadsToUse = 1 def pEpEngineDB = new File(new File(pEpEngineSrc), 'db') +def archsToCompile = "arm arm64 x86 x86_64" buildscript { repositories { @@ -118,7 +119,7 @@ android { // call external build (GnuPG, GPGME, etc) task buildExternal(type:Exec, dependsOn: 'genSources') { workingDir 'external' - commandLine 'make', "-j${threadsToUse}", 'build' + commandLine 'make', "-j${threadsToUse}", 'build', "archs=${archsToCompile}" } task externalAssets(type:Exec) { From 9c966091814e931b6fecd7e4f7c5cedbb77414f7 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Thu, 27 Oct 2022 11:15:49 +0200 Subject: [PATCH 22/29] PEMA-107 Add argument to ndk to prevent "bad file descriptor" Reference: https://jira.appcelerator.org/plugins/servlet/mobile#issue/TIMOB-27776 --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 1ba4235..770959b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -81,7 +81,7 @@ android { jniDebuggable true externalNativeBuild { ndkBuild { - arguments "-j${threadsToUse}", 'NDK_LOG=1', 'NDK_DEBUG=1', 'NDEBUG=null' + arguments "-j${threadsToUse}", 'NDK_LOG=1', 'NDK_DEBUG=1', 'NDEBUG=null', '--output-sync=none' // arguments '-B', 'NDK_DEBUG=1', 'NDEBUG=null', 'NDK_LOG=1' } } From 8b61d784eebfcd7ebf475e096c8a975d8a074c8f Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Fri, 28 Oct 2022 06:42:17 +0200 Subject: [PATCH 23/29] PEMA-107 Do not use phony targets as prerequisites If we do that, the rule will always run. Instead we need to use real files as prerequisites. Reference: https://www.gnu.org/software/make/manual/make.html#Phony-Targets: "A phony target should not be a prerequisite of a real target file; if it is, its recipe will be run every time make goes to update that file." --- android/external/MakefileTemplate | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 0251b67..eb5bb49 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -105,7 +105,7 @@ libetpan.src.stamp: ../downloads/libetpan.tar.gz cd libetpan && tar xvf ../$< touch $@ -libetpan/Makefile: libetpan.src.stamp | libiconv-install +libetpan/Makefile: libetpan.src.stamp | $(LOCAL)/lib/libiconv.a cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh $(APP_ABI) cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/$(APP_ABI)/lib/* $(LOCAL)/lib/ cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/include/* $(LOCAL)/include/ @@ -152,7 +152,7 @@ uuid/jni/Android.mk: uuid.src.stamp #------------------------------------------------------------------------------# # Sequoia -sequoia-deps-build: openssl-install nettle-install +sequoia-deps-build: $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so #------------------------------------------------------------------------------# # OpenSSL @@ -220,7 +220,7 @@ nettle.src.stamp: ../downloads/nettle-$(NETTLE_VERSION)-patched.tar.gz $(LOCAL)/ mv nettle-$(NETTLE_VERSION) nettle touch $@ -nettle/Makefile: nettle.src.stamp gmp-install +nettle/Makefile: nettle.src.stamp $(LOCAL)/lib/libgmp.so cd nettle && \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure \ @@ -263,7 +263,7 @@ sequoia-ffi-clean: rm -rf sequoia rm -rf sequoia.src.stamp -$(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp sequoia-deps-build +$(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so: sequoia.src.stamp $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so cd sequoia && PATH=$(TEMP_WORK_PATH) \ CC="$(CC)" LD="$(LD)" AR="$(AR)" AS="$(AS)" RANLIB=$(RANLIB) STRIP="$(STRIP)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ LD_LIBRARY_PATH=$(LOCAL)/lib/ \ @@ -281,7 +281,7 @@ $(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/rele sequoia-ffi-build: $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so -sequoia-ffi-install: sequoia-deps-build $(LOCAL)/lib/libsequoia_openpgp_ffi.so +sequoia-ffi-install: $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so $(LOCAL)/lib/libsequoia_openpgp_ffi.so #------------------------------------------------------------------------------# # assets for Android app From ceb96af85da13ed8909be78b502d18efefa19ac9 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Fri, 28 Oct 2022 06:55:05 +0200 Subject: [PATCH 24/29] PEMA-107 Add convenience methods to refresh makefiles in-place Declare phony targets --- android/external/Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/android/external/Makefile b/android/external/Makefile index 6c97e1f..d5474e3 100644 --- a/android/external/Makefile +++ b/android/external/Makefile @@ -19,7 +19,9 @@ ifdef BUILD_CONFIG $(info ================================================) endif -.PHONY: all build clean clean-all build-arm build-arm64 build-x86 build-x86_64 +.PHONY: all build clean clean-all build-arm build-arm64 build-x86 build-x86_64 showAllSetups \ + showx86Setup showx86_64Setup showArmSetup showArm64Setup createMakefiles cleanMakefiles \ + refreshMakefiles build: $(if $(archs),$(foreach wrd, $(archs), build-$(wrd)), all) @@ -83,3 +85,11 @@ showArm64Setup: $(MAKE) -C arm64-v8a showsetup createMakefiles: armeabi-v7a/Makefile arm64-v8a/Makefile x86/Makefile x86_64/Makefile + +cleanMakefiles: + rm armeabi-v7a/Makefile + rm arm64-v8a/Makefile + rm x86/Makefile + rm x86_64/Makefile + +refreshMakefiles: cleanMakefiles createMakefiles From d7786acd4ef092d087229224dd46ab05ea6b86fd Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Fri, 28 Oct 2022 07:48:31 +0200 Subject: [PATCH 25/29] PEMA-107 Only run buildExternal for connected devices --- android/build.gradle | 15 +++-- .../plugins/set-pep-jniadapter-archs.gradle | 56 +++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 android/gradle/plugins/set-pep-jniadapter-archs.gradle diff --git a/android/build.gradle b/android/build.gradle index 770959b..0347761 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,7 +8,9 @@ def buildAutomatic = hasProperty('buildAutomatic') ? buildAutomatic : "true" def threadsToUse = 1 def pEpEngineDB = new File(new File(pEpEngineSrc), 'db') -def archsToCompile = "arm arm64 x86 x86_64" +ext.archsToCompile = "arm arm64 x86 x86_64" + +apply from: 'gradle/plugins/set-pep-jniadapter-archs.gradle' buildscript { repositories { @@ -117,9 +119,14 @@ android { } // call external build (GnuPG, GPGME, etc) - task buildExternal(type:Exec, dependsOn: 'genSources') { - workingDir 'external' - commandLine 'make', "-j${threadsToUse}", 'build', "archs=${archsToCompile}" + task buildExternal(dependsOn: ['genSources', 'setpEpJNIAdapterArchs']) { + doLast { + println("compiling for abis: ${project.archsToCompile}") + exec { + workingDir 'external' + commandLine 'make', "-j${threadsToUse}", 'build', "archs=${project.archsToCompile}" + } + } } task externalAssets(type:Exec) { diff --git a/android/gradle/plugins/set-pep-jniadapter-archs.gradle b/android/gradle/plugins/set-pep-jniadapter-archs.gradle new file mode 100644 index 0000000..150fd91 --- /dev/null +++ b/android/gradle/plugins/set-pep-jniadapter-archs.gradle @@ -0,0 +1,56 @@ +task setpEpJNIAdapterArchs { + + description = "Prepare pEpJNIAdapter to build with the first archs of each connected device." + + doLast { + def serialNos = getConnectedDevicesIds() + println("Connected devices: $serialNos") + def abis = serialNos.collect { serialNo -> + convertAbiName(execCommand("adb -s ${serialNo} shell getprop ro.product.cpu.abilist", true).trim().split(",")[0]) + }.toSet() + def sb = new StringBuilder() + for (String s : abis) { + sb.append(s) + sb.append(" ") + } + if (!abis.isEmpty()) { + project.archsToCompile = sb.toString().trim() + println("got archs to compile: ${project.archsToCompile}") + } + } +} + +private List getConnectedDevicesIds(boolean verbose = false) { + def lines = execCommand("adb devices", true, verbose).readLines() + lines.removeIf { it.trim().isEmpty() } + lines.remove(0) + if (lines.isEmpty()) return lines + return lines.collect { line -> + line.substring(0, line.indexOf("device")).trim() + } +} + +static String convertAbiName(name) { + if (name == "armeabi-v7a") return "arm" + else if (name == "arm64-v8a") return "arm64" + else return name +} + +private String execCommand(String command, boolean captureOutput = false, boolean verbose = false) { + def stdout = captureOutput ? new ByteArrayOutputStream() : null + exec { + if (verbose) { + println("running command: $command") + } + commandLine command.split(' ') + if (stdout != null) { + standardOutput = stdout + } + } + String out = null + if (stdout != null) { + out = stdout.toString() + stdout.close() + } + return out +} From bdc33943c24b0b96151c2c20fb9e92ebc2523ca5 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Fri, 28 Oct 2022 09:21:46 +0200 Subject: [PATCH 26/29] PEMA-107 Compile for only connected devices if running from IDE --- android/build.gradle | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 0347761..a2431f6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -119,9 +119,9 @@ android { } // call external build (GnuPG, GPGME, etc) - task buildExternal(dependsOn: ['genSources', 'setpEpJNIAdapterArchs']) { + task buildExternal(dependsOn: ['genSources']) { doLast { - println("compiling for abis: ${project.archsToCompile}") + println("buildExternal for abis: ${project.archsToCompile}") exec { workingDir 'external' commandLine 'make', "-j${threadsToUse}", 'build', "archs=${project.archsToCompile}" @@ -160,10 +160,19 @@ android { if(buildAutomatic == "true") { buildpEpEngineSystemDB.dependsOn(buildExternal) } + if(isIdeBuild()) { + buildExternal.dependsOn(setpEpJNIAdapterArchs) + } // This ensures that assets are populated before collecting resources. preBuild.dependsOn(cpDBAssets) preBuild.dependsOn(externalAssets) } - +def isIdeBuild() { + boolean runningFromIde = project.properties['android.injected.invoked.from.ide'] == 'true' + if (runningFromIde) { + println("GRADLE RUNNING FROM IDE") + } + return runningFromIde +} From 0d101afcbc5dd15e00a94f6f27b66147b430b370 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Fri, 28 Oct 2022 12:05:08 +0200 Subject: [PATCH 27/29] PEMA-107 Remove downloads.stamp dependency from makefile creation --- android/external/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/android/external/Makefile b/android/external/Makefile index d5474e3..ba6a46c 100644 --- a/android/external/Makefile +++ b/android/external/Makefile @@ -27,28 +27,28 @@ build: $(if $(archs),$(foreach wrd, $(archs), build-$(wrd)), all) all: build-arm build-arm64 build-x86 build-x86_64 -build-arm: armeabi-v7a/Makefile +build-arm: armeabi-v7a/Makefile downloads/downloads.stamp $(MAKE) -C armeabi-v7a -armeabi-v7a/Makefile: downloads/downloads.stamp +armeabi-v7a/Makefile: sh createMakefile.sh armeabi-v7a -build-arm64: arm64-v8a/Makefile +build-arm64: arm64-v8a/Makefile downloads/downloads.stamp $(MAKE) -C arm64-v8a -arm64-v8a/Makefile: downloads/downloads.stamp +arm64-v8a/Makefile: sh createMakefile.sh arm64-v8a -build-x86: x86/Makefile +build-x86: x86/Makefile downloads/downloads.stamp $(MAKE) -C x86 -x86/Makefile: downloads/downloads.stamp +x86/Makefile: sh createMakefile.sh x86 -build-x86_64: x86_64/Makefile +build-x86_64: x86_64/Makefile downloads/downloads.stamp $(MAKE) -C x86_64 -x86_64/Makefile: downloads/downloads.stamp +x86_64/Makefile: sh createMakefile.sh x86_64 clean: From 184d45b73d642dde84bc9f02eb7a0fc4d81a2137 Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Mon, 31 Oct 2022 09:33:25 +0100 Subject: [PATCH 28/29] PEMA-107 Add Makefile help and colors Ignore errors in non-essential recipes. --- android/external/Makefile | 53 ++++++++++++++------ android/external/Makefile.conf | 12 ++++- android/external/MakefileTemplate | 77 ++++++++++++++++++----------- android/external/createMakefile.sh | 1 - android/external/downloads/Makefile | 21 +++++--- android/external/help.mk | 27 ++++++++++ 6 files changed, 139 insertions(+), 52 deletions(-) create mode 100644 android/external/help.mk diff --git a/android/external/Makefile b/android/external/Makefile index ba6a46c..aeb84ec 100644 --- a/android/external/Makefile +++ b/android/external/Makefile @@ -21,75 +21,100 @@ endif .PHONY: all build clean clean-all build-arm build-arm64 build-x86 build-x86_64 showAllSetups \ showx86Setup showx86_64Setup showArmSetup showArm64Setup createMakefiles cleanMakefiles \ - refreshMakefiles + refreshMakefiles help +## Build dependencies for the archs passed. Example: make build archs=x86 arm64. If no archs passed, build for all 4 archs. build: $(if $(archs),$(foreach wrd, $(archs), build-$(wrd)), all) +## Build dependencies for all 4 archs all: build-arm build-arm64 build-x86 build-x86_64 +## Call armeabi-v7a Makefile (build dependencies for arm arch) build-arm: armeabi-v7a/Makefile downloads/downloads.stamp $(MAKE) -C armeabi-v7a +## Create Makefile for arm (armeabi-v7a) arch armeabi-v7a/Makefile: sh createMakefile.sh armeabi-v7a +## Call arm64-v8a Makefile (build dependencies for arm64 arch) build-arm64: arm64-v8a/Makefile downloads/downloads.stamp $(MAKE) -C arm64-v8a +## Create Makefile for arm64 (arm64-v8a) arch arm64-v8a/Makefile: sh createMakefile.sh arm64-v8a +## Call x86 Makefile (build dependencies for x86 arch) build-x86: x86/Makefile downloads/downloads.stamp $(MAKE) -C x86 +## Create Makefile for x86 arch x86/Makefile: sh createMakefile.sh x86 +## Call x86_64 Makefile (build dependencies for x86_64 arch) build-x86_64: x86_64/Makefile downloads/downloads.stamp $(MAKE) -C x86_64 +## Create Makefile for x86_64 arch x86_64/Makefile: sh createMakefile.sh x86_64 +## Clean generated artifacts for all archs clean: -$(MAKE) -C armeabi-v7a clean -$(MAKE) -C arm64-v8a clean -$(MAKE) -C x86 clean -$(MAKE) -C x86_64 clean +## Clean generated artifacts for all archs and remove downloaded files clean-all: clean $(MAKE) -C downloads clean - rm -rf build - rm -rf arm64-v8a - rm -rf armeabi-v7a - rm -rf x86 - rm -rf x86_64 + -rm -rf build + -rm -rf arm64-v8a + -rm -rf armeabi-v7a + -rm -rf x86 + -rm -rf x86_64 +## Download dependency files downloads/downloads.stamp: $(MAKE) -C downloads assets: +## Show setup values for all Makefiles (Needs for Makefiles to be already created first) showAllSetups: showx86Setup showx86_64Setup showArmSetup showArm64Setup +## Show setup values for x86 Makefile showx86Setup: - $(MAKE) -C x86 showsetup + -$(MAKE) -C x86 showsetup +## Show setup values for x86_64 Makefile showx86_64Setup: - $(MAKE) -C x86_64 showsetup + -$(MAKE) -C x86_64 showsetup +## Show setup values for arm (armeabi-v7a) Makefile showArmSetup: - $(MAKE) -C armeabi-v7a showsetup + -$(MAKE) -C armeabi-v7a showsetup +## Show setup values for arm64 (arm64-v8a) Makefile showArm64Setup: - $(MAKE) -C arm64-v8a showsetup + -$(MAKE) -C arm64-v8a showsetup +## Create all arch Makefiles createMakefiles: armeabi-v7a/Makefile arm64-v8a/Makefile x86/Makefile x86_64/Makefile +## Delete all arch Makefiles cleanMakefiles: - rm armeabi-v7a/Makefile - rm arm64-v8a/Makefile - rm x86/Makefile - rm x86_64/Makefile + -rm armeabi-v7a/Makefile + -rm arm64-v8a/Makefile + -rm x86/Makefile + -rm x86_64/Makefile +## Refresh all arch Makefiles (delete and re-create all arch Makefiles) refreshMakefiles: cleanMakefiles createMakefiles + +include help.mk +helpHeader='pEpJNIAdapter/android/external Makefile' +helpPurpose='Cross-compile external dependencies of pEpEngine for the 4 Android archs \(x86, x86_64, arm, arm64\)' diff --git a/android/external/Makefile.conf b/android/external/Makefile.conf index f9102f8..3b684a3 100644 --- a/android/external/Makefile.conf +++ b/android/external/Makefile.conf @@ -1,4 +1,14 @@ -# TODO: Tiddy up +# TODO: Tiddy up +# COLORS +BOLD := $(shell tput bold) +RED := $(shell tput -Txterm setaf 1) +GREEN := $(shell tput -Txterm setaf 2) +YELLOW := $(shell tput -Txterm setaf 3) +CYAN := $(shell tput -Txterm setaf 6) +PURPLE := $(shell tput -Txterm setaf 5) +WHITE := $(shell tput -Txterm setaf 7) +RESET := $(shell tput -Txterm sgr0) + ### Android NDK Common conf NDK_TOOLCHAIN_COMPILER ?= clang diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index eb5bb49..38598d9 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -23,8 +23,10 @@ include ../PerArchMakefile.conf #------------------------------------------------------------------------------# +## Same as build all: build +## Build dependencies for arch [ARCH] build: showsetup uuid-prebuild sequoia-ffi-install libetpan-build #------------------------------------------------------------------------------# @@ -48,25 +50,26 @@ export ac_cv_func_malloc_0_nonnull=yes #------------------------------------------------------------------------------# # debugging stuff +## Show setup values for [ARCH] Makefile showsetup: - @echo "============================================== CURRENT SETUP ====================================================" - @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" - @echo "NDK_TOOLCHAIN_COMPILER: $(NDK_TOOLCHAIN_COMPILER)" - @echo "NDK_TOOLCHAIN_TARGET: $(NDK_TOOLCHAIN_TARGET)" - @echo "TEMP_WORK_PATH: $(TEMP_WORK_PATH)" - @echo "LOCAL: $(LOCAL)" - @echo "APP_ABI: $(APP_ABI)" - @echo "HOST: $(HOST)" - @echo "SEQUOIA_ARCH: $(SEQUOIA_ARCH)" - @echo "CC: $(CC)" - @echo "LD: $(LD)" - @echo "AR: $(AR)" - @echo "AS: $(AS)" - @echo "STRIP: $(STRIP)" - @echo "RANLIB: $(RANLIB)" - @echo "CFLAGS: $(CFLAGS)" - @echo "LDFLAGS: $(LDFLAGS)" - @echo "============================================== CURRENT SETUP END ====================================================" + @echo "${YELLOW}============================================== CURRENT SETUP ====================================================${RESET}" + @echo "${YELLOW}NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)${RESET}" + @echo "${YELLOW}NDK_TOOLCHAIN_COMPILER: $(NDK_TOOLCHAIN_COMPILER)${RESET}" + @echo "${YELLOW}NDK_TOOLCHAIN_TARGET: $(NDK_TOOLCHAIN_TARGET)${RESET}" + @echo "${YELLOW}TEMP_WORK_PATH: $(TEMP_WORK_PATH)${RESET}" + @echo "${YELLOW}LOCAL: $(LOCAL)${RESET}" + @echo "${YELLOW}APP_ABI: $(APP_ABI)${RESET}" + @echo "${YELLOW}HOST: $(HOST)${RESET}" + @echo "${YELLOW}SEQUOIA_ARCH: $(SEQUOIA_ARCH)${RESET}" + @echo "${YELLOW}CC: $(CC)${RESET}" + @echo "${YELLOW}LD: $(LD)${RESET}" + @echo "${YELLOW}AR: $(AR)${RESET}" + @echo "${YELLOW}AS: $(AS)${RESET}" + @echo "${YELLOW}STRIP: $(STRIP)${RESET}" + @echo "${YELLOW}RANLIB: $(RANLIB)${RESET}" + @echo "${YELLOW}CFLAGS: $(CFLAGS)${RESET}" + @echo "${YELLOW}LDFLAGS: $(LDFLAGS)${RESET}" + @echo "${YELLOW}============================================== CURRENT SETUP END ====================================================${RESET}" #------------------------------------------------------------------------------# # libiconv @@ -94,8 +97,10 @@ $(LOCAL)/lib/libiconv.a: libiconv/lib/.libs/libiconv.a $(MAKE) -C libiconv DESTDIR=$(DESTDIR) prefix=$(prefix) install ls -l $(LOCAL)/lib/libiconv.a +## Build iconv libiconv-build: libiconv/lib/.libs/libiconv.a +## Install iconv libiconv-install: $(LOCAL)/lib/libiconv.a #------------------------------------------------------------------------------# @@ -111,6 +116,7 @@ libetpan/Makefile: libetpan.src.stamp | $(LOCAL)/lib/libiconv.a cp -r libetpan/build-android/libetpan-android-$(ANDROID_ETPAN_BUILD_VERSION)/include/* $(LOCAL)/include/ touch $@ +## Build etpan libetpan-build: libetpan/Makefile #------------------------------------------------------------------------------# @@ -142,6 +148,7 @@ uuid-build: uuid/.libs/libuuid.so $(LOCAL)/include/uuid.h: uuid/Makefile mkdir -p $(LOCAL)/include && cd uuid && cp uuid.h $(LOCAL)/include +## Prebuild uuid uuid-prebuild: uuid/jni/Android.mk $(LOCAL)/include/uuid.h uuid/jni/Android.mk: uuid.src.stamp @@ -152,6 +159,7 @@ uuid/jni/Android.mk: uuid.src.stamp #------------------------------------------------------------------------------# # Sequoia +## Build sequoia dependencies sequoia-deps-build: $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so #------------------------------------------------------------------------------# @@ -176,8 +184,10 @@ $(LOCAL)/lib/libssl.so: openssl/libssl.so cp libssl.a $(LOCAL)/lib ls -l $(LOCAL)/lib/libssl.so +## Build openssl openssl-build: openssl/libssl.so +## Install openssl openssl-install: $(LOCAL)/lib/libssl.so @@ -207,8 +217,10 @@ $(LOCAL)/lib/libgmp.so: gmp/.libs/libgmp.so ls -l $(LOCAL)/lib/libgmp.so touch $@ +## Build gmp gmp-build: gmp/.libs/libgmp.so +## Install gmp gmp-install: $(LOCAL)/lib/libgmp.so @@ -239,8 +251,10 @@ $(LOCAL)/lib/libnettle.so: nettle/libnettle.so cp nettle/libnettle.so $(LOCAL)/lib/libnettle.so cp nettle/libhogweed.so $(LOCAL)/lib/libhogweed.so +## Build nettle nettle-build: nettle/libnettle.so +## Install nettle nettle-install: $(LOCAL)/lib/libnettle.so @@ -278,9 +292,10 @@ $(LOCAL)/lib/libsequoia_openpgp_ffi.so: $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/rele cp $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.* $(LOCAL)/lib/ cp -r sequoia/openpgp-ffi/include/* $(LOCAL)/include - +## Build sequoia-ffi sequoia-ffi-build: $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so +## Install sequoia-ffi sequoia-ffi-install: $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so $(LOCAL)/lib/libsequoia_openpgp_ffi.so #------------------------------------------------------------------------------# @@ -312,20 +327,23 @@ sequoia-ffi-install: $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so $(LOCAL)/l #------------------------------------------------------------------------------# # clean %-clean: - rm -rf $* - rm -rf $*.src.stamp + -rm -rf $* + -rm -rf $*.src.stamp clean-assets: - rm -rf $(ASSETS) + -rm -rf $(ASSETS) +## Delete install destination folder clean-install: - rm -rf $(LOCAL) + -rm -rf $(LOCAL) +## Remove generated artifacts clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-clean +## Remove generated artifacts and files clean-all: clean - rm -rf *.git - rm -rf *.stamp + -rm -rf *.git + -rm -rf *.stamp #------------------------------------------------------------------------------# .PHONY = clean clean-install clean-assets libetpan-clean \ @@ -336,9 +354,9 @@ clean-all: clean sequoia-deps-build \ openssl-build openssl-install \ nettle-build nettle-install \ - sequoia-ffi-build sequoia-ffi-install\ + sequoia-ffi-build sequoia-ffi-install \ assets \ - $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN)\ + $(EXTERNAL_LOCAL_GITS_UPDATE) $(EXTERNAL_SRCS) $(EXTERNAL_SRCS_CLEAN) \ showsetup #------------------------------------------------------------------------------# @@ -346,4 +364,7 @@ clean-all: clean .SECONDEXPANSION: # src %-src: %.src.stamp - @echo $< \ No newline at end of file + @echo $< + +include ../help.mk +helpPurpose='Cross-compile external dependencies of pEpEngine for arch [ARCH]' diff --git a/android/external/createMakefile.sh b/android/external/createMakefile.sh index 4bdc8f9..1f8e528 100644 --- a/android/external/createMakefile.sh +++ b/android/external/createMakefile.sh @@ -1,6 +1,5 @@ #!/bin/zsh #emulate -LR bash -#cd ~code/android/pEpJNIAdapter/external ARCH_DEST="$1" mkdir "$ARCH_DEST" diff --git a/android/external/downloads/Makefile b/android/external/downloads/Makefile index cc2bc09..2a2616b 100644 --- a/android/external/downloads/Makefile +++ b/android/external/downloads/Makefile @@ -13,20 +13,26 @@ include ../Makefile.conf #------------------------------------------------------------------------------# # Build parameters +## Download all dependencies all: downloads.stamp downloads.stamp: download-iconv download-uuid download-sequoia-deps download-etpan download-sequoia touch $@ +## Download iconv download-iconv: libiconv-1.15.tar.gz +## Download and patch uuid download-uuid: ossp-uuid_1.6.2.orig-patched.tar.gz +## Download sequoia dependencies download-sequoia-deps: openssl-$(OPENSSL_VERSION).tar.gz gmp-$(GMP_VERSION).tar.bz2 \ nettle-$(NETTLE_VERSION)-patched.tar.gz +## Download etpan download-etpan: libetpan.git.stamp +## Download sequoia download-sequoia: sequoia.git.stamp # Download source and patch it @@ -107,15 +113,14 @@ git_update: $(EXTERNAL_LOCAL_GITS_UPDATE) #------------------------------------------------------------------------------# clean: - rm -rf *.git - rm -rf *.stamp - rm -rf *.tar.gz - rm -rf *.tar.bz2 - rm -rf ../arm64-v8a/ndk-standalone-toolchain - rm -rf ../armeabi-v7a/ndk-standalone-toolchain - rm -rf ../x86/ndk-standalone-toolchain - rm -rf ../x86_64/ndk-standalone-toolchain + -rm -rf *.git + -rm -rf *.stamp + -rm -rf *.tar.gz + -rm -rf *.tar.bz2 .PHONY: all clean download-iconv \ download-uuid download-etpan \ download-sequoia-deps download-sequoia + +include ../help.mk +helpPurpose='Download all files and packages needed to compile external dependencies for pEpEngine' diff --git a/android/external/help.mk b/android/external/help.mk new file mode 100644 index 0000000..472769f --- /dev/null +++ b/android/external/help.mk @@ -0,0 +1,27 @@ +mkfileName = $(firstword $(MAKEFILE_LIST)) +helpHeader = $(notdir $(abspath $(dir $(mkfileName))))/$(mkfileName) + +TARGET_MAX_CHAR_NUM=21 +## Show help +help: + @echo '' + @echo '${BOLD}${CYAN}============= $(helpHeader) =============${RESET}' + @echo '' + @echo '${BOLD}Purpose:${RESET}' + @echo ' $(helpPurpose)' + @echo '' + @echo '${BOLD}Usage:${RESET}' + @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' + @echo '' + @echo '${BOLD}Targets:${RESET}' + @awk '/^[a-zA-Z\-\_0-9]+:/ { \ + helpMessage = match(lastLine, /^## (.*)/); \ + if (helpMessage) { \ + helpCommand = substr($$1, 0, index($$1, ":")-1); \ + helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ + printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ + } \ + } \ + { lastLine = $$0 }' $(MAKEFILE_LIST) + +.PHONY: help-base From c9f77caab7dc36189528a89d3c9b3eebe19e328c Mon Sep 17 00:00:00 2001 From: ignaciogarcia Date: Mon, 2 Jan 2023 16:56:56 +0100 Subject: [PATCH 29/29] PEMA-107 Update rust toolchain version for sequoia --- android/external/MakefileTemplate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/external/MakefileTemplate b/android/external/MakefileTemplate index 38598d9..be81e57 100644 --- a/android/external/MakefileTemplate +++ b/android/external/MakefileTemplate @@ -266,7 +266,7 @@ CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/../build/ sequoia.src.stamp: ../downloads/sequoia.tar.gz mkdir -p sequoia cd sequoia && tar xvf ../$< - $(SED) -i 's,1.48.0,1.49.0,' sequoia/rust-toolchain + $(SED) -i 's,1.48.0,1.64.0,' sequoia/rust-toolchain cd sequoia && cargo update -p nettle-sys --precise 2.0.8 mkdir -p $(LOCAL)/lib/ # This is a bad fix, we should move this to a common makefile (but not the .conf one)