-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
iSSH2-openssl.sh
executable file
·115 lines (91 loc) · 4.24 KB
/
iSSH2-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
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
#!/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. #
################################################################################
XCODE_VERSION=`xcodebuild -version | grep Xcode | cut -d' ' -f2`
version () {
printf "%02d%02d%02d" ${1//./ }
}
source "$BASEPATH/iSSH2-commons"
set -e
mkdir -p "$LIBSSLDIR"
LIBSSL_TAR="openssl-$LIBSSL_VERSION.tar.gz"
downloadFile "https://www.openssl.org/source/$LIBSSL_TAR" "$LIBSSLDIR/$LIBSSL_TAR"
LIBSSLSRC="$LIBSSLDIR/src/"
mkdir -p "$LIBSSLSRC"
set +e
echo "Extracting $LIBSSL_TAR"
tar -zxkf "$LIBSSLDIR/$LIBSSL_TAR" -C "$LIBSSLSRC" --strip-components 1 2>&-
set -e
echo "Building OpenSSL $LIBSSL_VERSION, please wait..."
for ARCH in $ARCHS
do
if [[ "$SDK_PLATFORM" == "macosx" ]]; then
CONF="no-shared"
else
CONF="no-asm no-hw no-shared no-async"
fi
PLATFORM="$(platformName "$SDK_PLATFORM" "$ARCH")"
OPENSSLDIR="$LIBSSLDIR/${PLATFORM}_$SDK_VERSION-$ARCH"
LIPO_LIBSSL="$LIPO_LIBSSL $OPENSSLDIR/libssl.a"
LIPO_LIBCRYPTO="$LIPO_LIBCRYPTO $OPENSSLDIR/libcrypto.a"
if [[ -f "$OPENSSLDIR/libssl.a" ]] && [[ -f "$OPENSSLDIR/libcrypto.a" ]]; then
echo "libssl.a and libcrypto.a for $ARCH already exist."
else
rm -rf "$OPENSSLDIR"
cp -R "$LIBSSLSRC" "$OPENSSLDIR"
cd "$OPENSSLDIR"
LOG="$OPENSSLDIR/build-openssl.log"
touch $LOG
if [[ "$SDK_PLATFORM" == "macosx" ]]; then
if [[ "$ARCH" == "x86_64" ]]; then
HOST="darwin64-x86_64-cc"
elif [[ "$ARCH" == "arm64" ]] && [[ $(version "$XCODE_VERSION") -ge $(version "12.0") ]]; then
HOST="darwin64-arm64-cc"
else
HOST="darwin-$ARCH-cc"
fi
else
HOST="iphoneos-cross"
if [[ "${ARCH}" == *64 ]] || [[ "${ARCH}" == arm64* ]]; then
CONF="$CONF enable-ec_nistp_64_gcc_128"
fi
fi
export CROSS_TOP="$DEVELOPER/Platforms/$PLATFORM.platform/Developer"
export CROSS_SDK="$PLATFORM$SDK_VERSION.sdk"
export SDKROOT="$CROSS_TOP/SDKs/$CROSS_SDK"
export CC="$CLANG -arch $ARCH"
CONF="$CONF -m$SDK_PLATFORM-version-min=$MIN_VERSION $EMBED_BITCODE"
./Configure $HOST $CONF >> "$LOG" 2>&1
if [[ "$ARCH" == "x86_64" ]]; then
sed -ie "s!^CFLAG=!CFLAG=-isysroot $SDKROOT !" "Makefile"
fi
make depend >> "$LOG" 2>&1
make -j "$BUILD_THREADS" build_libs >> "$LOG" 2>&1
echo "- $PLATFORM $ARCH done!"
fi
done
lipoFatLibrary "$LIPO_LIBSSL" "$BASEPATH/openssl_$SDK_PLATFORM/lib/libssl.a"
lipoFatLibrary "$LIPO_LIBCRYPTO" "$BASEPATH/openssl_$SDK_PLATFORM/lib/libcrypto.a"
importHeaders "$OPENSSLDIR/include/" "$BASEPATH/openssl_$SDK_PLATFORM/include"
echo "Building done."