forked from DimaRU/Libssh2Prebuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-libssh2.sh
executable file
·98 lines (79 loc) · 2.85 KB
/
build-libssh2.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
#!/bin/bash
#
# build-libssh2.sh
# Copyright © 2020 Dmitriy Borovikov. All rights reserved.
#
source "$ROOT_PATH/script/build-commons"
set -e
if [[ -f "$BUILT_PRODUCTS_DIR/lib/libssh2.a" ]]; then
echo "$PLATFORM libssh2 already build"
exit 0
fi
CLANG=$(xcrun --find clang)
export CLANG
DEVELOPER=$(xcode-select --print-path)
export DEVELOPER
mkdir -p "$BUILT_PRODUCTS_DIR"
for ARCH in $ARCHS
do
OPENSSLDIR="$BUILT_PRODUCTS_DIR/"
PLATFORM_SRC="$LIBSSHDIR/${PLATFORM}$EFFECTIVE_PLATFORM_NAME-$ARCH/src"
PLATFORM_OUT="$LIBSSHDIR/${PLATFORM}$EFFECTIVE_PLATFORM_NAME-$ARCH/install"
LOG="$BUILT_PRODUCTS_DIR/$PLATFORM$EFFECTIVE_PLATFORM_NAME-$ARCH-libssh2-build.log"
LIPO_SSH2="$LIPO_SSH2 $PLATFORM_OUT/lib/libssh2.a"
mkdir -p "$PLATFORM_SRC"
mkdir -p "$PLATFORM_OUT"
cp -R "$LIBSSH_SOURCE" "$PLATFORM_SRC"
cd "$PLATFORM_SRC"
touch "$LOG"
echo "LOG: $LOG"
if [[ "$ARCH" == arm64* ]]; then
HOST="aarch64-apple-darwin"
else
HOST="$ARCH-apple-darwin"
fi
export DEVROOT="$DEVELOPER/Platforms/$PLATFORM.platform/Developer"
export SDKROOT="$DEVROOT/SDKs/$PLATFORM.sdk"
export CC="$CLANG"
export CPP="$CLANG -E"
export CFLAGS="-arch $ARCH -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPPFLAGS="-arch $ARCH -pipe -no-cpp-precomp -isysroot $SDKROOT"
if [[ "$SDK_PLATFORM" != "xros" ]] && [[ "$SDK_PLATFORM" != "xrsimulator" ]]; then
export CFLAGS="$CFLAGS -m$SDK_PLATFORM-version-min=$MIN_VERSION"
export CPPFLAGS="$CPPFLAGS -m$SDK_PLATFORM-version-min=$MIN_VERSION"
fi
if [[ "$EFFECTIVE_PLATFORM_NAME" == "-maccatalyst" ]]; then
EXTRAFLAGS="-target $ARCH-apple-ios13.1-macabi -Wno-overriding-t-option"
CFLAGS="${CFLAGS} ${EXTRAFLAGS}"
CPPFLAGS="${CPPFLAGS} ${EXTRAFLAGS}"
fi
if [[ $(./configure --help | grep -c -- --with-openssl) -eq 0 ]]; then
CRYPTO_BACKEND_OPTION="--with-crypto=openssl"
else
CRYPTO_BACKEND_OPTION="--with-openssl"
fi
{
{
./configure \
--host="$HOST" \
--prefix="$PLATFORM_OUT" \
--enable-debug \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-examples-build \
--without-libz "$CRYPTO_BACKEND_OPTION" \
--with-libssl-prefix="$OPENSSLDIR" \
--disable-shared \
--enable-static
} >> "$LOG"
} 2>&1
make >> "$LOG" 2>&1
make -j "$BUILD_THREADS" install >> "$LOG" 2>&1
echo "Libssh2 - $PLATFORM $ARCH done."
done
buildFatLibrary "$LIPO_SSH2" "$BUILT_PRODUCTS_DIR/lib/libssh.a"
copyHeaders "$LIBSSH_SOURCE/include/" "$BUILT_PRODUCTS_DIR/include"
cp "$ROOT_PATH/script/module.modulemap" "$BUILT_PRODUCTS_DIR/include"
cd "$BUILT_PRODUCTS_DIR/lib"
libtool -static -D -o libssh2.a libssh.a libssl.a libcrypto.a >> "$LOG" 2>&1
echo "Libssh2 - $PLATFORM done."