This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathbuild-osx-ios.sh
executable file
·146 lines (112 loc) · 3.34 KB
/
build-osx-ios.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#
# References:
# https://gist.github.com/Norod/2f3ef9b6e3758dfc1433
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
set -e
# SDK version:
SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 -d ':' | tr -d '[[:space:]]')
# Min iOS deployment target version:
MIN_IOS_VERSION="7.0"
OPENSSL_CONFIG_OPTIONS=$(cat config-params.txt)
build_osx() {
ARCH=$1
echo "Building osx libcrypto.a for ${ARCH}"
cd vendor/openssl
git clean -dfx && git checkout -f
# define temp output directory:
TMP_OUTPUT_DIR="/tmp/openssl-osx-${ARCH}"
rm -rf ${TMP_OUTPUT_DIR}
mkdir ${TMP_OUTPUT_DIR}
export CC="/usr/bin/clang"
TARGET="darwin-i386-cc"
if [[ $ARCH == "x86_64" ]]; then
TARGET="darwin64-x86_64-cc"
fi
# Config:
./Configure dist
./Configure ${TARGET} ${OPENSSL_CONFIG_OPTIONS} --openssldir="${TMP_OUTPUT_DIR} -fPIC"
# Remove test:
rm -rf test
# Make depend:
make depend
# Make libcrypto:
make build_crypto
# Copy libcrypto.a to temp output directory:
file libcrypto.a
cp libcrypto.a ${TMP_OUTPUT_DIR}
# Cleanup:
git clean -dfx && git checkout -f
cd ../../
}
build_ios() {
ARCH=$1
echo "Building ios libcrypto.a for ${ARCH}"
cd vendor/openssl
git clean -dfx && git checkout -f
# define temp output directory:
TMP_OUTPUT_DIR="/tmp/openssl-ios-${ARCH}"
rm -rf ${TMP_OUTPUT_DIR}
mkdir ${TMP_OUTPUT_DIR}
DEVELOPER=`xcode-select -print-path`
export BUILD_TOOLS="${DEVELOPER}"
PLATFORM=""
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
fi
export $PLATFORM
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc -fembed-bitcode -mios-version-min=${MIN_IOS_VERSION} -arch ${ARCH}"
TARGET="iphoneos-cross"
if [[ "${ARCH}" == "x86_64" ]]; then
TARGET="darwin64-x86_64-cc"
fi
# Config:
./Configure dist
./Configure ${TARGET} ${OPENSSL_CONFIG_OPTIONS} --openssldir="${output_tmp_dir} -fPIC"
# Remove test:
rm -rf test
# Make depend:
sudo make depend
# Make libcrypto:
make build_crypto
# Copy libcrypto.a to temp output directory:
file libcrypto.a
cp libcrypto.a ${TMP_OUTPUT_DIR}
# Cleanup:
git clean -dfx && git checkout -f
cd ../../
}
# Build OSX binaries:
OUTPUT_DIR="libs/osx"
rm -rf ${OUTPUT_DIR}
mkdir ${OUTPUT_DIR}
build_osx "i386"
build_osx "x86_64"
# Create fat binaries:
BASE_TMP_OUTPUT_DIR="/tmp/openssl-osx"
lipo \
"${BASE_TMP_OUTPUT_DIR}-i386/libcrypto.a" \
"${BASE_TMP_OUTPUT_DIR}-x86_64/libcrypto.a" \
-create -output ${OUTPUT_DIR}/libcrypto.a
# # Build iOS binaries:
# OUTPUT_DIR="libs/ios"
# rm -rf ${OUTPUT_DIR}
# mkdir ${OUTPUT_DIR}
# build_ios "armv7"
# build_ios "arm64"
# build_ios "x86_64"
# build_ios "i386"
# # Create fat binaries:
# BASE_TMP_OUTPUT_DIR="/tmp/openssl-ios"
# lipo \
# "${BASE_TMP_OUTPUT_DIR}-armv7/libcrypto.a" \
# "${BASE_TMP_OUTPUT_DIR}-arm64/libcrypto.a" \
# "${BASE_TMP_OUTPUT_DIR}-i386/libcrypto.a" \
# "${BASE_TMP_OUTPUT_DIR}-x86_64/libcrypto.a" \
# -create -output ${OUTPUT_DIR}/libcrypto.a