-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·176 lines (156 loc) · 4.28 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
#!/bin/bash
set -o nounset
set -o errexit
HOME=$PWD
BUILD_DIR=$HOME/build
PREFIX=$BUILD_DIR/bin
HOST=aarch64-linux-android
CORSS_PREFIX=aarch64-linux-android-
mkdir -p $BUILD_DIR
mkdir -p $PREFIX
build-x264(){
cd $BUILD_DIR
X264_ZIP=x264-snapshot-20171210-2245-stable.tar.bz2
X264_DIR=x264-snapshot-20171210-2245-stable
AS_ORI=$AS
# AS must be CC
export AS=${CC}
if [ ! -f ${BUILD_DIR}/${X264_ZIP} ]; then
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/${X264_ZIP}
fi
if [ ! -d ${BUILD_DIR}/${X264_ZIP} ]; then
tar xjvf ${BUILD_DIR}/${X264_ZIP} > /dev/null
fi
cd ${BUILD_DIR}/${X264_DIR}
./configure \
--prefix=${PREFIX} \
--cross-prefix=${CORSS_PREFIX} \
--host=${HOST} \
--enable-static \
--enable-pic \
--disable-cli \
--extra-cflags="-march=armv8-a"
make clean
make
make install
# reset AS
export AS=${AS_ORI}
}
build-fdk-aac(){
cd ${BUILD_DIR}
AAC_ZIP=fdk-aac-0.1.5.tar.gz
AAC_DIR=fdk-aac-0.1.5
if [ ! -f ${BUILD_DIR}/${AAC_ZIP} ]; then
wget --no-check-certificate https://nchc.dl.sourceforge.net/project/opencore-amr/fdk-aac/${AAC_ZIP}
fi
if [ ! -d ${BUILD_DIR}/${AAC_DIR} ]; then
tar zxvf ${BUILD_DIR}/${AAC_ZIP} > /dev/null
fi
cd ${BUILD_DIR}/${AAC_DIR}
./configure \
--prefix=${PREFIX} \
--host=${HOST} \
--enable-static \
--disable-shared \
CFLAGS="-Wno-sequence-point -Wno-extra" \
make clean
make
make install
}
build-ffmpeg(){
cd ${BUILD_DIR}
FFMPEG_ZIP=ffmpeg-3.4.1.tar.bz2
FFMPEG_DIR=ffmpeg-3.4.1
if [ ! -f ${BUILD_DIR}/${FFMPEG_ZIP} ]; then
wget http://ffmpeg.org/releases/${FFMPEG_ZIP}
fi
if [ ! -d ${BUILD_DIR}/${FFMPEG_DIR} ]; then
tar xjvf ${FFMPEG_ZIP} > /dev/null
cp ../ffmpeg.patch .
patch -p0 -i ffmpeg.patch
fi
cd ${BUILD_DIR}/${FFMPEG_DIR}
./configure \
--prefix=${PREFIX} \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-doc \
--disable-avdevice \
--disable-pthreads \
--disable-pixelutils \
--disable-everything \
--enable-encoder=libx264 \
--enable-encoder=aac \
--enable-encoder=libfdk_aac \
--enable-decoder=h264 \
--enable-decoder=aac \
--enable-decoder=libfdk_aac \
--enable-muxer=hls \
--enable-muxer=h264 \
--enable-muxer=rtsp \
--enable-demuxer=rtsp \
--enable-demuxer=sdp \
--enable-demuxer=hls \
--enable-demuxer=h264 \
--enable-parser=h264 \
--enable-parser=aac \
--enable-protocol=file \
--enable-protocol=hls \
--enable-libfdk-aac \
--enable-libx264 \
--arch=aarch64 \
--cross-prefix=${CORSS_PREFIX} \
--enable-cross-compile \
--target-os=linux \
--extra-cflags="-march=armv8-a -I${PREFIX}/include -I${PREFIX}/include/fdk_aac" \
--extra-ldflags="-lm -Wl,-Bsymbolic -L${PREFIX}/lib" \
--extra-ldexeflags="-pie" \
--extra-libs="-lgcc" \
--enable-pic \
--ignore-tests
make clean
make
make install
# build libffmpeg.so
$LD -rpath-link=${PREFIX}/lib \
-rpath-link=${SYSROOT}/usr/lib \
-L${PREFIX}/lib \
-L${SYSROOT}/usr/lib \
-soname libffmpeg.so \
-shared -nostdlib -Bsymbolic --whole-archive --no-undefined \
-o libffmpeg.so \
${PREFIX}/lib/libavcodec.a \
${PREFIX}/lib/libavfilter.a \
${PREFIX}/lib/libswresample.a \
${PREFIX}/lib/libavformat.a \
${PREFIX}/lib/libavutil.a \
${PREFIX}/lib/libswscale.a \
${PREFIX}/lib/libpostproc.a \
-lc -lm -lz -ldl -lx264 -lfdk-aac \
--dynamic-linker=/system/bin/linker ${ARM64_TOOLCHAIN_HOME}/lib/gcc/aarch64-linux-android/4.9.x/libgcc.a
cp libffmpeg.so ${PREFIX}/lib/libffmpeg.so
$STRIP --strip-unneeded ${PREFIX}/lib/libffmpeg.so
# shared library libffmpegcmd.so
$CC ${HOME}/ffmpeg_cmd_src/*.c \
-I${PREFIX}/include \
-I${BUILD_DIR}/${FFMPEG_DIR} \
-L${PREFIX}/lib \
-L${SYSROOT}/usr/lib \
-lffmpeg -fPIC -Wl,-soname,libffmpegcmd.so -shared -o libffmpegcmd.so
mv libffmpegcmd.so $PREFIX/lib
# exectuable ffmpeg_cmd
$CC ${HOME}/ffmpeg_cmd_src/*.c \
-I${PREFIX}/include \
-I${BUILD_DIR}/${FFMPEG_DIR} \
-L${PREFIX}/lib \
-L${SYSROOT}/usr/lib \
-lffmpeg -lm -lz -fPIC -pie -o ffmpeg_cmd
mv ffmpeg_cmd $PREFIX/bin
}
build-x264
build-fdk-aac
build-ffmpeg