Browse Source

Merge multiarch-build into sync

JNI-88
Hussein Kasem 6 years ago
parent
commit
448edef931
  1. 2
      .hgignore
  2. 44
      android/build.gradle
  3. 502
      android/external/Makefile
  4. 40
      android/external/Makefile.conf
  5. 395
      android/external/arm64-v8a/Makefile
  6. 21
      android/external/arm64-v8a/generate-standalone-ndk-toolchain.sh
  7. 402
      android/external/armeabi-v7a/Makefile
  8. 21
      android/external/armeabi-v7a/generate-standalone-ndk-toolchain.sh
  9. 1168
      android/external/config.guess
  10. 2492
      android/external/config.sub
  11. 17
      android/external/configure_openssl.sh
  12. 121
      android/external/downloads/Makefile
  13. 0
      android/external/downloads/gmp-6.1.2.tar.bz2.md5
  14. 0
      android/external/downloads/nettle-3.4.1.tar.gz.md5
  15. 0
      android/external/downloads/openssl-1.1.1b.tar.gz.md5
  16. 0
      android/external/downloads/ossp-uuid_1.6.2.orig.tar.gz.md5
  17. 394
      android/external/x86/Makefile
  18. 21
      android/external/x86/generate-standalone-ndk-toolchain.sh
  19. 394
      android/external/x86_64/Makefile
  20. 21
      android/external/x86_64/generate-standalone-ndk-toolchain.sh
  21. 22
      android/jni/Android.mk
  22. 2
      android/jni/Application.mk
  23. 120
      android/src-pEpJNIAdapter-android-pEpJNIAdapter~2.iml
  24. 2
      src/jniutils.cc
  25. 14
      utils/configure_openssl.sh
  26. 48
      utils/ndk_toolchains_path.py

2
.hgignore

@ -78,6 +78,8 @@ androidTests/gradlew.bat
src/org.tar.gz
src/local.conf
*.iml
syntax: regexp
android/external/[^.]*

44
android/build.gradle

@ -2,9 +2,7 @@
def pEpEngineSrc = hasProperty('pEpEngineSrc') ? pEpEngineSrc : "../../pEpEngine"
def buildAutomatic = hasProperty('buildAutomatic') ? buildAutomatic : "true"
def pEpAppPackageName = hasProperty('pEpAppPackageName') ? pEpAppPackageName : "pep.android.k9"
def libetpanAndroid = file('external/libetpan/build-android')
def threadsToUse = hasProperty('threadsToUse') ? buildAutomatic : 2
def pEpEngineDB = new File(new File(pEpEngineSrc), 'db')
@ -14,7 +12,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
@ -39,7 +37,7 @@ android {
externalNativeBuild {
ndkBuild {
abiFilters "armeabi-v7a"
//abiFilters "armeabi-v7a"
//abiFilters ["armeabi-v7a"]
//abiFilters ["arm64-v8a, armeabi-v7a"]
}
@ -80,6 +78,7 @@ android {
jniDebuggable true
externalNativeBuild {
ndkBuild {
arguments "-j${threadsToUse}", 'NDK_LOG=1'
// arguments '-B', 'NDK_DEBUG=1', 'NDEBUG=null', 'NDK_LOG=1'
}
}
@ -92,64 +91,53 @@ android {
}
}
ext {
//FIXME> improve that build to be able to build without the need of unzip deps // Get rid of unziping
libEtPanZip = new File(libetpanAndroid, 'libetpan-android-1.zip')
}
// call source generation makefile target
task genSources(type:Exec, dependsOn: 'genpEpEngineAsn1Sources') {
workingDir '../src'
commandLine 'make', 'pEp.jar'
commandLine 'make', "-j${threadsToUse}", 'pEp.jar'
}
task genpEpEngineSyncSources(type:Exec) {
workingDir '../../pEpEngine'
commandLine 'make', '-C', 'sync'
workingDir "${pEpEngineSrc}"
commandLine 'make', "-j${threadsToUse}", '-C', 'sync'
}
task genpEpEngineAsn1Sources(type:Exec, dependsOn: 'genpEpEngineSyncSources') {
workingDir '../../pEpEngine'
commandLine 'make', '-C', 'asn.1'
workingDir "${pEpEngineSrc}"
commandLine 'make', "-j${threadsToUse}", '-C', 'asn.1'
}
task cleanGenSource(type:Exec) {
workingDir '../src'
commandLine 'make', 'clean'
commandLine 'make', "-j${threadsToUse}", 'clean'
}
// call external build (GnuPG, GPGME, etc)
task buildExternal(type:Exec, dependsOn: 'genSources') {
workingDir 'external'
commandLine 'make', 'build', 'PEP_PACKAGE_NAME='+pEpAppPackageName
commandLine 'make', "-j${threadsToUse}", 'build'
}
task externalAssets(type:Exec) {
workingDir 'external'
commandLine 'make', 'assets', 'PEP_PACKAGE_NAME='+pEpAppPackageName
commandLine 'make', "-j${threadsToUse}", 'assets'
}
task cleanExternal(type:Exec) {
workingDir 'external'
commandLine 'make', 'clean', 'PEP_PACKAGE_NAME='+pEpAppPackageName
commandLine 'make', "-j${threadsToUse}", 'clean'
}
task cleanExternalAssets(type:Exec) {
workingDir 'external'
commandLine 'make', 'clean-assets', 'PEP_PACKAGE_NAME='+pEpAppPackageName
}
// unzip some of the dependencies
task unzipDeps(type: Copy, dependsOn: 'buildExternal') {
from zipTree(libEtPanZip)
into file("${buildDir}")
commandLine 'make', 'clean-assets'
}
// builds pEpEnginge's system.db
task buildpEpEngineSystemDB(type:Exec) {
workingDir pEpEngineDB
commandLine 'make', 'system.db'
commandLine 'make', "-j${threadsToUse}", 'system.db'
}
// copy pEpEnginge's system.db to asset
@ -159,7 +147,7 @@ android {
}
if(buildAutomatic == "true") {
buildpEpEngineSystemDB.dependsOn(unzipDeps)
buildpEpEngineSystemDB.dependsOn(buildExternal)
}
// This ensures that assets are populated before collecting resources.

502
android/external/Makefile

@ -1,480 +1,54 @@
#------------------------------------------------------------------------------#
# Makefile to build deps for use with pEpEngine
# based on gnupg-for-android/external/Makefile
#------------------------------------------------------------------------------#
# Copyright 2019, pEp Foundation
# This file is part of pEpJNIAdapter Android Build
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
#------------------------------------------------------------------------------#
# Build parameters
HERE_REL := $(notdir $(CURDIR))
# TODO: get params from the outside for multiarch build
include Makefile.conf
NDK_ABI ?= arm
NDK_TOOLCHAIN_VERSION ?= clang
APP_ABI ?= armeabi-v7a
APP_PLATFORM ?= android-18
PEP_PACKAGE_NAME ?= security.pEp
APP_OPTIM ?= debug
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 = /data/data/$(PEP_PACKAGE_NAME)/$(APP_ABI)/app_opt
LOCAL := $(DESTDIR)$(prefix)
PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin
NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot
NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]')
ifeq ($(NDK_ABI),x86)
HOST = i686-linux-android
NDK_TOOLCHAIN = $(NDK_ABI)-$(NDK_TOOLCHAIN_VERSION)
else
HOST = $(NDK_ABI)-linux-androideabi
NDK_TOOLCHAIN = $(HOST)-$(NDK_TOOLCHAIN_VERSION)
ifneq ($(wildcard local.conf),)
$(info ================================================)
$(info Overrides in `local.conf` are used.)
$(info ================================================)
endif
# include Android's build flags
TARGET_ARCH_ABI = $(APP_ABI)
include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk
#include $(ANDROID_NDK_HOME)/toolchains/$(NDK_TOOLCHAIN)/setup.mk
ANDROID_NDK_HOME=$(EXTERNAL_ROOT)/ndk-18-arm
LD := $(ANDROID_NDK_HOME)/bin/$(HOST)-ld
AR := $(ANDROID_NDK_HOME)/bin/$(HOST)-ar
AS := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang++
RANLIB := $(ANDROID_NDK_HOME)/bin/$(HOST)-ranlib
STRIP := $(ANDROID_NDK_HOME)/bin/$(HOST)-strip
#-D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1
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
ifeq ($(APP_ABI),armeabi-v7a)
CFLAGS += $(TARGET_arm_debug_CFLAGS)
endif
ifeq ($(APP_ABI),armeabi)
CFLAGS += $(TARGET_thumb_debug_CFLAGS)
ifdef BUILD_CONFIG
$(info ================================================)
$(info Overrides in `$(BUILD_CONFIG)` are used.)
$(info ================================================)
endif
#------------------------------------------------------------------------------#
# 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_VERSION: $(NDK_TOOLCHAIN_VERSION)"
@echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)"
@echo "NDK_SYSROOT: $(NDK_SYSROOT)"
@echo "APP_PLATFORM: $(APP_PLATFORM)"
@echo "APP_ABI: $(APP_ABI)"
@echo "HOST: $(HOST)"
@echo "CC: $(CC)"
@echo "LD: $(LD)"
@echo "CFLAGS: $(CFLAGS)"
@echo "LDFLAGS: $(LDFLAGS)"
#------------------------------------------------------------------------------#
# libiconv
# libiconv from git can't autogen with today's debian packages.
#EXTERNAL_GIT_REPOS += libiconv|git://git.savannah.gnu.org/libiconv.git?5365cc8
# using released package instead
libiconv-1.15.tar.gz:
wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
touch $@
libiconv.src.stamp: libiconv-1.15.tar.gz
tar xvfz 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
EXTERNAL_SRCS += libiconv-src
EXTERNAL_SRCS_CLEAN += libiconv-clean
libiconv/Makefile: libiconv.src.stamp
-patch -N -p1 --reject-file=- libiconv/m4/libtool.m4 libtool-Add-Android-Linux-support-iconv.patch
cp config.sub libiconv/build-aux
cp config.guess libiconv/build-aux
cp config.sub libiconv/libcharset/build-aux
cp config.guess libiconv/libcharset/build-aux
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
EXTERNAL_GIT_REPOS += libetpan|https://github.com/fdik/libetpan.git?HEAD
libetpan/Makefile: libetpan.src.stamp | libiconv-install
cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh
touch $@
libetpan-build: libetpan/Makefile
libetpan-cleanzip:
rm -f libetpan/build-android/libetpan-android-1.zip
#------------------------------------------------------------------------------#
# uuid
# using released package from debian. official ftp wasn't available today
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
touch $@
uuid.src.stamp: ossp-uuid_1.6.2.orig.tar.gz
tar xvfz ossp-uuid_1.6.2.orig.tar.gz
mv uuid-1.6.2 uuid
touch $@
uuid-src: uuid.src.stamp
uuid-clean:
rm -rf uuid
rm -rf uuid.src.stamp
EXTERNAL_SRCS += uuid-src
EXTERNAL_SRCS_CLEAN += 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 && \
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
OPENSSL_VERSION=1.1.1b
GMP_VERSION=6.1.2
NETTLE_VERSION=3.4.1
sequoia-deps-build: gmp-install nettle-install openssl-install
#------------------------------------------------------------------------------#
# OpenSSL
openssl-$(OPENSSL_VERSION).tar.gz:
wget -nc https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz
md5sum -c openssl-$(OPENSSL_VERSION).tar.gz.md5
touch $@
openssl.src.stamp: openssl-$(OPENSSL_VERSION).tar.gz
tar xvf 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
EXTERNAL_SRCS += openssl-src
EXTERNAL_SRCS_CLEAN += openssl-clean
openssl/Makefile: openssl.src.stamp
cd openssl && \
PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" ./Configure android-arm --prefix=$(prefix)
openssl/libssl.so: | openssl/Makefile
PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl
$(LOCAL)/lib/libssl.so: openssl/libssl.so
PATH="$(ANDROID_NDK_HOME)/bin:$(PATH)" $(MAKE) -C openssl DESTDIR=$(DESTDIR) prefix=$(prefix) install_sw
pwd
ls -l $(LOCAL)/lib/libssl.so
openssl-build: openssl/libssl.so
openssl-install: $(LOCAL)/lib/libssl.so
#------------------------------------------------------------------------------#
# GMP
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
touch $@
gmp.src.stamp: gmp-$(GMP_VERSION).tar.bz2
tar xvf 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
EXTERNAL_SRCS += gmp-src
EXTERNAL_SRCS_CLEAN += gmp-clean
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-$(NETTLE_VERSION).tar.gz: $(LOCAL)/lib/libgmp.so
wget -nc https://ftp.gnu.org/gnu/nettle/nettle-$(NETTLE_VERSION).tar.gz
md5sum -c nettle-$(NETTLE_VERSION).tar.gz.md5
touch $@
nettle.src.stamp: nettle-$(NETTLE_VERSION).tar.gz
tar xvf nettle-$(NETTLE_VERSION).tar.gz
mv nettle-$(NETTLE_VERSION) nettle
touch $@
nettle-src: nettle.src.stamp
nettle-clean:
rm -rf nettle
rm -rf nettle.src.stamp
EXTERNAL_SRCS += nettle-src
EXTERNAL_SRCS_CLEAN += nettle-clean
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 \
--host=$(HOST) \
--prefix=$(LOCAL)
nettle/libnettle.so: nettle/Makefile
$(MAKE) -C nettle
$(LOCAL)/lib/libnettle.so: nettle/libnettle.so nettle/libhogweed.so
$(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install
nettle-build: nettle/libnettle.so nettle/libhogweed.so
nettle-install: $(LOCAL)/lib/libnettle.so $(LOCAL)/lib/libhogweed.so
#------------------------------------------------------------------------------#
# Sequoia-ffi
EXTERNAL_GIT_REPOS += sequoia|https://gitlab.com/husspEp/sequoia.git?master
CARGO_TARGET_DIR=$(EXTERNAL_ROOT)/build/$(APP_ABI)
sequoia-ffi-clean:
rm -rf sequoia
rm -rf sequoia.src.stamp
EXTERNAL_SRCS_CLEAN += sequoia-ffi-clean
$(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)" \
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
define per_repo_targets
$(1).git.stamp:
git clone $(2) $(1).git
touch $(1).git.stamp
$(1).git_update: $(1).git.stamp
cd $(1).git; git pull
touch $(1).git.stamp
$(1).src.stamp: $(1).git.stamp
rm -rf $(1)
mkdir $(1)
(cd $(1).git; git archive --format=tar $(3)) | tar -C $(1) -x
touch $(1).src.stamp
$(1)-src: $(1).src.stamp
$(1)-clean:
rm -rf $(1)
rm -f $(1).src.stamp
EXTERNAL_LOCAL_GITS += $(1).git.stamp
EXTERNAL_LOCAL_GITS_UPDATE += $(1).git_update
EXTERNAL_SRCS += $(1)-src
EXTERNAL_SRCS_CLEAN += $(1)-clean
endef
define per_repo
$(call per_repo_targets,\
$(1),\
$(word 1,$(subst ?, ,$(2))),\
$(word 2,$(subst ?, ,$(2))))
endef
.PHONY: all build clean clean-all
$(foreach repo, $(EXTERNAL_GIT_REPOS), $(eval $(call per_repo,\
$(word 1,$(subst |, ,$(repo))),\
$(word 2,$(subst |, ,$(repo))))))
all: build-arm build-arm64 build-x86 build-x86_64
git_clones: $(EXTERNAL_LOCAL_GITS)
build-arm: downloads/downloads.stamp
$(MAKE) -C armeabi-v7a
git_update: $(EXTERNAL_LOCAL_GITS_UPDATE)
build-arm64: downloads/downloads.stamp
$(MAKE) -C arm64-v8a
#------------------------------------------------------------------------------#
# clean
build-x86: downloads/downloads.stamp
$(MAKE) -C x86
clean-assets:
rm -rf $(ASSETS)
build-x86_64: downloads/downloads.stamp
$(MAKE) -C x86_64
clean-install:
rm -rf $(DESTDIR)/data
clean:
$(MAKE) -C armeabi-v7a clean
$(MAKE) -C arm64-v8a clean
$(MAKE) -C x86 clean
$(MAKE) -C x86_64 clean
clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-cleanzip
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
clean-all: clean
rm -rf *.git
rm -rf *.stamp
#------------------------------------------------------------------------------#
downloads/downloads.stamp:
$(MAKE) -C downloads
.PHONY = clean clean-install clean-assets libetpan-cleanzip\
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
assets:

40
android/external/Makefile.conf

@ -0,0 +1,40 @@
# TODO: Tiddy up
### Android NDK Common conf
NDK_TOOLCHAIN_COMPILER ?= clang
### Select GNU SED on MacOS.
NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]')
ifeq ($(NDK_UNAME),darwin)
SED=gsed
else
SED=sed
endif
### Sequoia deps versions
OPENSSL_VERSION=1.1.1b
GMP_VERSION=6.1.2
NETTLE_VERSION=3.4.1
### Git deps repos
EXTERNAL_GIT_REPOS += libetpan|https://github.com/fdik/libetpan.git?HEAD
EXTERNAL_GIT_REPOS += sequoia|https://gitlab.com/husspEp/sequoia.git?master
### Common variables
#### Source code targets
EXTERNAL_SRCS += libiconv-src
EXTERNAL_SRCS += uuid-src
EXTERNAL_SRCS += openssl-src
EXTERNAL_SRCS += gmp-src
EXTERNAL_SRCS += nettle-src
#### Clean source code targets.
EXTERNAL_SRCS_CLEAN += libiconv-clean
EXTERNAL_SRCS_CLEAN += uuid-clean
EXTERNAL_SRCS_CLEAN += openssl-clean
EXTERNAL_SRCS_CLEAN += gmp-clean
EXTERNAL_SRCS_CLEAN += nettle-clean
EXTERNAL_SRCS_CLEAN += sequoia-ffi-clean

395
android/external/arm64-v8a/Makefile

@ -0,0 +1,395 @@
# 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
ANDROID_API ?= 21
all: build
build: generate-ndk-toolchain showsetup uuid-install sequoia-ffi-install libetpan-build
#------------------------------------------------------------------------------#
# Generate standalone toolchain
generate-ndk-toolchain: ndk-standalone-toolchain/bin/clang
ndk-standalone-toolchain/bin/clang:
bash generate-standalone-ndk-toolchain.sh
#------------------------------------------------------------------------------#
# 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
ANDROID_NDK_HOME=$(EXTERNAL_ROOT)/ndk-standalone-toolchain
LD := $(ANDROID_NDK_HOME)/bin/$(HOST)-ld
AR := $(ANDROID_NDK_HOME)/bin/$(HOST)-ar
AS := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang++
RANLIB := $(ANDROID_NDK_HOME)/bin/$(HOST)-ranlib
STRIP := $(ANDROID_NDK_HOME)/bin/$(HOST)-strip
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 xvfz $<
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 xvfz ../$<
touch $@
libetpan/Makefile: libetpan.src.stamp | libiconv-install
cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh
cp -r libetpan/build-android/libetpan-android-1/$(APP_ABI)/lib/* $(LOCAL)/lib/
cp -r libetpan/build-android/libetpan-android-1/include/* $(LOCAL)/include/
touch $@
libetpan-build: libetpan/Makefile
libetpan-clean:
rm -rf libetpan
#------------------------------------------------------------------------------#
# 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 && \
../../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
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 ../$<
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)" \
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

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

@ -0,0 +1,21 @@
#!/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 arm64 --api 21 --install-dir=ndk-standalone-toolchain
exit 0

402
android/external/armeabi-v7a/Makefile

@ -0,0 +1,402 @@
# 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
ANDROID_API ?= 18
all: build
#assets
build: generate-ndk-toolchain showsetup uuid-install sequoia-ffi-install libetpan-build
#------------------------------------------------------------------------------#
# Generate standalone toolchain
generate-ndk-toolchain: ndk-standalone-toolchain/bin/clang
ndk-standalone-toolchain/bin/clang:
bash generate-standalone-ndk-toolchain.sh
#------------------------------------------------------------------------------#
# 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
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=$(EXTERNAL_ROOT)/ndk-standalone-toolchain
LD := $(ANDROID_NDK_HOME)/bin/$(HOST)-ld
AR := $(ANDROID_NDK_HOME)/bin/$(HOST)-ar
AS := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang++
RANLIB := $(ANDROID_NDK_HOME)/bin/$(HOST)-ranlib
STRIP := $(ANDROID_NDK_HOME)/bin/$(HOST)-strip
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
cp -r libetpan/build-android/libetpan-android-1/$(APP_ABI)/lib/* $(LOCAL)/lib/
cp -r libetpan/build-android/libetpan-android-1/include/* $(LOCAL)/include/
touch $@
libetpan-build: libetpan/Makefile
libetpan-clean:
rm -rf libetpan
#------------------------------------------------------------------------------#
# 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 xvfz $<
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
OPENSSL_VERSION=1.1.1b
GMP_VERSION=6.1.2
NETTLE_VERSION=3.4.1
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 && \
../../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
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 ../$<
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)" \
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

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

@ -0,0 +1,21 @@
#!/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-standalone-toolchain
exit 0

1168
android/external/config.guess

File diff suppressed because it is too large

2492
android/external/config.sub

File diff suppressed because it is too large

17
android/external/configure_openssl.sh

@ -0,0 +1,17 @@
#!/bin/bash
### 
# DONT USE IT
### 
CC=clang
TOOLCHAINS_PATH=$(python ../../../../utils/ndk_toolchains_path.py --ndk ${ANDROID_NDK})
export OLD_PATH=$PATH
export PATH=$TOOLCHAINS_PATH/bin:$PATH
ARCHITECTURE=$1
ANDROID_API=$2
echo $3
./Configure ${ARCHITECTURE} -D__ANDROID_API__=$ANDROID_API --prefix=$3
export PATH=$OLD_PATH

121
android/external/downloads/Makefile

@ -0,0 +1,121 @@
# 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
all: downloads.stamp
downloads.stamp: download-iconv download-uuid download-sequoia-deps download-etpan download-sequoia \
generate-ndk-arm generate-ndk-arm64 generate-ndk-x86 generate-ndk-x86_64
touch $@
generate-ndk-arm64:
cd ../arm64-v8a && bash generate-standalone-ndk-toolchain.sh
generate-ndk-arm:
cd ../armeabi-v7a && bash generate-standalone-ndk-toolchain.sh
generate-ndk-x86:
cd ../x86 && bash generate-standalone-ndk-toolchain.sh
generate-ndk-x86_64:
cd ../x86_64 && bash generate-standalone-ndk-toolchain.sh
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
download-etpan: libetpan.git.stamp
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.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
openssl-$(OPENSSL_VERSION).tar.gz:
wget -nc https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz
md5sum -c openssl-$(OPENSSL_VERSION).tar.gz.md5
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).tar.gz:
wget -nc https://ftp.gnu.org/gnu/nettle/nettle-$(NETTLE_VERSION).tar.gz
md5sum -c nettle-$(NETTLE_VERSION).tar.gz.md5
#------------------------------------------------------------------------------#
# Clone update and archive external projects GIT repos
# Local clone is in external/$project.git while
# selected commit is archived in external/$project
define per_repo_targets
$(1).git.stamp:
git clone $(2) $(1).git
(cd $(1).git; git archive --format=tar $(3)) > $(1).tar.gz
touch $(1).git.stamp
$(1).git_update: $(1).git.stamp
cd $(1).git; git pull
rm -rf $(1).tar.gz
(cd $(1).git; git archive --format=tar $(3)) > $(1).tar.gz
touch $(1).git.stamp
$(1)-clean:
rm -rf $(1)
rm -f $(1).src.stamp
EXTERNAL_LOCAL_GITS += $(1).git.stamp
EXTERNAL_LOCAL_GITS_UPDATE += $(1).git_update
EXTERNAL_SRCS += $(1)-src
EXTERNAL_SRCS_CLEAN += $(1)-clean
endef
define per_repo
$(call per_repo_targets,\
$(1),\
$(word 1,$(subst ?, ,$(2))),\
$(word 2,$(subst ?, ,$(2))))
endef
$(foreach repo, $(EXTERNAL_GIT_REPOS), $(eval $(call per_repo,\
$(word 1,$(subst |, ,$(repo))),\
$(word 2,$(subst |, ,$(repo))))))
git_clones: $(EXTERNAL_LOCAL_GITS)
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
.PHONY: all clean download-iconv \
download-uuid download-etpan \
download-sequoia-deps download-sequoia

0
android/external/gmp-6.1.2.tar.bz2.md5 → android/external/downloads/gmp-6.1.2.tar.bz2.md5

0
android/external/nettle-3.4.1.tar.gz.md5 → android/external/downloads/nettle-3.4.1.tar.gz.md5

0
android/external/openssl-1.1.1b.tar.gz.md5 → android/external/downloads/openssl-1.1.1b.tar.gz.md5

0
android/external/ossp-uuid_1.6.2.orig.tar.gz.md5 → android/external/downloads/ossp-uuid_1.6.2.orig.tar.gz.md5

394
android/external/x86/Makefile

@ -0,0 +1,394 @@
# 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
ANDROID_API ?= 18
all: build
build: generate-ndk-toolchain showsetup uuid-install sequoia-ffi-install libetpan-build
#------------------------------------------------------------------------------#
# Generate standalone toolchain
generate-ndk-toolchain: ndk-standalone-toolchain/bin/clang
ndk-standalone-toolchain/bin/clang:
bash generate-standalone-ndk-toolchain.sh
#------------------------------------------------------------------------------#
# 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=$(EXTERNAL_ROOT)/ndk-standalone-toolchain
LD := $(ANDROID_NDK_HOME)/bin/$(HOST)-ld
AR := $(ANDROID_NDK_HOME)/bin/$(HOST)-ar
AS := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang++
RANLIB := $(ANDROID_NDK_HOME)/bin/$(HOST)-ranlib
STRIP := $(ANDROID_NDK_HOME)/bin/$(HOST)-strip
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 xvfz $<
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 xvfz ../$<
touch $@
libetpan/Makefile: libetpan.src.stamp | libiconv-install
cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh
cp -r libetpan/build-android/libetpan-android-1/$(APP_ABI)/lib/* $(LOCAL)/lib/
cp -r libetpan/build-android/libetpan-android-1/include/* $(LOCAL)/include/
touch $@
libetpan-build: libetpan/Makefile
libetpan-clean:
rm -rf libetpan
#------------------------------------------------------------------------------#
# 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 && \
../../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/Makefile
$(MAKE) -C nettle
$(LOCAL)/lib/libnettle.so: nettle/libnettle.so
$(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install
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 ../$<
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)" \
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

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

@ -0,0 +1,21 @@
#!/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 x86 --api 18 --install-dir=ndk-standalone-toolchain
exit 0

394
android/external/x86_64/Makefile

@ -0,0 +1,394 @@
# 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
ANDROID_API ?= 21
all: build
build: generate-ndk-toolchain showsetup uuid-install sequoia-ffi-install libetpan-build
#------------------------------------------------------------------------------#
# Generate standalone toolchain
generate-ndk-toolchain: ndk-standalone-toolchain/bin/clang
ndk-standalone-toolchain/bin/clang:
bash generate-standalone-ndk-toolchain.sh
#------------------------------------------------------------------------------#
# 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=$(EXTERNAL_ROOT)/ndk-standalone-toolchain
LD := $(ANDROID_NDK_HOME)/bin/$(HOST)-ld
AR := $(ANDROID_NDK_HOME)/bin/$(HOST)-ar
AS := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang
CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)$(ANDROID_API)-clang++
RANLIB := $(ANDROID_NDK_HOME)/bin/$(HOST)-ranlib
STRIP := $(ANDROID_NDK_HOME)/bin/$(HOST)-strip
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 xvfz $<
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 xvfz ../$<
touch $@
libetpan/Makefile: libetpan.src.stamp | libiconv-install
cd libetpan/build-android; ICONV_PREFIX=$(LOCAL) bash ./build.sh
cp -r libetpan/build-android/libetpan-android-1/$(APP_ABI)/lib/* $(LOCAL)/lib/
cp -r libetpan/build-android/libetpan-android-1/include/* $(LOCAL)/include/
touch $@
libetpan-build: libetpan/Makefile
libetpan-clean:
rm -rf libetpan
#------------------------------------------------------------------------------#
# 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 && \
../../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/Makefile
$(MAKE) -C nettle
$(LOCAL)/lib/libnettle.so: nettle/libnettle.so
$(MAKE) -C nettle DESTDIR=$(DESTDIR) prefix=$(prefix) install
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 ../$<
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)" \
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

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

@ -0,0 +1,21 @@
#!/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 x86_64 --api 21 --install-dir=ndk-standalone-toolchain
exit 0

22
android/jni/Android.mk

@ -1,38 +1,39 @@
LOCAL_PATH:= $(call my-dir)
SRC_PATH := $(LOCAL_PATH)/../../../
ENGINE_PATH := $(LOCAL_PATH)/../../../pEpEngine
GPGBUILD:= $(LOCAL_PATH)/../external/data/data/security.pEp
LIB_PEP_ADAPTER_PATH:=$(SRC_PATH)/libpEpAdapter
GPGBUILD:= $(LOCAL_PATH)/../external/output/
include $(CLEAR_VARS)
LOCAL_MODULE := libiconv
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/lib/libiconv.a
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/lib/libiconv.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libsequoia_openpgp_ffi
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/lib/libsequoia_openpgp_ffi.a
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/lib/libsequoia_openpgp_ffi.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libhogweed
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/lib/libhogweed.so
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/lib/libhogweed.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libgmp
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/lib/libgmp.so
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/lib/libgmp.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libnettle
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/lib/libnettle.so
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/lib/libnettle.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libetpan
LOCAL_SRC_FILES := $(LOCAL_PATH)/../build/libetpan-android-1/libs/$(TARGET_ARCH_ABI)/libetpan.a
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/../build/libetpan-android-1/include
LOCAL_SRC_FILES := $(GPGBUILD)/$(TARGET_ARCH_ABI)/lib/libetpan.a
LOCAL_EXPORT_C_INCLUDES += $(GPGBUILD)/$(TARGET_ARCH_ABI)/include
LOCAL_EXPORT_LDLIBS := -lz
include $(PREBUILT_STATIC_LIBRARY)
@ -54,8 +55,9 @@ LOCAL_SRC_FILES := \
../../src/identity_api.cc \
../../src/jniutils.cc
LOCAL_C_INCLUDES += $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/include
LOCAL_C_INCLUDES += $(GPGBUILD)/$(TARGET_ARCH_ABI)/include
LOCAL_C_INCLUDES += $(LIB_PEP_ADAPTER_PATH)/build-android/include $(SRC_PATH)/libpEpAdapter
LOCAL_LDFLAGS = -Wl,--allow-multiple-definition
LOCAL_LDLIBS += -llog
@ -71,4 +73,4 @@ $(call import-add-path,$(SRC_PATH))
$(call import-module, pEpEngine/build-android/jni/)
$(call import-module, libpEpAdapter/build-android/jni/)
$(info $(LOCAL_PATH))
$(call import-module, pEpJNIAdapter/android/external/uuid/jni)
$(call import-module, pEpJNIAdapter/android/external/$(TARGET_ARCH_ABI)/uuid/jni)

2
android/jni/Application.mk

@ -1,6 +1,6 @@
APP_STL := c++_shared
#APP_OPTIM := debug
#APP_PLATFORM=android-18
APP_ABI := armeabi-v7a
#APP_ABI := armeabi-v7a
NDK_TOOLCHAIN_VERSION = clang
APP_UNIFIED_HEADERS=true

120
android/src-pEpJNIAdapter-android-pEpJNIAdapter~2.iml

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":pEpJNIAdapter" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../../pEp4Android" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":pEpJNIAdapter" />
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" value="3.5.0" />
<option name="LAST_KNOWN_AGP_VERSION" value="3.5.0" />
</configuration>
</facet>
<facet type="native-android-gradle" name="Native-Android-Gradle">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug-armeabi-v7a" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="PROJECT_TYPE" value="1" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../libpEpAdapter">
<sourceFolder url="file://$MODULE_DIR$/../../libpEpAdapter" isTestSource="false" />
</content>
<content url="file://$MODULE_DIR$/../../pEpEngine/asn.1">
<sourceFolder url="file://$MODULE_DIR$/../../pEpEngine/asn.1" isTestSource="false" />
</content>
<content url="file://$MODULE_DIR$/../../pEpEngine/src">
<sourceFolder url="file://$MODULE_DIR$/../../pEpEngine/src" isTestSource="false" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/external/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/external/uuid" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/jni" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<content url="file://$MODULE_DIR$/../src">
<sourceFolder url="file://$MODULE_DIR$/../src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: commons-io:commons-io:2.4@jar" level="project" />
<orderEntry type="library" name="Gradle: android-android-27" level="project" />
</component>
</module>

2
src/jniutils.cc

@ -7,7 +7,7 @@
#include <assert.h>
#include <string>
#ifdef ANDROID
#ifndef __LP64__
#include <time64.h>
#define time_t time64_t
#define timegm timegm64

14
utils/configure_openssl.sh

@ -0,0 +1,14 @@
#!/bin/bash
### 
# DONT USE IT
### 
CC=clang
TOOLCHAINS_PATH=$(python ../../../utils/ndk_toolchains_path.py --ndk ${ANDROID_NDK})
PATH=$TOOLCHAINS_PATH/bin:$PATH
ARCHITECTURE=$1
ANDROID_API=$2
echo $3
./Configure ${ARCHITECTURE} -D__ANDROID_API__=$ANDROID_API --prefix=$3

48
utils/ndk_toolchains_path.py

@ -0,0 +1,48 @@
#!/usr/bin/env python
"""
Get the toolchains path
"""
import argparse
import atexit
import inspect
import os
import shutil
import stat
import sys
import textwrap
def get_host_tag_or_die():
"""Return the host tag for this platform. Die if not supported."""
if sys.platform.startswith('linux'):
return 'linux-x86_64'
elif sys.platform == 'darwin':
return 'darwin-x86_64'
elif sys.platform == 'win32' or sys.platform == 'cygwin':
host_tag = 'windows-x86_64'
if not os.path.exists(os.path.join(NDK_DIR, 'prebuilt', host_tag)):
host_tag = 'windows'
return host_tag
sys.exit('Unsupported platform: ' + sys.platform)
def get_toolchain_path_or_die(ndk, host_tag):
"""Return the toolchain path or die."""
toolchain_path = os.path.join(ndk, 'toolchains/llvm/prebuilt',
host_tag)
if not os.path.exists(toolchain_path):
sys.exit('Could not find toolchain: {}'.format(toolchain_path))
return toolchain_path
def main():
"""Program entry point."""
parser = argparse.ArgumentParser(description='Optional app description')
parser.add_argument('--ndk', required=True,
help='The NDK Home directory')
args = parser.parse_args()
host_tag = get_host_tag_or_die()
toolchain_path = get_toolchain_path_or_die(args.ndk, host_tag)
print toolchain_path
if __name__ == '__main__':
main()
Loading…
Cancel
Save