-
Notifications
You must be signed in to change notification settings - Fork 135
/
prepare-build-system
executable file
·256 lines (226 loc) · 7.16 KB
/
prepare-build-system
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
#!/bin/bash -e
. config.conf
# Check if script is run with sudo privileges
HAS_PRIVILEGES=$(id -u)
if [ $HAS_PRIVILEGES -ne 0 ]
then
echo "Run as root or with sudo"
exit 1
fi
# Create Download directory if it does not exist
if [ ! -d "$DOWNLOAD_DIR" ]
then
mkdir $DOWNLOAD_DIR
fi
# Create Build directory if it does not exist
if [ ! -d "$BUILD_DIR" ]
then
mkdir $BUILD_DIR
fi
if [ "$SETUP_PACKAGES" == "1" ]
then
# Setup Java 8
apt-get update
apt-get purge -y openjdk*
apt-get install -y openjdk-8-jdk
DEPS="unzip git curl bzip2 binutils make autoconf openssl \
libssl-dev libopus0 libpcre3 libpcre3-dev build-essential nasm python"
sh -c "dpkg --add-architecture i386; apt-get update && apt-get -y upgrade && apt-get install -y ${DEPS}"
fi
if [ "$DOWNLOAD_NDK" == "1" ]
then
echo ""
echo "Downloading Android NDK ${NDK_VERSION} ..."
echo ""
cd $DOWNLOAD_DIR
curl -L -# -o ndk.zip "$NDK_DOWNLOAD_URL" 2>&1
rm -rf "$NDK_DIR_NAME"
echo ""
echo "Android NDK downloaded!"
echo ""
echo "Extracting Android NDK ..."
echo ""
unzip ndk.zip -d ndk
mv ndk/$NDK_DIR_NAME .
rm -rf ndk
rm -rf ndk.zip
fi
if [ "$DOWNLOAD_SDK" == "1" ]
then
CMD_ZIP_FILE="$CMD_TOOLS.zip"
echo ""
echo "Downloading Android CMD Line Tools version ${CMD_TOOLS_VERSION} ..."
cd $DOWNLOAD_DIR
curl -L -# -o $CMD_ZIP_FILE $CMD_TOOLS_DOWNLOAD_URL 2>&1
echo ""
echo "Android CMD Tools downloaded!"
echo "Extracting Android CMD Tools ..."
rm -rf $SDK_DIR_NAME
unzip -d $SDK_DIR_NAME $CMD_ZIP_FILE
# Remove zip file
rm -rf $CMD_ZIP_FILE
# Create empty repositories.cfg file to avoid warning
mkdir -p ~/.android
touch ~/.android/repositories.cfg
# Since new updates, there are some changes that are not mentioned in the documentation.
# After unzipping the command line tools package, the top-most directory you'll get is $CMD_TOOLS.
# Rename the unpacked directory from $CMD_TOOLS to $CMD_TOOLS_DIR_NAME, and place it under $ANDROID_HOME/$CMD_TOOLS
# which will then look like $ANDROID_HOME/$CMD_TOOLS/$CMD_TOOLS_DIR_NAME
cd $SDK_DIR_NAME/$CMD_TOOLS
mkdir -p $CMD_TOOLS_DIR_NAME
mv `ls | grep -w -v $CMD_TOOLS_DIR_NAME` $CMD_TOOLS_DIR_NAME
fi
if [ "$DOWNLOAD_ANDROID_APIS" == "1" ]
then
echo "Exporting ANDROID_HOME"
export ANDROID_HOME=$DOWNLOAD_DIR/$SDK_DIR_NAME
SDK_MANAGER=$ANDROID_HOME/$CMD_TOOLS/$CMD_TOOLS_DIR_NAME/bin/sdkmanager
echo "Downloading Android Platforms"
for api in ${SETUP_ANDROID_APIS[@]}
do
echo yes | $SDK_MANAGER "platforms;android-$api"
done
echo "Downloading Android Platform-Tools"
echo yes | $SDK_MANAGER "platform-tools"
echo "Exporting TOOLS & PLATFORM_TOOLS"
export PATH=$ANDROID_HOME/platform-tools/:$ANDROID_HOME/tools:$PATH
echo "Downloading Android Build-Tools"
echo yes | $SDK_MANAGER "build-tools;$ANDROID_BUILD_TOOLS"
fi
if [ "$DOWNLOAD_PJSIP" == "1" ]
then
echo ""
echo "Downloading PJSIP ${PJSIP_VERSION} ..."
echo ""
cd $DOWNLOAD_DIR
pjsipFile="pjsip.tar.gz"
curl -L -# -o $pjsipFile "$PJSIP_DOWNLOAD_URL" 2>&1
rm -rf "$PJSIP_DIR_NAME"
echo "PJSIP downloaded!"
echo "Extracting PJSIP ..."
tar xzf $pjsipFile && rm -rf $pjsipFile
PATCH_DIR=$BASEDIR/patches
# Fixed Call-ID PATCH
if [ "${USE_FIXED_CALLID}" == "1" ]
then
echo ""
echo ""
echo "######################################################################"
echo "Apply patch to use a fixed Call-ID in registration ..."
echo "######################################################################"
echo ""
cd $PATCH_DIR/fixed_callid
./patch.sh
cd $BASEDIR
fi
# Rtcp-FB-Event data to pjsua2 PATCH
if [ "${EXPORT_RTCP_FB_DATA}" == "1" ]
then
echo ""
echo ""
echo "######################################################################"
echo "Apply patch to export RTCP-FB Event data to pjsua2 ..."
echo "######################################################################"
echo ""
cd $PATCH_DIR/export_rtcp_fb
./patch.sh
cd $BASEDIR
fi
# Fix missing contact header PATCH
if [ "${FIX_MISSING_CONTACT_HEADER}" == "1" ]
then
echo ""
echo ""
echo "######################################################################"
echo "Apply patch to fix missing contact header ..."
echo "######################################################################"
echo ""
cd $PATCH_DIR/fix_missing_contact_header_on_incall_ip_change
./patch.sh
cd $BASEDIR
fi
fi
if [ "$DOWNLOAD_SWIG" == "1" ]
then
echo ""
echo "Downloading SWIG ${SWIG_VERSION} ..."
echo ""
cd $DOWNLOAD_DIR
curl -L -# -o swig.tar.gz "$SWIG_DOWNLOAD_URL" 2>&1
rm -rf "$SWIG_DIR_NAME"
echo "SWIG downloaded!"
echo "Extracting SWIG ..."
tar xzf swig.tar.gz && rm -rf swig.tar.gz
cd "$SWIG_DIR_NAME"
mkdir -p $SWIG_BUILD_OUT_PATH
echo "Configuring SWIG ..."
./configure >> "$SWIG_BUILD_OUT_PATH/swig.log" 2>&1
echo "Compiling SWIG ..."
make >> "$SWIG_BUILD_OUT_PATH/swig.log" 2>&1
echo "Installing SWIG ..."
make install >> "$SWIG_BUILD_OUT_PATH/swig.log" 2>&1
cd ..
rm -rf "$SWIG_DIR_NAME"
fi
if [ "$DOWNLOAD_OPENSSL" == "1" ]
then
echo ""
echo "Downloading OpenSSL ${OPENSSL_VERSION} ..."
echo ""
cd $DOWNLOAD_DIR
curl -L -# -o openssl.tar.gz "$OPENSSL_DOWNLOAD_URL" 2>&1
rm -rf "$OPENSSL_DIR_NAME"
echo "OpenSSL downloaded!"
echo "Extracting OpenSSL ..."
tar xzf openssl.tar.gz && rm -rf openssl.tar.gz
cd "${BASEDIR}"
./openssl-build-target-archs
fi
if [ "$DOWNLOAD_OPENH264" == "1" ]
then
echo ""
echo "Downloading OpenH264 ${OPENH264_VERSION} ..."
echo ""
cd $DOWNLOAD_DIR
curl -L -# -o openh264.tar.gz "$OPENH264_DOWNLOAD_URL" 2>&1
rm -rf "${OPENH264_DIR_NAME}"
echo "OpenH264 downloaded!"
echo "Extracting OpenH264 ..."
tar xzf openh264.tar.gz && rm -rf openh264.tar.gz
if [ "$SKIP_OPENH264_DEMO" == "1" ]
then
echo "Modifying platform-android.mk to skip Encdemo and Decdemo builds"
sed -e "/binaries: decdemo encdemo/ s/^#*/#/" -i ${OPENH264_DIR_NAME}/build/platform-android.mk
fi
cd ${BASEDIR}
./openh264-build-target-archs || true
fi
if [ "$DOWNLOAD_OPUS" == "1" ]
then
echo ""
echo "Downloading Opus ${OPUS_VERSION} ..."
echo ""
cd "$DOWNLOAD_DIR"
curl -L -# -o opus.tar.gz "$OPUS_DOWNLOAD_URL" 2>&1
rm -rf "${OPUS_DIR_NAME}"
echo "Opus downloaded!"
echo "Extracting Opus ..."
tar xzf opus.tar.gz && rm -rf opus.tar.gz
cd ${BASEDIR}
./opus-build || true
fi
if [ "${DOWNLOAD_BCG729}" == "1" ]
then
echo ""
echo "Downloading bcg729 $BCG729_VERSION ..."
echo ""
cd "$DOWNLOAD_DIR"
rm -rf "${BCG729_DIR_NAME}"
mkdir $BCG729_DIR_NAME
git clone -b $BCG729_VERSION $BCG729_DOWNLOAD_URL $BCG729_DIR_NAME
echo "bcg729 downloaded!"
cd ${BASEDIR}
./bcg729-build || true
fi
echo ""
echo "The build system is ready! Execute: ./build to build PJSIP"