-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_libssh_linux.sh
executable file
·80 lines (63 loc) · 2.06 KB
/
build_libssh_linux.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
#!/bin/bash
set -e
# config
ANDROID_API="arm64-v8a"
API_LEVEL=21
ANDROID_SDK_PATH="/home/andrey/Android/Sdk"
BUILD_SHARED_LIB=0
ANDROID_NDK_ROOT="${ANDROID_SDK_PATH}/ndk/20.0.5594570"
#
if [[ "$1" != "" ]]; then
ANDROID_API="$1"
fi
NDK_TOOLCHAIN_PATH="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake"
OUTPUT_LIBS_DIR="libs/${ANDROID_API}"
if [[ "$BUILD_SHARED_LIB" -eq "1" ]]
then
libs_files_extension="so"
build_static_libssh=0
else
libs_files_extension="a"
build_static_libssh=1
fi
rm boringssl_build_dir_${ANDROID_API} -R || true
mkdir boringssl_build_dir_${ANDROID_API}
cd boringssl_build_dir_${ANDROID_API}
cmake -DANDROID_ABI=${ANDROID_API} \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake \
-DANDROID_NATIVE_API_LEVEL=${API_LEVEL} \
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIB} \
-GNinja \
../boringssl
ninja -j4
cd ..
mkdir libs || true
rm ${OUTPUT_LIBS_DIR} -R || true
mkdir ${OUTPUT_LIBS_DIR}
cp boringssl_build_dir_${ANDROID_API}/crypto/libcrypto.${libs_files_extension} ${OUTPUT_LIBS_DIR}
cp boringssl_build_dir_${ANDROID_API}/decrepit/libdecrepit.${libs_files_extension} ${OUTPUT_LIBS_DIR}
cp boringssl_build_dir_${ANDROID_API}/ssl/libssl.${libs_files_extension} ${OUTPUT_LIBS_DIR}
rm libssh_build_dir_${ANDROID_API} -R || true
mkdir libssh_build_dir_${ANDROID_API}
cd libssh_build_dir_${ANDROID_API}
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/libssh-android \
-DWITH_INTERNAL_DOC=OFF \
-DWITH_GSSAPI=OFF \
-DWITH_NACL=OFF \
-DWITH_EXAMPLES=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${NDK_TOOLCHAIN_PATH} \
-DANDROID_NDK=${ANDROID_NDK_ROOT} \
-DANDROID_NATIVE_API_LEVEL=android-${API_LEVEL} \
-DANDROID_ABI=${ANDROID_API} \
-DBUILD_STATIC_LIB=${build_static_libssh} \
-DBUILT_LIBS_DIR=${OUTPUT_LIBS_DIR} \
-DWITH_ZLIB=1 \
-DWITH_SERVER=1 \
-DWITH_SFTP=1 \
..
cmake --build .
cd ..
cp libssh_build_dir_${ANDROID_API}/libssh-boringssl-compat.a ${OUTPUT_LIBS_DIR}
cp libssh_build_dir_${ANDROID_API}/libssh/src/libssh.${libs_files_extension} ${OUTPUT_LIBS_DIR}