forked from zimbatm/ffmpeg-static
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·241 lines (206 loc) · 5.11 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
#!/bin/sh
set -e
set -u
jflag=
jval=2
while getopts 'j:' OPTION
do
case $OPTION in
j) jflag=1
jval="$OPTARG"
;;
?) printf "Usage: %s: [-j concurrency_level] (hint: your cores + 20%%)\n" $(basename $0) >&2
exit 2
;;
esac
done
shift $(($OPTIND - 1))
if [ "$jflag" ]
then
if [ "$jval" ]
then
printf "Option -j specified (%d)\n" $jval
fi
fi
#echo $TARGET_DIR
#exit
cd `dirname $0`
ENV_ROOT=`pwd`
. ./env.source
#if you want a rebuild
#rm -rf "$BUILD_DIR" "$TARGET_DIR"
mkdir -p "$BUILD_DIR" "$TARGET_DIR" "$DOWNLOAD_DIR" "$BIN_DIR"
#download and extract package
download(){
filename="$1"
if [ ! -z "$2" ];then
filename="$2"
fi
../download.pl "$DOWNLOAD_DIR" "$1" "$filename" "$3" "$4"
#disable uncompress
CACHE_DIR="$DOWNLOAD_DIR" ../fetchurl "http://cache/$filename"
}
echo "#### FFmpeg static build ####"
#this is our working directory
cd $BUILD_DIR
download \
"yasm-1.3.0.tar.gz" \
"" \
"fc9e586751ff789b34b1f21d572d96af" \
"http://www.tortall.net/projects/yasm/releases/"
download \
"last_x264.tar.bz2" \
"" \
"nil" \
"http://download.videolan.org/pub/videolan/x264/snapshots/"
download \
"x265_1.7.tar.gz" \
"" \
"nil" \
"https://bitbucket.org/multicoreware/x265/downloads/"
download \
"master" \
"fdk-aac.tar.gz" \
"nil" \
"https://github.com/mstorsjo/fdk-aac/tarball"
download \
"lame-3.99.5.tar.gz" \
"" \
"84835b313d4a8b68f5349816d33e07ce" \
"http://downloads.sourceforge.net/project/lame/lame/3.99"
download \
"opus-1.1.tar.gz" \
"" \
"c5a8cf7c0b066759542bc4ca46817ac6" \
"http://downloads.xiph.org/releases/opus"
download \
"v1.5.0.tar.gz" \
"" \
"0c662bc7525afe281badb3175140d35c" \
"https://github.com/webmproject/libvpx/archive/"
download \
"libogg-1.3.2.tar.gz" \
"" \
"nil" \
"http://downloads.xiph.org/releases/ogg"
download \
"libvorbis-1.3.5.tar.gz" \
"" \
"nil" \
"http://downloads.xiph.org/releases/vorbis"
download \
"libtheora-1.1.1.tar.gz" \
"" \
"nil" \
"http://downloads.xiph.org/releases/theora/"
download \
"n2.8.10.tar.gz" \
"ffmpeg2.8.tar.gz" \
"nil" \
"https://github.com/FFmpeg/FFmpeg/archive"
echo "*** Building yasm ***"
cd $BUILD_DIR/yasm*
./configure --prefix=$TARGET_DIR --bindir=$BIN_DIR
make -j $jval
make install
echo "*** Building x264 ***"
cd $BUILD_DIR/x264*
PATH="$BIN_DIR:$PATH" \
CFLAGS="-fPIC" \
CXXFLAGS="-fPIC" \
./configure --prefix=$TARGET_DIR --enable-static --enable-pic --disable-shared --disable-opencl
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building x265 ***"
cd $BUILD_DIR/x265*
cd build/linux
PATH="$BIN_DIR:$PATH" CFLAGS="-fPIC" CXXFLAGS="-fPIC" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DENABLE_SHARED:bool=off ../../source
make -j $jval
make install
echo "*** Building fdk-aac ***"
cd $BUILD_DIR/mstorsjo-fdk-aac*
autoreconf -fiv
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building mp3lame ***"
cd $BUILD_DIR/lame*
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=$TARGET_DIR --enable-nasm --disable-shared
make
make install
echo "*** Building opus ***"
cd $BUILD_DIR/opus*
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=$TARGET_DIR --disable-shared
make
make install
echo "*** Building libvpx ***"
cd $BUILD_DIR/libvpx*
PATH="$BIN_DIR:$PATH" \
CFLAGS="-fPIC" \
CXXFLAGS="-fPIC" \
ASFLAGS="-DPIC" \
./configure --prefix=$TARGET_DIR --disable-examples --disable-unit-tests
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building libogg ***"
cd $BUILD_DIR/libogg*
PATH="$BIN_DIR:$PATH" \
CFLAGS="-fPIC" \
CXXFLAGS="-fPIC" \
./configure --prefix=$TARGET_DIR --disable-shared --enable-static
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building libvorbis ***"
cd $BUILD_DIR/libvorbis*
PATH="$BIN_DIR:$PATH" \
PKG_CONFIG_PATH="$TARGET_DIR/lib/pkgconfig" \
CFLAGS="-fPIC" \
CXXFLAGS="-fPIC" \
./configure --prefix=$TARGET_DIR --disable-shared --enable-static
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building libtheora ***"
cd $BUILD_DIR/libtheora*
PATH="$BIN_DIR:$PATH" \
PKG_CONFIG_PATH="$TARGET_DIR/lib/pkgconfig" \
CFLAGS="-fPIC" \
CXXFLAGS="-fPIC" \
./configure --prefix=$TARGET_DIR --disable-shared --enable-static
PATH="$BIN_DIR:$PATH" make -j $jval
make install
NPROC=1
if which `nproc`;then
NPROC="`nproc`"
elif [ -f /proc/cpuinfo ];then
NPROC="`grep -c ^processor /proc/cpuinfo`"
fi
# FFMpeg
echo "*** Building FFmpeg ***"
cd $BUILD_DIR/FFmpeg*
PATH="$BIN_DIR:$PATH" \
PKG_CONFIG_PATH="$TARGET_DIR/lib/pkgconfig" ./configure \
--prefix="$TARGET_DIR" \
--pkg-config-flags="--static" \
--extra-cflags="-I$TARGET_DIR/include" \
--extra-ldflags="-L$TARGET_DIR/lib" \
--bindir="$BIN_DIR" \
--enable-shared \
--enable-ffmpeg \
--enable-ffplay \
--enable-ffserver \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
PATH="$BIN_DIR:$PATH" make -j$NPROC
make install
make distclean
hash -r