Browse Source

Merge pull request 'gitea-29' (#30) from Ignacio/pEpJNIAdapter:gitea-29 into Release_2.1

Reviewed-on: https://gitea.pep.foundation/pEp.foundation/pEpJNIAdapter/pulls/30
Release_2.1
heck 3 years ago
parent
commit
00605c51e4
  1. 27
      android/build.gradle
  2. 95
      android/external/Makefile
  3. 24
      android/external/Makefile.conf
  4. 208
      android/external/MakefileTemplate
  5. 9
      android/external/PerArchMakefile.conf
  6. 388
      android/external/arm64-v8a/Makefile
  7. 398
      android/external/armeabi-v7a/Makefile
  8. 76
      android/external/createMakefile.sh
  9. 38
      android/external/downloads/Makefile
  10. 21
      android/external/generate-standalone-ndk-toolchain.sh
  11. 27
      android/external/help.mk
  12. 390
      android/external/x86/Makefile
  13. 56
      android/gradle/plugins/set-pep-jniadapter-archs.gradle

27
android/build.gradle

@ -8,6 +8,9 @@ def buildAutomatic = hasProperty('buildAutomatic') ? buildAutomatic : "true"
def threadsToUse = 1
def pEpEngineDB = new File(new File(pEpEngineSrc), 'db')
ext.archsToCompile = "arm arm64 x86 x86_64"
apply from: 'gradle/plugins/set-pep-jniadapter-archs.gradle'
buildscript {
repositories {
@ -80,7 +83,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'
}
}
@ -116,9 +119,14 @@ android {
}
// call external build (GnuPG, GPGME, etc)
task buildExternal(type:Exec, dependsOn: 'genSources') {
workingDir 'external'
commandLine 'make', "-j${threadsToUse}", 'build'
task buildExternal(dependsOn: ['genSources']) {
doLast {
println("buildExternal for abis: ${project.archsToCompile}")
exec {
workingDir 'external'
commandLine 'make', "-j${threadsToUse}", 'build', "archs=${project.archsToCompile}"
}
}
}
task externalAssets(type:Exec) {
@ -152,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
}

95
android/external/Makefile

@ -19,39 +19,102 @@ 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 help
build: all
## 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
build-arm: downloads/downloads.stamp
## Call armeabi-v7a Makefile (build dependencies for arm arch)
build-arm: armeabi-v7a/Makefile downloads/downloads.stamp
$(MAKE) -C armeabi-v7a
build-arm64: downloads/downloads.stamp
## 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
build-x86: downloads/downloads.stamp
## 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
build-x86_64: downloads/downloads.stamp
## 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
-$(MAKE) -C armeabi-v7a clean
-$(MAKE) -C arm64-v8a clean
-$(MAKE) -C x86 clean
-$(MAKE) -C x86_64 clean
clean-all:
## Clean generated artifacts for all archs and remove downloaded files
clean-all: clean
$(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
-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
## Show setup values for x86_64 Makefile
showx86_64Setup:
-$(MAKE) -C x86_64 showsetup
## Show setup values for arm (armeabi-v7a) Makefile
showArmSetup:
-$(MAKE) -C armeabi-v7a showsetup
## Show setup values for arm64 (arm64-v8a) Makefile
showArm64Setup:
-$(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
## 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\)'

24
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
@ -51,5 +61,17 @@ 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)/..
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

208
android/external/x86_64/Makefile → android/external/MakefileTemplate

@ -1,56 +1,42 @@
# Copyright 2019, pEp Foundation
# This file is part of pEpJNIAdapter for Android - x86_64 build
# 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
# Build parameters
APP_ABI ?= [ARCH]
HOST ?= [HOST]
NDK_TOOLCHAIN_TARGET ?= [NDK_TOOLCHAIN_TARGET]
SEQUOIA_ARCH ?= [SEQUOIA_ARCH]
OPENSSL_ARCHITECTURE ?= [OPENSSL_ARCHITECTURE]
COMPILER_PREFIX ?= [COMPILER_PREFIX]
# 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
# based on gnupg-for-android/external/Makefile
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
# Build parameters
APP_ABI ?= x86_64
## Same as build
all: build
build:showsetup uuid-install sequoia-ffi-install libetpan-build
## Build dependencies for arch [ARCH]
build: showsetup uuid-prebuild 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)
# Manage paths for PREFIX, LOCAL and PATH
# 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)
CFLAGS += $(MYCFLAGS)
LDFLAGS += $(MYLDFLAGS)
#------------------------------------------------------------------------------#
# GNU Tools trickery
@ -64,15 +50,26 @@ export ac_cv_func_malloc_0_nonnull=yes
#------------------------------------------------------------------------------#
# debugging stuff
## Show setup values for [ARCH] Makefile
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)"
@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
@ -82,12 +79,6 @@ libiconv.src.stamp: ../downloads/libiconv-1.15.tar.gz
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)" \
@ -106,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
#------------------------------------------------------------------------------#
@ -117,36 +110,26 @@ 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/
touch $@
## Build etpan
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.tar.gz
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
-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 && \
@ -160,17 +143,13 @@ 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
## Prebuild uuid
uuid-prebuild: uuid/jni/Android.mk $(LOCAL)/include/uuid.h
uuid/jni/Android.mk: uuid.src.stamp
mkdir -p uuid/jni
@ -180,7 +159,8 @@ uuid/jni/Android.mk: uuid.src.stamp
#------------------------------------------------------------------------------#
# Sequoia
sequoia-deps-build: openssl-install nettle-install
## Build sequoia dependencies
sequoia-deps-build: $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so
#------------------------------------------------------------------------------#
# OpenSSL
@ -190,30 +170,24 @@ openssl.src.stamp: ../downloads/openssl-$(OPENSSL_VERSION).tar.gz
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)
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
cd openssl && \
mkdir -p $(LOCAL)/lib && cd openssl && \
cp libcrypto.so $(LOCAL)/lib && \
cp libcrypto.a $(LOCAL)/lib && \
cp libssl.so $(LOCAL)/lib && \
cp libssl.a $(LOCAL)/lib
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
@ -225,19 +199,13 @@ gmp.src.stamp: ../downloads/gmp-$(GMP_VERSION).tar.bz2
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
--disable-static[GMP_MAKEFILE_EXTRA]
gmp/.libs/libgmp.so: gmp/Makefile
@ -249,28 +217,22 @@ $(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
#------------------------------------------------------------------------------#
# 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 $@
nettle-src: nettle.src.stamp gmp-install
nettle-clean:
rm -rf nettle
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
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 \
@ -289,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
@ -302,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)
@ -313,8 +277,8 @@ 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)" \
$(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/ \
PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig \
@ -322,17 +286,17 @@ $(CARGO_TARGET_DIR)/x86_64-linux-android/release/libsequoia_openpgp_ffi.so: seq
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
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)/x86_64-linux-android/release/libsequoia_openpgp_ffi.so
cp $(CARGO_TARGET_DIR)/x86_64-linux-android/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
## Build sequoia-ffi
sequoia-ffi-build: $(CARGO_TARGET_DIR)/$(SEQUOIA_ARCH)/release/libsequoia_openpgp_ffi.so
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
## Install sequoia-ffi
sequoia-ffi-install: $(LOCAL)/lib/libssl.so $(LOCAL)/lib/libnettle.so $(LOCAL)/lib/libsequoia_openpgp_ffi.so
#------------------------------------------------------------------------------#
# assets for Android app
@ -362,29 +326,45 @@ 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)
-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 \
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 \
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
#------------------------------------------------------------------------------#
.SECONDEXPANSION:
# src
%-src: %.src.stamp
@echo $<
include ../help.mk
helpPurpose='Cross-compile external dependencies of pEpEngine for arch [ARCH]'

9
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"

388
android/external/arm64-v8a/Makefile

@ -1,388 +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.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
-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 && \
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).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
-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 \
--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

398
android/external/armeabi-v7a/Makefile

@ -1,398 +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.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
-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 && \
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).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
-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 \
--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

76
android/external/createMakefile.sh

@ -0,0 +1,76 @@
#!/bin/zsh
#emulate -LR bash
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)
HOST=i686-linux-android
COMPILER_PREFIX="$HOST"
NDK_TOOLCHAIN_TARGET="$ARCH_DEST"
ARCH_DEBUG_CFLAGS=TARGET_x86_debug_CFLAGS
OPENSSL_ARCHITECTURE=android-x86
SEQUOIA_ARCH=i686-linux-android
;;
x86_64)
HOST=x86_64-linux-android
COMPILER_PREFIX="$HOST"
NDK_TOOLCHAIN_TARGET="$ARCH_DEST"
ARCH_DEBUG_CFLAGS=TARGET_x86_64_debug_CFLAGS
OPENSSL_ARCHITECTURE=android-x86_64
SEQUOIA_ARCH=x86_64-linux-android
;;
armeabi-v7a)
HOST=arm-linux-androideabi
COMPILER_PREFIX=armv7a-linux-androideabi
NDK_TOOLCHAIN_TARGET="$HOST"
ARCH_DEBUG_CFLAGS=TARGET_arm_debug_CFLAGS
OPENSSL_ARCHITECTURE=android-arm
SEQUOIA_ARCH=armv7-linux-androideabi
;;
arm64-v8a)
HOST=aarch64-linux-android
COMPILER_PREFIX="$HOST"
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/\[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"

38
android/external/downloads/Makefile

@ -13,26 +13,38 @@ 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-uuid: ossp-uuid_1.6.2.orig.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).tar.gz
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
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
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
md5sum -c ossp-uuid_1.6.2.orig.tar.gz.md5
@ -45,6 +57,13 @@ 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)
rm -rf 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
@ -94,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'

21
android/external/generate-standalone-ndk-toolchain.sh

@ -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

27
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}<target>${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

390
android/external/x86/Makefile

@ -1,390 +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.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
-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 && \
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).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
-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 \
--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

56
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<String> 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
}
Loading…
Cancel
Save