-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_android_openssl.sh
executable file
·76 lines (66 loc) · 1.38 KB
/
build_android_openssl.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
#!/usr/bin/env bash
_ARCH=""
_HOST=""
function usage() {
echo
echo "usage: $1 <-a arch to build: android-arm, android-arm64, ...>"
echo
}
while getopts "a:" arg; do
case $arg in
a)
_ARCH="${OPTARG}"
;;
*)
usage "$0"
exit 1
;;
esac
done
# check running os
case "$(uname -s)" in
Darwin)
_HOST=darwin-x86_64
;;
Linux)
_HOST=linux-x86_64
echo 'Linux'
;;
esac
# android ndk must be installed somewhere
if [ -z "$ANDROID_NDK_ROOT" ]; then
echo "[!] ANDROID_NDK_ROOT must be set to point to the Android NDK (min r21d) !"
exit 1
fi
if [ -z "$_ARCH" ]; then
usage "$0"
exit 1
fi
_PWD=$(pwd)
# (download and) build openssl
if [ ! -d ./openssl ]; then
echo "[.] downloading openssl from github"
git clone https://github.com/openssl/openssl
if [ "$?" -ne 0 ]; then
exit 1
fi
fi
cd ./openssl
make clean
rm -rf "../build/openssl-$_ARCH"
mkdir -p "../build/openssl-$_ARCH"
_prefix=$(realpath "../build/openssl-$_ARCH")
PATH="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$_HOST/bin:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/$_HOST/bin:$PATH"
./Configure "$_ARCH" -D__ANDROID_API__=22 --prefix="$_prefix"
if [ "$?" -ne 0 ]; then
cd "$_PWD"
exit 1
fi
make -j4
if [ "$?" -ne 0 ]; then
cd "$_PWD"
exit 1
fi
# copy to output dir
make install
cd "$_PWD"