-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
iSSH2-libssh2.sh
executable file
·98 lines (78 loc) · 4.08 KB
/
iSSH2-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
#########
#################################### iSSH2 #####################################
# ######### #
# Copyright (c) 2013 Tommaso Madonia. All rights reserved. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal#
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,#
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN #
# THE SOFTWARE. #
################################################################################
source "$BASEPATH/iSSH2-commons"
set -e
mkdir -p "$LIBSSHDIR"
LIBSSH_TAR="libssh2-$LIBSSH_VERSION.tar.gz"
downloadFile "http://www.libssh2.org/download/$LIBSSH_TAR" "$LIBSSHDIR/$LIBSSH_TAR"
LIBSSHSRC="$LIBSSHDIR/src/"
mkdir -p "$LIBSSHSRC"
set +e
echo "Extracting $LIBSSH_TAR"
tar -zxkf "$LIBSSHDIR/$LIBSSH_TAR" -C "$LIBSSHDIR/src" --strip-components 1 2>&-
set -e
echo "Building Libssh2 $LIBSSH_VERSION:"
for ARCH in $ARCHS
do
PLATFORM="$(platformName "$SDK_PLATFORM" "$ARCH")"
OPENSSLDIR="$BASEPATH/openssl_$SDK_PLATFORM/"
PLATFORM_SRC="$LIBSSHDIR/${PLATFORM}_$SDK_VERSION-$ARCH/src"
PLATFORM_OUT="$LIBSSHDIR/${PLATFORM}_$SDK_VERSION-$ARCH/install"
LIPO_SSH2="$LIPO_SSH2 $PLATFORM_OUT/lib/libssh2.a"
if [[ -f "$PLATFORM_OUT/lib/libssh2.a" ]]; then
echo "libssh2.a for $ARCH already exists."
else
rm -rf "$PLATFORM_SRC"
rm -rf "$PLATFORM_OUT"
mkdir -p "$PLATFORM_OUT"
cp -R "$LIBSSHSRC" "$PLATFORM_SRC"
cd "$PLATFORM_SRC"
LOG="$PLATFORM_OUT/build-libssh2.log"
touch $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_VERSION.sdk"
export CC="$CLANG"
export CPP="$CLANG -E"
export CFLAGS="-arch $ARCH -pipe -no-cpp-precomp -isysroot $SDKROOT -m$SDK_PLATFORM-version-min=$MIN_VERSION $EMBED_BITCODE"
export CPPFLAGS="-arch $ARCH -pipe -no-cpp-precomp -isysroot $SDKROOT -m$SDK_PLATFORM-version-min=$MIN_VERSION"
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" --disable-debug --disable-dependency-tracking --disable-silent-rules --disable-examples-build --with-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 "- $PLATFORM $ARCH done!"
fi
done
lipoFatLibrary "$LIPO_SSH2" "$BASEPATH/libssh2_$SDK_PLATFORM/lib/libssh2.a"
importHeaders "$LIBSSHSRC/include/" "$BASEPATH/libssh2_$SDK_PLATFORM/include"
echo "Building done."