1
1
#! /bin/bash
2
2
3
3
# https://github.com/markus-perl/ffmpeg-build-script
4
- # Version 0.3
4
+ # Version 0.4
5
5
6
- CWD=` pwd`
6
+ CWD=$( pwd)
7
7
PACKAGES=" $CWD /packages"
8
8
WORKSPACE=" $CWD /workspace"
9
9
CC=clang
10
10
LDFLAGS=" -L${WORKSPACE} /lib -lm"
11
11
CFLAGS=" -I${WORKSPACE} /include"
12
12
PKG_CONFIG_PATH=" ${WORKSPACE} /lib/pkgconfig"
13
13
14
+ # Speed up the process
15
+ # Env Var NUMJOBS overrides automatic detection
16
+ if [[ -n $NUMJOBS ]]; then
17
+ MJOBS=$NUMJOBS
18
+ elif [[ -f /proc/cpuinfo ]]; then
19
+ MJOBS=$( grep -c processor /proc/cpuinfo)
20
+ else
21
+ MJOBS=4
22
+ fi
23
+ echo " Using $MJOBS make jobs simultaneously."
24
+
14
25
make_dir () {
15
26
if [ ! -d $1 ]; then
16
27
if ! mkdir $1 ; then
17
- echo " \nFailed to create dir $1 " ;
28
+ printf " \n Failed to create dir %s " " $1 " ;
18
29
exit 1
19
30
fi
20
31
fi
@@ -49,13 +60,13 @@ download () {
49
60
}
50
61
51
62
execute () {
52
- echo " $ $@ "
63
+ echo " $ $* "
53
64
OUTPUT=" $( $@ 2>&1 ) "
54
65
55
66
if [ $? -ne 0 ]; then
56
- echo $OUTPUT
67
+ echo " $OUTPUT "
57
68
echo " "
58
- echo " Failed to Execute $@ " >&2
69
+ echo " Failed to Execute $* " >&2
59
70
exit 1
60
71
fi
61
72
}
@@ -75,7 +86,7 @@ build () {
75
86
}
76
87
77
88
command_exists () {
78
- if ! [ -x " $( command -v $1 ) " ]; then
89
+ if ! [[ -x $( command -v " $1 " ) ] ]; then
79
90
return 1
80
91
fi
81
92
@@ -124,120 +135,120 @@ fi
124
135
125
136
if build " yasm" ; then
126
137
download " http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz" " yasm-1.3.0.tar.gz"
127
- cd $PACKAGES /yasm-1.3.0
128
- execute ./configure --prefix=${WORKSPACE}
129
- execute make -j 4
138
+ cd $PACKAGES /yasm-1.3.0 || exit
139
+ execute ./configure --prefix=${WORKSPACE}
140
+ execute make -j $MJOBS
130
141
execute make install
131
142
build_done " yasm"
132
143
fi
133
144
134
145
if build " opencore" ; then
135
146
download " http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Fopencore-amr%2F&ts=1442256558&use_mirror=netassist" " opencore-amr-0.1.3.tar.gz"
136
- cd $PACKAGES /opencore-amr-0.1.3
147
+ cd $PACKAGES /opencore-amr-0.1.3 || exit
137
148
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
138
- execute make -j 4
149
+ execute make -j $MJOBS
139
150
execute make install
140
151
build_done " opencore"
141
152
fi
142
153
143
154
if build " libvpx" ; then
144
155
download " https://github.com/webmproject/libvpx/archive/v1.5.0.tar.gz" " libvpx-1.5.0.tar.gz"
145
- cd $PACKAGES /libvpx*
156
+ cd $PACKAGES /libvpx* || exit
146
157
sed -e ' s/cp -p/cp/' -i build/make/Makefile
147
158
execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
148
- execute make -j 4
159
+ execute make -j $MJOBS
149
160
execute make install
150
161
build_done " libvpx"
151
162
fi
152
163
153
164
if build " lame" ; then
154
165
download " http://kent.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz" " lame-3.99.5.tar.gz"
155
- cd $PACKAGES /lame-3.99.5
166
+ cd $PACKAGES /lame-3.99.5 || exit
156
167
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
157
- execute make -j 4
168
+ execute make -j $MJOBS
158
169
execute make install
159
170
build_done " lame"
160
171
fi
161
172
162
173
if build " xvidcore" ; then
163
174
download " http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz" " xvidcore-1.3.3.tar.gz"
164
- cd $PACKAGES /xvidcore
165
- cd build/generic
175
+ cd $PACKAGES /xvidcore || exit
176
+ cd build/generic || exit
166
177
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
167
- execute make -j 4
178
+ execute make -j $MJOBS
168
179
execute make install
169
180
170
- if [ -f ${WORKSPACE} /lib/libxvidcore.4.dylib ]; then
171
- execute rm ${WORKSPACE} /lib/libxvidcore.4.dylib
181
+ if [[ -f ${WORKSPACE} /lib/libxvidcore.4.dylib ] ]; then
182
+ execute rm " ${WORKSPACE} /lib/libxvidcore.4.dylib"
172
183
fi
173
184
174
185
build_done " xvidcore"
175
186
fi
176
187
177
188
if build " x264" ; then
178
189
download " ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2" " last_x264.tar.bz2"
179
- cd $PACKAGES /x264-snapshot-*
190
+ cd $PACKAGES /x264-snapshot-* || exit
180
191
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
181
- execute make -j 4
192
+ execute make -j $MJOBS
182
193
execute make install
183
194
execute make install-lib-static
184
195
build_done " x264"
185
196
fi
186
197
187
198
if build " libogg" ; then
188
199
download " http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz" " libogg-1.3.2.tar.gz"
189
- cd $PACKAGES /libogg-1.3.2
200
+ cd $PACKAGES /libogg-1.3.2 || exit
190
201
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
191
- execute make -j 4
202
+ execute make -j $MJOBS
192
203
execute make install
193
204
build_done " libogg"
194
205
fi
195
206
196
207
if build " libvorbis" ; then
197
208
download " http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz" " libvorbis-1.3.5.tar.gz"
198
- cd $PACKAGES /libvorbis-1.3.5
209
+ cd $PACKAGES /libvorbis-1.3.5 || exit
199
210
execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE} /lib --with-ogg-includes=${WORKSPACE} /include/ --enable-static --disable-shared --disable-oggtest
200
- execute make -j 4
211
+ execute make -j $MJOBS
201
212
execute make install
202
213
build_done " libvorbis"
203
214
fi
204
215
205
216
if build " libtheora" ; then
206
217
download " http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz" " libtheora-1.1.1.tar.bz"
207
- cd $PACKAGES /libtheora-1.1.1
218
+ cd $PACKAGES /libtheora-1.1.1 || exit
208
219
sed " s/-fforce-addr//g" configure > configure.patched
209
220
chmod +x configure.patched
210
221
mv configure.patched configure
211
222
execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE} /lib --with-ogg-includes=${WORKSPACE} /include/ --with-vorbis-libraries=${WORKSPACE} /lib --with-vorbis-includes=${WORKSPACE} /include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm
212
- execute make -j 4
223
+ execute make -j $MJOBS
213
224
execute make install
214
225
build_done " libtheora"
215
226
fi
216
227
217
228
if build " pkg-config" ; then
218
229
download " http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.1.tar.gz" " pkg-config-0.29.1.tar.gz"
219
- cd $PACKAGES /pkg-config-0.29.1
230
+ cd $PACKAGES /pkg-config-0.29.1 || exit
220
231
execute ./configure --silent --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE} /lib/pkgconfig --with-internal-glib
221
- execute make -j 4
232
+ execute make -j $MJOBS
222
233
execute make install
223
234
build_done " pkg-config"
224
235
fi
225
236
226
237
if build " cmake" ; then
227
238
download " https://cmake.org/files/v3.5/cmake-3.5.0.tar.gz" " cmake-3.5.0.tar.gz"
228
- cd $PACKAGES /cmake*
239
+ cd $PACKAGES /cmake* || exit
229
240
rm Modules/FindJava.cmake
230
241
perl -p -i -e " s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
231
242
perl -p -i -e " s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
232
243
execute ./configure --prefix=${WORKSPACE}
233
- execute make -j 4
244
+ execute make -j $MJOBS
234
245
execute make install
235
246
build_done " cmake"
236
247
fi
237
248
238
249
if build " vid_stab" ; then
239
250
download " https://codeload.github.com/georgmartius/vid.stab/legacy.tar.gz/release-0.98b" " vid.stab-0.98b-transcode-1.1-binary-x86_64.tgz"
240
- cd $PACKAGES /georgmartius-vid*
251
+ cd $PACKAGES /georgmartius-vid* || exit
241
252
perl -p -i -e " s/vidstab SHARED/vidstab STATIC/" CMakeLists.txt
242
253
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
243
254
execute make -s install
246
257
247
258
if build " x265" ; then
248
259
download " https://bitbucket.org/multicoreware/x265/downloads/x265_1.9.tar.gz" " x265-1.9.tar.gz"
249
- cd $PACKAGES /x265_1.9
250
- cd source
260
+ cd $PACKAGES /x265_1.9 || exit
261
+ cd source || exit
251
262
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
252
- execute make -j 4
263
+ execute make -j $MJOBS
253
264
execute make install
254
265
sed " s/-lx265/-lx265 -lstdc++/g" " $WORKSPACE /lib/pkgconfig/x265.pc" > " $WORKSPACE /lib/pkgconfig/x265.pc.tmp"
255
266
mv " $WORKSPACE /lib/pkgconfig/x265.pc.tmp" " $WORKSPACE /lib/pkgconfig/x265.pc"
258
269
259
270
if build " fdk_aac" ; then
260
271
download " http://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.4.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Ffdk-aac%2F&ts=1457561564&use_mirror=kent" " fdk-aac-0.1.4.tar.gz"
261
-
262
- cd $PACKAGES /fdk-aac*
272
+ cd $PACKAGES /fdk-aac* || exit
263
273
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
264
- execute make -j 4
274
+ execute make -j $MJOBS
265
275
execute make install
266
276
build_done " fdk_aac"
267
277
fi
268
278
269
279
270
280
build " ffmpeg"
271
281
download " http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 " " ffmpeg-snapshot.tar.bz2 "
272
- cd $PACKAGES /ffmpeg*
282
+ cd $PACKAGES /ffmpeg* || exit
273
283
CFLAGS=" -I$WORKSPACE /include" LDFLAGS=" -L$WORKSPACE /lib"
274
284
execute ./configure --arch=64 --prefix=${WORKSPACE} --extra-cflags=" -I$WORKSPACE /include" --extra-ldflags=" -L$WORKSPACE /lib" --extra-version=static --disable-debug --disable-shared --enable-static --extra-cflags=--static --disable-ffplay --disable-ffserver --disable-doc --enable-version3 --enable-libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-gpl --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-nonfree --enable-filters --enable-libvidstab --enable-libx265 --enable-runtime-cpudetect --enable-libfdk-aac
275
- execute make -j 4
285
+ execute make -j $MJOBS
276
286
execute make install
277
287
278
288
INSTALL_FOLDER=" /usr/bin"
0 commit comments