forked from sqlcipher/android-database-sqlcipher
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-openssl-libraries.sh
executable file
·160 lines (123 loc) · 4.63 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#! /usr/bin/env sh
(cd external/openssl;
if [ ! ${ANDROID_NDK_ROOT} ]; then
echo "ANDROID_NDK_ROOT environment variable not set, set and rerun"
exit 1
fi
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 ../android-libs/armeabi/libcrypto.a \
../android-libs/x86/libcrypto.a \
../android-libs/arm64-v8a/libcrypto.a \
../android-libs/x86_64/libcrypto.a
git clean -dfx && git checkout -f
./Configure dist
ANDROID_PLATFORM_VERSION=android-19
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"
# arm build
${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \
--platform=${ANDROID_PLATFORM_VERSION} \
--install-dir=${ANDROID_TOOLCHAIN_DIR} \
--system=${TOOLCHAIN_SYSTEM} \
--arch=arm
export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH
RANLIB=arm-linux-androideabi-ranlib \
AR=arm-linux-androideabi-ar \
CC=arm-linux-androideabi-gcc \
./Configure android ${OPENSSL_CONFIGURE_OPTIONS}
make clean
make build_crypto
mv libcrypto.a ../android-libs/armeabi/
rm -rf ${ANDROID_TOOLCHAIN_DIR}
#armv7 build
${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \
--platform=${ANDROID_PLATFORM_VERSION} \
--install-dir=${ANDROID_TOOLCHAIN_DIR} \
--system=${TOOLCHAIN_SYSTEM} \
--arch=arm
export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH
RANLIB=arm-linux-androideabi-ranlib \
AR=arm-linux-androideabi-ar \
CC=arm-linux-androideabi-gcc \
./Configure android-armv7 ${OPENSSL_CONFIGURE_OPTIONS}
make clean
make build_crypto
mv libcrypto.a ../android-libs/armeabi-v7a/
rm -rf ${ANDROID_TOOLCHAIN_DIR}
# x86 build
${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \
--platform=${ANDROID_PLATFORM_VERSION} \
--install-dir=${ANDROID_TOOLCHAIN_DIR} \
--system=${TOOLCHAIN_SYSTEM} \
--arch=x86
export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH
RANLIB=i686-linux-android-ranlib \
AR=i686-linux-android-ar \
CC=i686-linux-android-gcc \
./Configure android-x86 ${OPENSSL_CONFIGURE_OPTIONS}
make clean
make build_crypto
mv libcrypto.a ../android-libs/x86/
rm -rf ${ANDROID_TOOLCHAIN_DIR}
make clean
git clean -dfx && git checkout -f
# Patch openssl to support building for arm64-v8a && x86_64
# Note, we only patch the Configure script
patch -p1 < ../../openssl_android_64_bit_support.patch
# arm64-v8a build
ANDROID_PLATFORM_VERSION=android-21
${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \
--platform=${ANDROID_PLATFORM_VERSION} \
--install-dir=${ANDROID_TOOLCHAIN_DIR} \
--system=${TOOLCHAIN_SYSTEM} \
--arch=arm64
export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH
RANLIB=aarch64-linux-android-ranlib \
AR=aarch64-linux-android-ar \
CC=aarch64-linux-android-gcc \
./Configure android-aarch64 ${OPENSSL_EXCLUSION_LIST}
make build_crypto
mv libcrypto.a ../android-libs/arm64-v8a/
rm -rf ${ANDROID_TOOLCHAIN_DIR}
make clean
git clean -dfx && git checkout -f
patch -p1 < ../../openssl_android_64_bit_support.patch
# x86_64 build
ANDROID_PLATFORM_VERSION=android-21
${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \
--platform=${ANDROID_PLATFORM_VERSION} \
--install-dir=${ANDROID_TOOLCHAIN_DIR} \
--system=${TOOLCHAIN_SYSTEM} \
--arch=x86_64
export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH
RANLIB=x86_64-linux-android-ranlib \
AR=x86_64-linux-android-ar \
CC=x86_64-linux-android-gcc \
./Configure android-x86_64 ${OPENSSL_EXCLUSION_LIST}
make build_crypto
mv libcrypto.a ../android-libs/x86_64/
rm -rf ${ANDROID_TOOLCHAIN_DIR}
)