]> git.sesse.net Git - casparcg/blob - dependencies64/ffmpeg/ffmpeg-build-linux/build.sh
dirty hack replace shipped ffmpeg linux libs with compiled ones!
[casparcg] / dependencies64 / ffmpeg / ffmpeg-build-linux / build.sh
1 #!/bin/sh
2
3 set -e
4 set -u
5
6 jflag=
7 jval=2
8
9 while getopts 'j:' OPTION
10 do
11   case $OPTION in
12   j)    jflag=1
13                 jval="$OPTARG"
14                 ;;
15   ?)    printf "Usage: %s: [-j concurrency_level] (hint: your cores + 20%%)\n" $(basename $0) >&2
16                 exit 2
17                 ;;
18   esac
19 done
20 shift $(($OPTIND - 1))
21
22 if [ "$jflag" ]
23 then
24   if [ "$jval" ]
25   then
26     printf "Option -j specified (%d)\n" $jval
27   fi
28 fi
29
30 cd `dirname $0`
31 ENV_ROOT=`pwd`
32 . ./env.source
33
34 rm -rf "$BUILD_DIR" "$TARGET_DIR"
35 mkdir -p "$BUILD_DIR" "$TARGET_DIR"
36
37 # NOTE: this is a fetchurl parameter, nothing to do with the current script
38 #export TARGET_DIR_DIR="$BUILD_DIR"
39
40 echo "#### FFmpeg static build, by STVS SA ####"
41 cd $BUILD_DIR
42 ../fetchurl "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz"
43 ../fetchurl "http://www.zlib.net/fossils/zlib-1.2.8.tar.gz"
44 ../fetchurl "http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz"
45 #../fetchurl "http://downloads.sf.net/project/libpng/libpng15/older-releases/1.5.14/libpng-1.5.14.tar.gz"
46 ../fetchurl "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz"
47 ../fetchurl "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz"
48 ../fetchurl "http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2"
49 ../fetchurl "http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.4.0.tar.bz2"
50 #../fetchurl "http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.bz2"
51 ../fetchurl "ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2"
52 ../fetchurl "http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz"
53 ../fetchurl "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz"
54 ../fetchurl "http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz"
55 ../fetchurl "http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.94.tar.bz2"
56 ../fetchurl "http://www.ffmpeg.org/releases/ffmpeg-2.7.tar.bz2"
57 ../fetchurl "http://downloads.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz"
58 ../fetchurl "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.3/gnutls-3.3.15.tar.xz"
59 ../fetchurl "https://ftp.gnu.org/gnu/nettle/nettle-2.7.1.tar.gz"
60 ../fetchurl "https://gmplib.org/download/gmp/gmp-6.0.0a.tar.xz"
61 ../fetchurl "https://github.com/libass/libass/archive/0.12.2.tar.gz"
62 ../fetchurl "http://fribidi.org/download/fribidi-0.19.6.tar.bz2"
63 ../fetchurl "ftp://ftp.videolan.org/pub/videolan/libbluray/0.8.1/libbluray-0.8.1.tar.bz2"
64 ../fetchurl "http://tukaani.org/xz/xz-5.2.1.tar.xz"
65 ../fetchurl "http://pkgs.fedoraproject.org/lookaside/pkgs/libgme/game-music-emu-0.6.0.tar.bz2/b98fafb737bc889dc65e7a8b94bd1bf5/game-music-emu-0.6.0.tar.bz2"
66 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/libilbc-20141214-git-ef04ebe.tar.xz"
67 ../fetchurl "http://downloads.sourceforge.net/project/modplug-xmms/libmodplug/0.8.8.5/libmodplug-0.8.8.5.tar.gz?r=&ts=1440421934&use_mirror=vorboss"
68 ../fetchurl "http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz"
69 ../fetchurl "http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3.tgz"
70 ../fetchurl "https://www.openssl.org/source/old/1.0.2/openssl-1.0.2a.tar.gz"
71 ../fetchurl "http://downloads.sourceforge.net/project/soxr/soxr-0.1.1-Source.tar.xz"
72 ../fetchurl "https://github.com/georgmartius/vid.stab/archive/release-0.98.tar.gz"
73 ../fetchurl "http://download.savannah.gnu.org/releases/freetype/freetype-2.5.5.tar.bz2"
74 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/libgsm-1.0.13-4.tar.xz"
75 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/openjpeg-1.5.2.tar.xz"
76 ../fetchurl "http://pkgs.fedoraproject.org/lookaside/pkgs/orc/orc-0.4.18.tar.gz/1a2552e8d127526c48d644fe6437b377/orc-0.4.18.tar.gz"
77 ../fetchurl "http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-8.36.tar.bz2"
78 ../fetchurl "http://78.108.103.11/MIRROR/ftp/png/src/history/libpng12/libpng-1.2.53.tar.bz2"
79 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/schroedinger-1.0.11.tar.xz"
80 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/speex-1.2rc2.tar.xz"
81 ../fetchurl "http://ftp.gnu.org/gnu/libtasn1/libtasn1-4.5.tar.gz"
82 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/twolame-0.3.13.tar.xz"
83 ../fetchurl "http://www.freedesktop.org/software/vaapi/releases/libva/libva-1.5.1.tar.bz2"
84 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/vo-aacenc-0.1.3.tar.xz"
85 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/vo-amrwbenc-0.1.2.tar.xz"
86 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/wavpack-4.75.0.tar.xz"
87 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/libwebp-0.4.3.tar.xz"
88 ../fetchurl "http://ffmpeg.zeranoe.com/builds/source/external_libraries/x265-1.7.tar.xz"
89 ../fetchurl "ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz"
90
91 echo "*** Building libxml2 ***"
92 cd $BUILD_DIR/libxml2*
93 ./configure --prefix=$TARGET_DIR --enable-shared
94 make -j $jval
95 make install || echo "Make install failed, continuing"
96
97 echo "*** Building x265 ***"
98 cd $BUILD_DIR/x265*/source
99 cmake .
100 make -j $jval
101 make DESTDIR=$TARGET_DIR install
102
103 echo "*** Building libwebp ***"
104 cd $BUILD_DIR/libwebp*
105 ./configure --prefix=$TARGET_DIR --enable-shared --enable-mmx
106 make -j $jval
107 make install
108
109 echo "*** Building wavpack ***"
110 cd $BUILD_DIR/wavpack*
111 ./configure --prefix=$TARGET_DIR --enable-shared --enable-mmx
112 make -j $jval
113 make install
114
115 echo "*** Building vo-amrwbenc ***"
116 cd $BUILD_DIR/vo-amrwbenc*
117 ./configure --prefix=$TARGET_DIR --enable-shared
118 make -j $jval
119 make install
120
121 echo "*** Building vo-aacenc ***"
122 cd $BUILD_DIR/vo-aacenc*
123 ./configure --prefix=$TARGET_DIR --enable-shared
124 make -j $jval
125 make install
126
127 echo "*** Building libva ***"
128 cd $BUILD_DIR/libva*
129 ./configure --prefix=$TARGET_DIR --enable-shared --enable-drm=no --enable-glx=no --enable-egl=no --enable-wayland=no
130 make -j $jval
131 make install
132
133 echo "*** Building twolame ***"
134 cd $BUILD_DIR/twolame*
135 ./configure --prefix=$TARGET_DIR --enable-shared
136 make -j $jval
137 make install
138
139 echo "*** Building libtasn1 ***"
140 cd $BUILD_DIR/libtasn1*
141 ./configure --prefix=$TARGET_DIR --enable-shared
142 make -j $jval
143 make install
144
145 echo "*** Building speex ***"
146 cd $BUILD_DIR/speex*
147 ./configure --prefix=$TARGET_DIR --enable-shared
148 make -j $jval
149 make install
150
151 echo "*** Building orc ***"
152 cd $BUILD_DIR/orc*
153 ./configure --prefix=$TARGET_DIR --enable-shared
154 make -j $jval
155 make install
156
157 echo "*** Building schroedinger ***"
158 cd $BUILD_DIR/schroedinger*
159 ./configure --prefix=$TARGET_DIR --enable-shared
160 make -j $jval
161 make install
162
163 echo "*** Building libpng ***"
164 cd $BUILD_DIR/libpng*
165 ./configure --prefix=$TARGET_DIR --enable-shared
166 make -j $jval
167 make install
168
169 echo "*** Building pcre ***"
170 cd $BUILD_DIR/pcre*
171 ./configure --prefix=$TARGET_DIR --enable-shared
172 make -j $jval
173 make install
174
175 echo "*** Building openjpeg ***"
176 cd $BUILD_DIR/openjpeg*
177 ./bootstrap.sh
178 ./configure --prefix=$TARGET_DIR --enable-shared
179 make -j $jval
180 make install
181
182 echo "*** Building freetype ***"
183 cd $BUILD_DIR/freetype*
184 ./configure --prefix=$TARGET_DIR --enable-shared --with-harfbuzz=no
185 make -j $jval
186 make install
187
188 echo "*** Building libgsm ***"
189 cd $BUILD_DIR/libgsm*
190 sed -i "s#INSTALL_ROOT  =#INSTALL_ROOT  = $TARGET_DIR#g" $BUILD_DIR/libgsm*/Makefile
191 sed -i 's#NeedFunctionPrototypes=1#NeedFunctionPrototypes=1 -fPIC#g' $BUILD_DIR/libgsm*/Makefile
192 sed -i 's#(GSM_INSTALL_ROOT)/inc#(GSM_INSTALL_ROOT)/include#g' $BUILD_DIR/libgsm*/Makefile
193 make -j $jval
194 make -j lib/libgsm.so
195 make install prefix=$TARGET_DIR
196 cp lib/libgsm.so* $TARGET_DIR/lib/
197
198 echo "*** Building xavs ***"
199 cd $BUILD_DIR/
200 svn checkout http://svn.code.sf.net/p/xavs/code/trunk xavs-code
201 cd xavs-code
202 ./configure --prefix=$TARGET_DIR --enable-shared --disable-asm
203 make -j $jval
204 make install
205
206 echo "*** Building vid.stab ***"
207 cd $BUILD_DIR/vid.stab*
208 cmake .
209 make -j $jval
210 make DESTDIR=$TARGET_DIR install
211
212 echo "*** Building soxr ***"
213 cd $BUILD_DIR/soxr*
214 cmake -DWITH_OPENMP=off .
215 make -j $jval
216 make DESTDIR=$TARGET_DIR install
217
218 echo "*** Building openssl ***"
219 cd $BUILD_DIR/openssl*
220 ./config --prefix=$TARGET_DIR shared
221 make
222 make install
223
224 echo "*** Building rtmpdump ***"
225 cd $BUILD_DIR/rtmpdump*
226 sed -i 's#LIB_OPENSSL=-lssl -lcrypto#LIB_OPENSSL=-lssl -lcrypto -ldl#g' $BUILD_DIR/rtmpdump*/Makefile
227 make INC=-I$TARGET_DIR/include LDFLAGS=-L$TARGET_DIR/lib  -j $jval SYS=posix
228 make install prefix=$TARGET_DIR
229
230 echo "*** Building opencore-amr ***"
231 cd $BUILD_DIR/opencore-amr*
232 ./configure --prefix=$TARGET_DIR --enable-shared
233 make -j $jval
234 make install
235
236 echo "*** Building libmodplug ***"
237 cd $BUILD_DIR/libmodplug*
238 ./configure --prefix=$TARGET_DIR --enable-shared
239 make -j $jval
240 make install
241
242 echo "*** Building libilbc ***"
243 cd $BUILD_DIR/libilbc*
244 ./configure --prefix=$TARGET_DIR --enable-shared
245 make -j $jval
246 make install
247
248 echo "*** Building game-music-emu ***"
249 cd $BUILD_DIR/game-music-emu*
250 cmake .
251 make -j $jval
252 make DESTDIR=$TARGET_DIR install
253
254 echo "*** Building xz ***"
255 cd $BUILD_DIR/xz*
256 ./configure --prefix=$TARGET_DIR --enable-shared
257 make -j $jval
258 make install
259
260 echo "*** Building libbluray ***"
261 cd $BUILD_DIR/libbluray*
262 ./configure --prefix=$TARGET_DIR --enable-shared
263 make -j $jval
264 make install
265 sed -i 's#Libs.private: -ldl -lxml2   -lfreetype#Libs.private: -ldl -lxml2   -lfreetype -llzma#g' $TARGET_DIR/lib/pkgconfig/libbluray.pc
266
267 echo "*** Building fribidi ***"
268 cd $BUILD_DIR/fribidi*
269 ./configure --prefix=$TARGET_DIR --enable-shared
270 make -j $jval
271 make install
272
273 echo "*** Building libass ***"
274 cd $BUILD_DIR/libass*
275 ./autogen.sh
276 ./configure --prefix=$TARGET_DIR --enable-shared --disable-harfbuzz --disable-enca
277 make -j $jval
278 make install
279
280 echo "*** Building expat ***"
281 cd $BUILD_DIR/expat*
282 ./configure --prefix=$TARGET_DIR --enable-shared
283 make -j $jval
284 make install
285
286 echo "*** Building fontconfig ***"
287 cd $BUILD_DIR/fontconfig*
288 ./configure --prefix=$TARGET_DIR --enable-shared
289 make -j $jval
290 make install
291
292 echo "*** Building gmp ***"
293 cd $BUILD_DIR/gmp*
294 ./configure --prefix=$TARGET_DIR --enable-shared
295 make -j $jval
296 make install
297
298 echo "*** Building nettle ***"
299 cd $BUILD_DIR/nettle*
300 sed -i 's#testsuite##g' Makefile.in
301 sed -i 's#examples##g' Makefile.in
302 ./configure --prefix=$TARGET_DIR --enable-shared --enable-mini-gmp
303 make -j $jval
304 make install
305
306 echo "*** Building gnutls ***"
307 cd $BUILD_DIR/gnutls*
308 ./configure --prefix=$TARGET_DIR --enable-shared --disable-doc --without-p11-kit --disable-libdane --disable-cxx
309 make -j $jval
310 make install
311
312 echo "*** Building yasm ***"
313 cd $BUILD_DIR/yasm*
314 ./configure --prefix=$TARGET_DIR
315 make -j $jval
316 make install
317
318 echo "*** Building zlib ***"
319 cd $BUILD_DIR/zlib*
320 ./configure --prefix=$TARGET_DIR --enable-shared
321 make -j $jval
322 make install
323
324 echo "*** Building bzip2 ***"
325 cd $BUILD_DIR/bzip2*
326 make -f Makefile-libbz2_so
327 make install PREFIX=$TARGET_DIR
328
329 #echo "*** Building libpng ***"
330 #cd $BUILD_DIR/libpng*
331 #./configure --prefix=$TARGET_DIR --enable-static --disable-shared
332 #make -j $jval
333 #make install
334
335 # Ogg before vorbis
336 echo "*** Building libogg ***"
337 cd $BUILD_DIR/libogg*
338 ./configure --prefix=$TARGET_DIR --enable-shared
339 make -j $jval
340 make install
341
342 # Vorbis before theora
343 echo "*** Building libvorbis ***"
344 cd $BUILD_DIR/libvorbis*
345 ./configure --prefix=$TARGET_DIR --enable-shared
346 make -j $jval
347 make install
348
349 echo "*** Building libtheora ***"
350 cd $BUILD_DIR/libtheora*
351 ./configure --prefix=$TARGET_DIR --enable-shared
352 make -j $jval
353 make install
354
355 echo "*** Building livpx ***"
356 cd $BUILD_DIR/libvpx*
357 ./configure --prefix=$TARGET_DIR --enable-shared
358 make -j $jval
359 make install
360
361 #echo "*** Building faac ***"
362 #cd $BUILD_DIR/faac*
363 #./configure --prefix=$TARGET_DIR --enable-static --disable-shared
364 # FIXME: gcc incompatibility, does not work with log()
365
366 #sed -i -e "s|^char \*strcasestr.*|//\0|" common/mp4v2/mpeg4ip.h
367 #make -j $jval
368 #make install
369
370 echo "*** Building x264 ***"
371 cd $BUILD_DIR/x264*
372 ./configure --prefix=$TARGET_DIR --enable-shared --disable-opencl
373 make -j $jval
374 make install
375
376 echo "*** Building xvidcore ***"
377 cd "$BUILD_DIR/xvidcore/build/generic"
378 ./configure --prefix=$TARGET_DIR --enable-shared
379 make -j $jval
380 make install
381 #rm $TARGET_DIR/lib/libxvidcore.so.*
382
383 echo "*** Building lame ***"
384 cd $BUILD_DIR/lame*
385 ./configure --prefix=$TARGET_DIR --enable-shared
386 make -j $jval
387 make install
388
389 echo "*** Building opus ***"
390 cd $BUILD_DIR/opus*
391 ./configure --prefix=$TARGET_DIR --enable-shared
392 make -j $jval
393 make install
394
395 rm -f $TARGET_DIR/lib/*.a
396 rm -f $TARGET_DIR/usr/local/lib/*.a
397
398 # FFMpeg
399 echo "*** Building FFmpeg ***"
400 cd $BUILD_DIR/ffmpeg*
401 CFLAGS="-I$TARGET_DIR/include -I$TARGET_DIR/usr/local/include" LDFLAGS="-L$TARGET_DIR/lib -L$TARGET_DIR/usr/local/lib -lm" PKG_CONFIG_PATH=$TARGET_DIR/lib/pkgconfig:$TARGET_DIR/usr/local/lib/pkgconfig ./configure \
402         --prefix=${OUTPUT_DIR:-$TARGET_DIR} \
403         --extra-cflags="-I$TARGET_DIR/include -fexceptions -fnon-call-exceptions -fPIC" \
404         --extra-ldflags="-L$TARGET_DIR/lib -lm -llzma" \
405         --disable-doc \
406         --disable-ffplay \
407         --disable-ffserver \
408         --disable-stripping \
409         --enable-shared \
410         --enable-avisynth \
411         --enable-bzlib \
412         --enable-fontconfig \
413         --enable-frei0r \
414         --enable-gnutls \
415         --enable-gpl \
416         --enable-iconv \
417         --enable-libass \
418         --enable-libbluray \
419         --enable-libfreetype \
420         --enable-libgme \
421         --enable-libgsm \
422         --enable-libilbc \
423         --enable-libmodplug \
424         --enable-libmp3lame \
425         --enable-libopencore-amrnb \
426         --enable-libopencore-amrwb \
427         --enable-libopenjpeg \
428         --enable-libopus \
429         --enable-librtmp \
430         --enable-libschroedinger \
431         --enable-libsoxr \
432         --enable-libspeex \
433         --enable-libtheora \
434         --enable-libtwolame \
435         --enable-libvidstab \
436         --enable-libvo-aacenc \
437         --enable-libvo-amrwbenc \
438         --enable-libvorbis \
439         --enable-libvpx \
440         --enable-libwavpack \
441         --enable-libwebp \
442         --enable-libx264 \
443         --enable-libx265 \
444         --enable-libxavs \
445         --enable-libxvid \
446         --enable-pthreads \
447         --enable-version3 \
448         --enable-libv4l2 \
449         --enable-zlib
450 make -j $jval && make install
451
452 #dirty hack
453 #replace shipped ffmpeg linux libs with compiled ones from here!
454 cd $BUILD_DIR
455 mv ../../bin/linux ../../bin/linux-shipped
456 cp -r ../target/lib ../../bin/linux
457 #some ffmpeg libs are build in a different shared target folder
458 cp ../target/usr/local/lib/* ../../bin/linux/