Browse Source

JNI-81 Add x86 and x64_86 support

JNI-88
Hussein Kasem 6 years ago
parent
commit
f8d6c883d8
  1. 31
      android/build.gradle
  2. 12
      android/external/Makefile
  3. 8
      android/external/downloads/Makefile
  4. 393
      android/external/x86/Makefile
  5. 21
      android/external/x86/generate-standalone-ndk-toolchain.sh
  6. 393
      android/external/x86_64/Makefile
  7. 21
      android/external/x86_64/generate-standalone-ndk-toolchain.sh
  8. 2
      src/jniutils.cc

31
android/build.gradle

@ -2,7 +2,7 @@
def pEpEngineSrc = hasProperty('pEpEngineSrc') ? pEpEngineSrc : "../../pEpEngine"
def buildAutomatic = hasProperty('buildAutomatic') ? buildAutomatic : "true"
def pEpAppPackageName = hasProperty('pEpAppPackageName') ? pEpAppPackageName : "pep.android.k9"
def threadsToUse = hasProperty('threadsToUse') ? buildAutomatic : 2
def libetpanAndroid = file('external')
@ -14,7 +14,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
@ -80,6 +80,7 @@ android {
jniDebuggable true
externalNativeBuild {
ndkBuild {
arguments "-j${threadsToUse}"
// arguments '-B', 'NDK_DEBUG=1', 'NDEBUG=null', 'NDK_LOG=1'
}
}
@ -100,46 +101,46 @@ android {
// 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) {
task cleanExternalAssets(type:Exec) {
workingDir 'external'
commandLine 'make', 'clean-assets', 'PEP_PACKAGE_NAME='+pEpAppPackageName
commandLine 'make', 'clean-assets'
}
*/
// unzip some of the dependencies
task unzipDeps(type: Copy, dependsOn: 'buildExternal') {
from zipTree(libEtPanZip)
@ -149,7 +150,7 @@ android {
// 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

12
android/external/Makefile

@ -21,7 +21,7 @@ endif
.PHONY: all build clean clean-all
all: build-arm build-arm64
all: build-arm build-arm64 build-x86 build-x86_64
build-arm: downloads/downloads.stamp
$(MAKE) -C armeabi-v7a
@ -29,14 +29,24 @@ build-arm: downloads/downloads.stamp
build-arm64: downloads/downloads.stamp
$(MAKE) -C arm64-v8a
build-x86: downloads/downloads.stamp
$(MAKE) -C x86
build-x86_64: downloads/downloads.stamp
$(MAKE) -C x86_64
clean:
$(MAKE) -C armeabi-v7a clean
$(MAKE) -C arm64-v8a clean
$(MAKE) -C x86 clean
$(MAKE) -C x86_64 clean
clean-all:
$(MAKE) -C downloads clean
$(MAKE) -C armeabi-v7a clean-all
$(MAKE) -C arm64-v8a clean-all
$(MAKE) -C x86 clean-all
$(MAKE) -C x86_64 clean-all
downloads/downloads.stamp:
$(MAKE) -C downloads

8
android/external/downloads/Makefile

@ -16,7 +16,7 @@ include ../Makefile.conf
all: downloads.stamp
downloads.stamp: download-iconv download-uuid download-sequoia-deps download-etpan download-sequoia \
generate-ndk-arm generate-ndk-arm64
generate-ndk-arm generate-ndk-arm64 generate-ndk-x86 generate-ndk-x86_64
touch $@
generate-ndk-arm64:
@ -25,6 +25,12 @@ generate-ndk-arm64:
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

393
android/external/x86/Makefile

@ -0,0 +1,393 @@
# 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
mv libetpan/build-android/libetpan-android-1.zip ../
touch $@
libetpan-build: libetpan/Makefile
libetpan-cleanzip:
rm -f libetpan/build-android/libetpan-android-1.zip
#------------------------------------------------------------------------------#
# 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-cleanzip
clean-all: clean
rm -rf *.git
rm -rf *.stamp
#------------------------------------------------------------------------------#
.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

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

393
android/external/x86_64/Makefile

@ -0,0 +1,393 @@
# 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
mv libetpan/build-android/libetpan-android-1.zip ../
touch $@
libetpan-build: libetpan/Makefile
libetpan-cleanzip:
rm -f libetpan/build-android/libetpan-android-1.zip
#------------------------------------------------------------------------------#
# 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-cleanzip
clean-all: clean
rm -rf *.git
rm -rf *.stamp
#------------------------------------------------------------------------------#
.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

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

2
src/jniutils.cc

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

Loading…
Cancel
Save