forked from sqlcipher/android-database-sqlcipher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-openssl-libraries.sh
executable file
·116 lines (104 loc) · 3.96 KB
/
build-openssl-libraries.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#! /usr/bin/env bash
(cd external/openssl;
if [ ! ${ANDROID_NDK_ROOT} ]; then
echo "ANDROID_NDK_ROOT environment variable not set, set and rerun"
exit 1
fi
ANDROID_LIB_ROOT=../android-libs
ANDROID_TOOLCHAIN_DIR=/tmp/sqlcipher-android-toolchain
OPENSSL_CONFIGURE_OPTIONS="no-krb5 no-idea no-camellia \
no-seed no-bf no-cast no-rc2 no-rc4 no-rc5 no-md2 \
no-md4 no-ripemd no-rsa no-ecdh no-sock no-ssl2 no-ssl3 \
no-dsa no-dh no-ec no-ecdsa no-tls1 no-pbe no-pkcs \
no-tlsext no-pem no-rfc3779 no-whirlpool no-ui no-srp \
no-ssltrace no-tlsext no-mdc2 no-ecdh no-engine \
no-tls2 no-srtp -fPIC"
HOST_INFO=`uname -a`
case ${HOST_INFO} in
Darwin*)
TOOLCHAIN_SYSTEM=darwin-x86
;;
Linux*)
if [[ "${HOST_INFO}" == *i686* ]]
then
TOOLCHAIN_SYSTEM=linux-x86
else
TOOLCHAIN_SYSTEM=linux-x86_64
fi
;;
*)
echo "Toolchain unknown for host system"
exit 1
;;
esac
rm -rf ${ANDROID_LIB_ROOT}
git clean -dfx && git checkout -f
./Configure dist
for SQLCIPHER_TARGET_PLATFORM in armeabi armeabi-v7a x86 x86_64 arm64-v8a
do
echo "Building for libcrypto.a for ${SQLCIPHER_TARGET_PLATFORM}"
case "${SQLCIPHER_TARGET_PLATFORM}" in
armeabi)
TOOLCHAIN_ARCH=arm
TOOLCHAIN_PREFIX=arm-linux-androideabi
CONFIGURE_ARCH=android
PLATFORM_OUTPUT_DIR=armeabi
ANDROID_PLATFORM_VERSION=android-9
;;
armeabi-v7a)
TOOLCHAIN_ARCH=arm
TOOLCHAIN_PREFIX=arm-linux-androideabi
CONFIGURE_ARCH=android -march=armv7-a
PLATFORM_OUTPUT_DIR=armeabi-v7a
ANDROID_PLATFORM_VERSION=android-9
;;
x86)
TOOLCHAIN_ARCH=x86
TOOLCHAIN_PREFIX=i686-linux-android
CONFIGURE_ARCH=android-x86
PLATFORM_OUTPUT_DIR=x86
ANDROID_PLATFORM_VERSION=android-9
;;
x86_64)
TOOLCHAIN_ARCH=x86_64
TOOLCHAIN_PREFIX=x86_64-linux-android
CONFIGURE_ARCH=android64
PLATFORM_OUTPUT_DIR=x86_64
ANDROID_PLATFORM_VERSION=android-21
;;
arm64-v8a)
TOOLCHAIN_ARCH=arm64
TOOLCHAIN_PREFIX=aarch64-linux-android
CONFIGURE_ARCH=android64-aarch64
PLATFORM_OUTPUT_DIR=arm64-v8a
ANDROID_PLATFORM_VERSION=android-21
;;
*)
echo "Unsupported build platform:${SQLCIPHER_TARGET_PLATFORM}"
exit 1
esac
rm -rf ${ANDROID_TOOLCHAIN_DIR}
mkdir -p "${ANDROID_LIB_ROOT}/${SQLCIPHER_TARGET_PLATFORM}"
${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \
--platform=${ANDROID_PLATFORM_VERSION} \
--install-dir=${ANDROID_TOOLCHAIN_DIR} \
--arch=${TOOLCHAIN_ARCH}
export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH
export CROSS_SYSROOT=${ANDROID_TOOLCHAIN_DIR}/sysroot
RANLIB=${TOOLCHAIN_PREFIX}-ranlib \
AR=${TOOLCHAIN_PREFIX}-ar \
CC=${TOOLCHAIN_PREFIX}-gcc \
./Configure "${CONFIGURE_ARCH}" "${OPENSSL_CONFIGURE_OPTIONS}"
if [ $? -ne 0 ]; then
echo "Error executing:./Configure ${CONFIGURE_ARCH} ${OPENSSL_CONFIGURE_OPTIONS}"
exit 1
fi
make clean
make
if [ $? -ne 0 ]; then
echo "Error executing make for platform:${SQLCIPHER_TARGET_PLATFORM}"
exit 1
fi
mv libcrypto.a ${ANDROID_LIB_ROOT}/${PLATFORM_OUTPUT_DIR}
done
)