forked from VoiSmart/pjsip-android-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-build-system
executable file
·161 lines (138 loc) · 5.33 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
#!/bin/bash -e
. config.conf
BASEDIR=$(pwd)
if [ "$SETUP_PACKAGES" == "1" ]
then
# Setup Java 8
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get purge -y openjdk*
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo apt-get -y install oracle-java8-installer ant
DEPS="vim git curl bzip2 gcc g++ binutils make autoconf openssl \
libssl-dev ant libopus0 \
libpcre3 libpcre3-dev build-essential nasm \
libc6:i386 libstdc++6:i386 zlib1g:i386"
sudo -- 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 "Downloading Android NDK ..."
cd "${BASEDIR}"
curl -L -# -o ndk.bin "$NDK_DOWNLOAD_URL" 2>&1
rm -rf "$NDK_DIR_NAME"
echo "Android NDK downloaded!"
echo "Extracting Android NDK ..."
chmod +x ndk.bin && ./ndk.bin 2>&1 > /dev/null || true
rm -rf ndk.bin
fi
if [ "$DOWNLOAD_SDK" == "1" ]
then
echo "Downloading Android SDK ..."
cd "${BASEDIR}"
curl -L -# -o sdk.tgz "$SDK_DOWNLOAD_URL" 2>&1
rm -rf "$SDK_DIR_NAME"
echo "Android SDK downloaded!"
echo "Extracting Android SDK ..."
tar xzf sdk.tgz && rm -rf sdk.tgz
fi
if [ "$DOWNLOAD_ANDROID_APIS" == "1" ]
then
cd ${BASEDIR}/${SDK_DIR_NAME}/tools
ALL_SDK=$(./android list sdk --all)
for api in "${SETUP_ANDROID_APIS[@]}"
do
echo "Downloading Android API Platform ${api}..."
PACKAGE=$(echo "${ALL_SDK}" | grep "API ${api}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1)
echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force
done
PACKAGE=$(echo "${ALL_SDK}" | grep "Android SDK Platform-tools" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1)
echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force
PACKAGE=$(echo "${ALL_SDK}" | grep "Build-tools" | grep "${BUILD_TOOLS_VERSION}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1)
echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force
fi
if [ "$DOWNLOAD_PJSIP" == "1" ]
then
echo "Downloading PJSIP ..."
cd "${BASEDIR}"
curl -L -# -o pjsip.tar.bz2 "$PJSIP_DOWNLOAD_URL" 2>&1
rm -rf "$PJSIP_DIR_NAME"
echo "PJSIP downloaded!"
echo "Extracting PJSIP ..."
tar xjf pjsip.tar.bz2 && rm -rf pjsip.tar.bz2
if [ "${PJSIP_DIR_NAME}" == "pjproject-2.4.5" ]
then
echo "Fix BASH script error in 2.4.5 tag ..."
sed -i 's/TARGET_HOST+=-linux-android/TARGET_HOST="\${TARGET_HOST}-linux-android"/g' "${BASEDIR}/${PJSIP_DIR_NAME}/configure-android"
echo "Apply patch to support G.729 codec without Intel IPP codec library ..."
cd g729_patch
./install.sh
cd ..
fi
fi
if [ "$DOWNLOAD_SWIG" == "1" ]
then
echo "Downloading SWIG ..."
cd "${BASEDIR}"
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"
./configure
make && sudo make install
cd ..
rm -rf "$SWIG_DIR_NAME"
fi
if [ "$DOWNLOAD_OPENSSL" == "1" ]
then
echo "Downloading OpenSSL ..."
cd "${BASEDIR}"
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_LIBYUV" == "1" ]
then
echo "Downloading libyuv ..."
cd "${BASEDIR}"
rm -rf "${LIBYUV_REPO_DIR_NAME}"
git clone "${LIBYUV_REPO_PATH}"
cd "${LIBYUV_REPO_DIR_NAME}"
export PATH="${BASEDIR}/${NDK_DIR_NAME}:$PATH"
# Re-enable static library, disabled with https://github.com/illuspas/libyuv-android/commit/d5d7e66ed635cf96fce1aa029ccc24a06bb0e7bc
sed -i 's/#include $(BUILD_SHARED_LIBRARY)/include $(BUILD_SHARED_LIBRARY)/g' jni/Android.mk
sed -i 's/include $(BUILD_STATIC_LIBRARY)/#include $(BUILD_STATIC_LIBRARY)/g' jni/Android.mk
if [ "${OPENH264_TARGET_NDK_LEVEL}" -ge "21" ]
then
sed -i 's/APP_ABI := armeabi-v7a arm64-v8a x86 x86_64/APP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mips64/g' jni/Application.mk
else
sed -i 's/APP_ABI := armeabi-v7a arm64-v8a x86 x86_64/APP_ABI := armeabi armeabi-v7a x86/g' jni/Application.mk
fi
ndk-build
fi
if [ "$DOWNLOAD_OPENH264" == "1" ]
then
echo "Downloading OpenH264 ..."
cd "${BASEDIR}"
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 [ "${OPENH264_DIR_NAME}" == "openh264-1.0.0" ] && [ "${OPENH264_TARGET_NDK_LEVEL}" -ge "21" ]
then
echo "Patching OpenH264 to be able to compile with Android API 21+.."
cp ${BASEDIR}/openh264-1.0.0-android21.patch ${BASEDIR}/${OPENH264_DIR_NAME}/
cd ${OPENH264_DIR_NAME} && patch -p1 < openh264-1.0.0-android21.patch || true
fi
cd ${BASEDIR}
./openh264-build-target-archs || true
fi
echo "The build system is ready! Execute: ./build to build PJSIP :)"