forked from nesterenkodm/pjsip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·299 lines (252 loc) · 15.6 KB
/
build.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#!/bin/sh
# see http://stackoverflow.com/a/3915420/318790
function realpath { echo $(cd $(dirname "$1"); pwd)/$(basename "$1"); }
BUILD_DIR=$(realpath "build")
if [ ! -d ${BUILD_DIR} ]; then
mkdir ${BUILD_DIR}
fi
PJSIP_URL="http://www.pjsip.org/release/2.3/pjproject-2.3.tar.bz2"
PJSIP_ARCHIVE=${BUILD_DIR}/`basename ${PJSIP_URL}`
OPENSSL_URL="https://raw.githubusercontent.com/x2on/OpenSSL-for-iPhone/master/build-libssl.sh"
OPENSSL_DIR=${BUILD_DIR}/openssl
OPENSSL_SH=${OPENSSL_DIR}/`basename ${OPENSSL_DIR}`
copy_libs () {
DST=${1}
if [ -d pjlib/lib-${DST}/ ]; then
rm -rf pjlib/lib-${DST}/
fi
if [ ! -d pjlib/lib-${DST}/ ]; then
mkdir pjlib/lib-${DST}/
fi
cp pjlib/lib/libpj-arm-apple-darwin9.a pjlib/lib-${DST}/libpj-arm-apple-darwin9.a
if [ -d pjlib-util/lib-${DST}/ ]; then
rm -rf pjlib-util/lib-${DST}/
fi
if [ ! -d pjlib-util/lib-${DST}/ ]; then
mkdir pjlib-util/lib-${DST}/
fi
cp pjlib-util/lib/libpjlib-util-arm-apple-darwin9.a pjlib-util/lib-${DST}/libpjlib-util-arm-apple-darwin9.a
if [ -d pjmedia/lib-${DST}/ ]; then
rm -rf pjmedia/lib-${DST}/
fi
if [ ! -d pjmedia/lib-${DST}/ ]; then
mkdir pjmedia/lib-${DST}/
fi
cp pjmedia/lib/libpjmedia-arm-apple-darwin9.a pjmedia/lib-${DST}/libpjmedia-arm-apple-darwin9.a
cp pjmedia/lib/libpjmedia-audiodev-arm-apple-darwin9.a pjmedia/lib-${DST}/libpjmedia-audiodev-arm-apple-darwin9.a
cp pjmedia/lib/libpjmedia-codec-arm-apple-darwin9.a pjmedia/lib-${DST}/libpjmedia-codec-arm-apple-darwin9.a
cp pjmedia/lib/libpjmedia-videodev-arm-apple-darwin9.a pjmedia/lib-${DST}/libpjmedia-videodev-arm-apple-darwin9.a
cp pjmedia/lib/libpjsdp-arm-apple-darwin9.a pjmedia/lib-${DST}/libpjsdp-arm-apple-darwin9.a
if [ -d pjnath/lib-${DST}/ ]; then
rm -rf pjnath/lib-${DST}/
fi
if [ ! -d pjnath/lib-${DST}/ ]; then
mkdir pjnath/lib-${DST}/
fi
cp pjnath/lib/libpjnath-arm-apple-darwin9.a pjnath/lib-${DST}/libpjnath-arm-apple-darwin9.a
if [ -d pjsip/lib-${DST}/ ]; then
rm -rf pjsip/lib-${DST}/
fi
if [ ! -d pjsip/lib-${DST}/ ]; then
mkdir pjsip/lib-${DST}/
fi
cp pjsip/lib/libpjsip-arm-apple-darwin9.a pjsip/lib-${DST}/libpjsip-arm-apple-darwin9.a
cp pjsip/lib/libpjsip-simple-arm-apple-darwin9.a pjsip/lib-${DST}/libpjsip-simple-arm-apple-darwin9.a
cp pjsip/lib/libpjsip-ua-arm-apple-darwin9.a pjsip/lib-${DST}/libpjsip-ua-arm-apple-darwin9.a
cp pjsip/lib/libpjsua-arm-apple-darwin9.a pjsip/lib-${DST}/libpjsua-arm-apple-darwin9.a
cp pjsip/lib/libpjsua2-arm-apple-darwin9.a pjsip/lib-${DST}/libpjsua2-arm-apple-darwin9.a
if [ -d third_party/lib-${DST}/ ]; then
rm -rf third_party/lib-${DST}/
fi
if [ ! -d third_party/lib-${DST}/ ]; then
mkdir third_party/lib-${DST}/
fi
cp third_party/lib/libg7221codec-arm-apple-darwin9.a third_party/lib-${DST}/libg7221codec-arm-apple-darwin9.a
cp third_party/lib/libgsmcodec-arm-apple-darwin9.a third_party/lib-${DST}/libgsmcodec-arm-apple-darwin9.a
cp third_party/lib/libilbccodec-arm-apple-darwin9.a third_party/lib-${DST}/libilbccodec-arm-apple-darwin9.a
cp third_party/lib/libresample-arm-apple-darwin9.a third_party/lib-${DST}/libresample-arm-apple-darwin9.a
cp third_party/lib/libspeex-arm-apple-darwin9.a third_party/lib-${DST}/libspeex-arm-apple-darwin9.a
cp third_party/lib/libsrtp-arm-apple-darwin9.a third_party/lib-${DST}/libsrtp-arm-apple-darwin9.a
}
lipo_libs () {
xcrun -sdk iphoneos lipo -arch i386 pjlib/lib-i386/libpj-arm-apple-darwin9.a \
-arch x86_64 pjlib/lib-x86_64/libpj-arm-apple-darwin9.a \
-arch armv7 pjlib/lib-armv7/libpj-arm-apple-darwin9.a \
-arch armv7s pjlib/lib-armv7s/libpj-arm-apple-darwin9.a \
-arch arm64 pjlib/lib-arm64/libpj-arm-apple-darwin9.a \
-create -output pjlib/lib/libpj-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjlib-util/lib-i386/libpjlib-util-arm-apple-darwin9.a \
-arch x86_64 pjlib-util/lib-x86_64/libpjlib-util-arm-apple-darwin9.a \
-arch armv7 pjlib-util/lib-armv7/libpjlib-util-arm-apple-darwin9.a \
-arch armv7s pjlib-util/lib-armv7s/libpjlib-util-arm-apple-darwin9.a \
-arch arm64 pjlib-util/lib-arm64/libpjlib-util-arm-apple-darwin9.a \
-create -output pjlib-util/lib/libpjlib-util-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjmedia/lib-i386/libpjmedia-arm-apple-darwin9.a \
-arch x86_64 pjmedia/lib-x86_64/libpjmedia-arm-apple-darwin9.a \
-arch armv7 pjmedia/lib-armv7/libpjmedia-arm-apple-darwin9.a \
-arch armv7s pjmedia/lib-armv7s/libpjmedia-arm-apple-darwin9.a \
-arch arm64 pjmedia/lib-arm64/libpjmedia-arm-apple-darwin9.a \
-create -output pjmedia/lib/libpjmedia-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjmedia/lib-i386/libpjmedia-audiodev-arm-apple-darwin9.a \
-arch x86_64 pjmedia/lib-x86_64/libpjmedia-audiodev-arm-apple-darwin9.a \
-arch armv7 pjmedia/lib-armv7/libpjmedia-audiodev-arm-apple-darwin9.a \
-arch armv7s pjmedia/lib-armv7s/libpjmedia-audiodev-arm-apple-darwin9.a \
-arch arm64 pjmedia/lib-arm64/libpjmedia-audiodev-arm-apple-darwin9.a \
-create -output pjmedia/lib/libpjmedia-audiodev-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjmedia/lib-i386/libpjmedia-codec-arm-apple-darwin9.a \
-arch x86_64 pjmedia/lib-x86_64/libpjmedia-codec-arm-apple-darwin9.a \
-arch armv7 pjmedia/lib-armv7/libpjmedia-codec-arm-apple-darwin9.a \
-arch armv7s pjmedia/lib-armv7s/libpjmedia-codec-arm-apple-darwin9.a \
-arch arm64 pjmedia/lib-arm64/libpjmedia-codec-arm-apple-darwin9.a \
-create -output pjmedia/lib/libpjmedia-codec-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjmedia/lib-i386/libpjmedia-videodev-arm-apple-darwin9.a \
-arch x86_64 pjmedia/lib-x86_64/libpjmedia-videodev-arm-apple-darwin9.a \
-arch armv7 pjmedia/lib-armv7/libpjmedia-videodev-arm-apple-darwin9.a \
-arch armv7s pjmedia/lib-armv7s/libpjmedia-videodev-arm-apple-darwin9.a \
-arch arm64 pjmedia/lib-arm64/libpjmedia-videodev-arm-apple-darwin9.a \
-create -output pjmedia/lib/libpjmedia-videodev-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjmedia/lib-i386/libpjsdp-arm-apple-darwin9.a \
-arch x86_64 pjmedia/lib-x86_64/libpjsdp-arm-apple-darwin9.a \
-arch armv7 pjmedia/lib-armv7/libpjsdp-arm-apple-darwin9.a \
-arch armv7s pjmedia/lib-armv7s/libpjsdp-arm-apple-darwin9.a \
-arch arm64 pjmedia/lib-arm64/libpjsdp-arm-apple-darwin9.a \
-create -output pjmedia/lib/libpjsdp-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjnath/lib-i386/libpjnath-arm-apple-darwin9.a \
-arch x86_64 pjnath/lib-x86_64/libpjnath-arm-apple-darwin9.a \
-arch armv7 pjnath/lib-armv7/libpjnath-arm-apple-darwin9.a \
-arch armv7s pjnath/lib-armv7s/libpjnath-arm-apple-darwin9.a \
-arch arm64 pjnath/lib-arm64/libpjnath-arm-apple-darwin9.a \
-create -output pjnath/lib/libpjnath-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjsip/lib-i386/libpjsip-arm-apple-darwin9.a \
-arch x86_64 pjsip/lib-x86_64/libpjsip-arm-apple-darwin9.a \
-arch armv7 pjsip/lib-armv7/libpjsip-arm-apple-darwin9.a \
-arch armv7s pjsip/lib-armv7s/libpjsip-arm-apple-darwin9.a \
-arch arm64 pjsip/lib-arm64/libpjsip-arm-apple-darwin9.a \
-create -output pjsip/lib/libpjsip-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjsip/lib-i386/libpjsip-simple-arm-apple-darwin9.a \
-arch x86_64 pjsip/lib-x86_64/libpjsip-simple-arm-apple-darwin9.a \
-arch armv7 pjsip/lib-armv7/libpjsip-simple-arm-apple-darwin9.a \
-arch armv7s pjsip/lib-armv7s/libpjsip-simple-arm-apple-darwin9.a \
-arch arm64 pjsip/lib-arm64/libpjsip-simple-arm-apple-darwin9.a \
-create -output pjsip/lib/libpjsip-simple-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjsip/lib-i386/libpjsip-ua-arm-apple-darwin9.a \
-arch x86_64 pjsip/lib-x86_64/libpjsip-ua-arm-apple-darwin9.a \
-arch armv7 pjsip/lib-armv7/libpjsip-ua-arm-apple-darwin9.a \
-arch armv7s pjsip/lib-armv7s/libpjsip-ua-arm-apple-darwin9.a \
-arch arm64 pjsip/lib-arm64/libpjsip-ua-arm-apple-darwin9.a \
-create -output pjsip/lib/libpjsip-ua-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjsip/lib-i386/libpjsua-arm-apple-darwin9.a \
-arch x86_64 pjsip/lib-x86_64/libpjsua-arm-apple-darwin9.a \
-arch armv7 pjsip/lib-armv7/libpjsua-arm-apple-darwin9.a \
-arch armv7s pjsip/lib-armv7s/libpjsua-arm-apple-darwin9.a \
-arch arm64 pjsip/lib-arm64/libpjsua-arm-apple-darwin9.a \
-create -output pjsip/lib/libpjsua-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 pjsip/lib-i386/libpjsua2-arm-apple-darwin9.a \
-arch x86_64 pjsip/lib-x86_64/libpjsua2-arm-apple-darwin9.a \
-arch armv7 pjsip/lib-armv7/libpjsua2-arm-apple-darwin9.a \
-arch armv7s pjsip/lib-armv7s/libpjsua2-arm-apple-darwin9.a \
-arch arm64 pjsip/lib-arm64/libpjsua2-arm-apple-darwin9.a \
-create -output pjsip/lib/libpjsua2-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 third_party/lib-i386/libg7221codec-arm-apple-darwin9.a \
-arch x86_64 third_party/lib-x86_64/libg7221codec-arm-apple-darwin9.a \
-arch armv7 third_party/lib-armv7/libg7221codec-arm-apple-darwin9.a \
-arch armv7s third_party/lib-armv7s/libg7221codec-arm-apple-darwin9.a \
-arch arm64 third_party/lib-arm64/libg7221codec-arm-apple-darwin9.a \
-create -output third_party/lib/libg7221codec-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 third_party/lib-i386/libgsmcodec-arm-apple-darwin9.a \
-arch x86_64 third_party/lib-x86_64/libgsmcodec-arm-apple-darwin9.a \
-arch armv7 third_party/lib-armv7/libgsmcodec-arm-apple-darwin9.a \
-arch armv7s third_party/lib-armv7s/libgsmcodec-arm-apple-darwin9.a \
-arch arm64 third_party/lib-arm64/libgsmcodec-arm-apple-darwin9.a \
-create -output third_party/lib/libgsmcodec-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 third_party/lib-i386/libilbccodec-arm-apple-darwin9.a \
-arch x86_64 third_party/lib-x86_64/libilbccodec-arm-apple-darwin9.a \
-arch armv7 third_party/lib-armv7/libilbccodec-arm-apple-darwin9.a \
-arch armv7s third_party/lib-armv7s/libilbccodec-arm-apple-darwin9.a \
-arch arm64 third_party/lib-arm64/libilbccodec-arm-apple-darwin9.a \
-create -output third_party/lib/libilbccodec-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 third_party/lib-i386/libresample-arm-apple-darwin9.a \
-arch x86_64 third_party/lib-x86_64/libresample-arm-apple-darwin9.a \
-arch armv7 third_party/lib-armv7/libresample-arm-apple-darwin9.a \
-arch armv7s third_party/lib-armv7s/libresample-arm-apple-darwin9.a \
-arch arm64 third_party/lib-arm64/libresample-arm-apple-darwin9.a \
-create -output third_party/lib/libresample-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 third_party/lib-i386/libspeex-arm-apple-darwin9.a \
-arch x86_64 third_party/lib-x86_64/libspeex-arm-apple-darwin9.a \
-arch armv7 third_party/lib-armv7/libspeex-arm-apple-darwin9.a \
-arch armv7s third_party/lib-armv7s/libspeex-arm-apple-darwin9.a \
-arch arm64 third_party/lib-arm64/libspeex-arm-apple-darwin9.a \
-create -output third_party/lib/libspeex-arm-apple-darwin9.a
xcrun -sdk iphoneos lipo -arch i386 third_party/lib-i386/libsrtp-arm-apple-darwin9.a \
-arch x86_64 third_party/lib-x86_64/libsrtp-arm-apple-darwin9.a \
-arch armv7 third_party/lib-armv7/libsrtp-arm-apple-darwin9.a \
-arch armv7s third_party/lib-armv7s/libsrtp-arm-apple-darwin9.a \
-arch arm64 third_party/lib-arm64/libsrtp-arm-apple-darwin9.a \
-create -output third_party/lib/libsrtp-arm-apple-darwin9.a
}
if [ ! -f ${OPENSSL_SH} ]; then
echo "Downloading openssl..."
curl -# --create-dirs -o ${OPENSSL_SH} ${OPENSSL_URL}
fi
if [ ! -f "${OPENSSL_DIR}/lib/libssl.a" ]; then
pushd . > /dev/null
cd ${OPENSSL_DIR}
/bin/sh ${OPENSSL_SH}
popd > /dev/null
else
echo "Using OpenSSL..."
fi
if [ ! -f ${PJSIP_ARCHIVE} ]; then
echo "Downloading pjsip..."
curl -# -o ${PJSIP_ARCHIVE} ${PJSIP_URL}
fi
PJSIP_NAME=`tar tzf ${PJSIP_ARCHIVE} | sed -e 's@/.*@@' | uniq`
PJSIP_DIR=${BUILD_DIR}/${PJSIP_NAME}
echo "Using ${PJSIP_NAME}..."
if [ -d ${PJSIP_DIR} ]; then
echo "Cleaning up..."
rm -rf ${PJSIP_DIR}
fi
echo "Unarchiving..."
pushd . > /dev/null
cd ${BUILD_DIR}
tar -xf ${PJSIP_ARCHIVE}
popd > /dev/null
echo "Creating config.h..."
echo "#define PJ_CONFIG_IPHONE 1
#include <pj/config_site_sample.h>" > ${PJSIP_DIR}/pjlib/include/pj/config_site.h
export CFLAGS="-I${OPENSSL_DIR}/include"
export LDFLAGS="-L${OPENSSL_DIR}/lib"
configure="./configure-iphone --with-ssl=${OPENSSL_DIR}"
cd ${PJSIP_DIR}
function _build() {
ARCH=$1
LOG=${BUILD_DIR}/${ARCH}.log
echo "Building for ${ARCH}..."
make distclean > ${LOG} 2>&1
ARCH="-arch ${ARCH}" ./configure-iphone --with-ssl=${OPENSSL_DIR} >> ${LOG} 2>&1
make dep >> ${LOG} 2>&1
make clean >> ${LOG}
make >> ${LOG} 2>&1
copy_libs ${ARCH}
}
function armv7() { _build "armv7"; }
function armv7s() { _build "armv7s"; }
function arm64() { _build "arm64"; }
function i386() {
export DEVPATH="`xcrun -sdk iphonesimulator --show-sdk-platform-path`/Developer"
export CFLAGS="-I${OPENSSL_DIR}/include -O2 -m32 -mios-simulator-version-min=7.0"
export LDFLAGS="-L${OPENSSL_DIR}/lib -O2 -m32 -mios-simulator-version-min=7.0"
_build "i386"
}
function x86_64() {
export DEVPATH="`xcrun -sdk iphonesimulator --show-sdk-platform-path`/Developer"
export CFLAGS="-I${OPENSSL_DIR}/include -O2 -m32 -mios-simulator-version-min=7.0"
export LDFLAGS="-L${OPENSSL_DIR}/lib -O2 -m32 -mios-simulator-version-min=7.0"
_build "x86_64"
}
armv7 && armv7s && arm64 && i386 && x86_64
echo "Making universal lib..."
make distclean > /dev/null
lipo_libs
echo "Done"