source: npl/mediabox/ffmpeg/ffmpeg.SlackBuild.orig

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 57.8 KB
Line 
1#!/bin/bash
2# $Id: ffmpeg.SlackBuild,v 1.82 2016/07/07 12:46:21 root Exp root $
3# Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016  Eric Hameleers, Eindhoven, NL
4# All rights reserved.
5#
6#   Permission to use, copy, modify, and distribute this software for
7#   any purpose with or without fee is hereby granted, provided that
8#   the above copyright notice and this permission notice appear in all
9#   copies.
10#
11#   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
12#   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13#   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
14#   IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
15#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
17#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18#   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19#   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20#   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
21#   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22#   SUCH DAMAGE.
23# -----------------------------------------------------------------------------
24#
25# Slackware SlackBuild script
26# ===========================
27# By:         Eric Hameleers <alien@slackware.com>
28# For:        ffmpeg
29# Descr:      software to record, convert and stream audio and video
30# URL:        http://ffmpeg.org/
31# Needs:      yasm (only compile-time)
32# Changelog:
33# 20070519-1: 19/May/2007 by Eric Hameleers <alien@slackware.com>
34#             * Initial build.
35#               Note that the version is set to the current date
36#               (using `date +%Y%d%m` output) when you build ffmpeg
37#               from source using this SlackBuild.
38#               You can override this behaviour by prepending a specific
39#               value for VERSION to the build command, like so:
40#               VERSION=20070519 ./ffmpeg.SlackBuild
41# 20070612-1: 12/jun/2007 by Eric Hameleers <alien@slackware.com>
42#             * Update. Also, make sure that the script actually works
43#               for newer snapshots if they should be downloaded.
44# 20071006-1: 06/oct/2007 by Eric Hameleers <alien@slackware.com>
45#             * Update. Added documentation of the included libraries.
46# 20071209-1: 09/dec/2007 by Eric Hameleers <alien@slackware.com>
47#             * Update of ffmpeg snapshot plus several of the support libs.
48#               Re-added AMR libraries, added libgsm and 1394 (firewire)
49#               support, and messed up the SlackBuild script pretty good.
50#               Added a download function for checking out SVN/CVS snapshots,
51#               which can easily be expanded for multiple snapshots.
52# 20080303-1: 03/mar/2008 by Eric Hameleers <alien@slackware.com>
53#             * Update of ffmpeg and x264 snapshots to their latest versions.
54#               Added dirac codec support. Internally use variable FFMPEG
55#               instead of VERSION to determine the version of ffmpeg to use
56#               (allows me to use a SVN revision number instead of timestamp).
57# r14080-1:   05/aug/2008 by Eric Hameleers <alien@slackware.com>
58#             * Update of almost all composing libraries. The dirac reference
59#               implementation library was replaced by schroedinger.
60#               This version of the package includes shared libraries which
61#               allows other programs to link to avcodec.
62#               If you install yasm, the SlackBuild will be able to use a
63#               very recent version of the x264 library, else it will fallback
64#               to a version that compiles with Slackware's 'asm'.
65# r16039-1:   09/dec/2008 by Eric Hameleers <alien@slackware.com>
66#             * Updated to the 20081209 snapshot. Also updated x264 and lame
67#               codecs, removed liba52 (because ffmpeg now has it's own native
68#               implementation) and added speex codec.
69# r16043-1:   10/dec/2008 by Eric Hameleers <alien@slackware.com>
70#             * Update. Also updated libraw1394 & libdc1394 to their 2.x
71#               versions and made small adaptations so that the script actually
72#               produces working binaries on x86_64
73# 0.5-1:      20/mar/2009 by Eric Hameleers <alien@slackware.com>
74#             * First new official release in ages. Add x264 presets to the
75#               package (idea borrowed from the script at slackbuilds.org).
76# 0.5-2:      13/may/2009 by Eric Hameleers <alien@slackware.com>
77#             * Updates to faac/faad/schro
78# r20056-1:   27/sep/2009 by Eric Hameleers <alien@slackware.com>
79#             * Update. AMR implementation from OpenCORE with a free license
80#               allows to add AMR support to the distributable package.
81#               Also updated the X264 snapshot and libgsm.
82# r22900-1:   26/apr/2010 by Eric Hameleers <alien@slackware.com>
83#             * New snapshot. Updated the schroedinger codec, which is now
84#               on par speed-wise with the dirac codec. Also updated the x264
85#               snapshot (x264 can now produce blu-ray compliant video),
86#               and updated the lame and dc1394 versions. Added support for
87#               RTMP(E) - flash - streams through librtmp.
88# r23357-1:   28/may/2010 by Eric Hameleers <alien@slackware.com>
89#             * New snapshot. Added libvpx plus patches for ffmpeg which
90#               enable support for WebM/VP8 (google-donated new video format).
91# 0.6-1:      18/jun/2010 by Eric Hameleers <alien@slackware.com>
92#             * A stable release. The internal libvpx library was updated to
93#               0.9.1 (no patching needed now), rtmpdump to 2.2e and x264
94#               to a recent snapshot.
95#               I also added VAAPI hardware acceleration support. Look further
96#               down in this script (in the header of the "make_libva" function)
97#               how you can benefit from GPU-accelerated encoding/decoding.
98# 0.6.1-1:    02/feb/2011 by Eric Hameleers <alien@slackware.com>
99#             * I forgot to update to a newer stable release.
100#               Updated internal codecs where available.
101# 0.6.3-1:    12/may/2011 by Eric Hameleers <alien@slackware.com>
102#             * Updated for Slackware 13.37.
103# 0.8.2-1:    11/aug/2011 by Eric Hameleers <alien@slackware.com>
104#             * Update. Add opencore's new AMR-WB and AAC encoders created
105#               for Android by VisualOn: 'libvo-amrwnenc' and 'libvo-aacenc'.
106#               And updated every built-in support library to their latest
107#               version.
108# 0.8.5-1:    07/oct/2011 by Eric Hameleers <alien@slackware.com>
109#             * New release. Also updated versions of internal vpx and x264
110#               libraries. Fix the compilation in case the x264 libraries are
111#               already installed on the system.
112# 0.8.6-1:    08/nov/2011 by Eric Hameleers <alien@slackware.com>
113#             * New release. Also updated versions of internal lame, orc,
114#               x264 libraries.
115# 0.8.7-1:    22/nov/2011 by Eric Hameleers <alien@slackware.com>
116#             * New release.
117# 0.9-1:      13/dec/2011 by Eric Hameleers <alien@slackware.com>
118#             * New release.  Added internal libass (subtitle) and v4l2 support.
119# 0.10.2-1:   05/may/2012 by Eric Hameleers <alien@slackware.com>
120#             * New release.
121# 0.10.3-1:   26/may/2012 by Eric Hameleers <alien@slackware.com>
122#             * Update.
123# 0.11-1:     03/jun/2012 by Eric Hameleers <alien@slackware.com>
124#             * Update.
125# 0.11.2-1:   27/sep/2012 by Eric Hameleers <alien@slackware.com>
126#             * Update.
127# 1.1.2-1:    13/feb/2013 by Eric Hameleers <alien@slackware.com>
128#             * Update. Also updated many internal libraries.
129#               Added ogg opus decoder.
130# 1.2-1:      13/apr/2013 by Eric Hameleers <alien@slackware.com>
131#             * Update.
132# 2.1-1:      26/dec/2013 by Eric Hameleers <alien@slackware.com>
133#             * Update.
134# 2.2.1-1:    02/may/2014 by Eric Hameleers <alien@slackware.com>
135#             * Update. Add teletext subtitle support.
136# 2.4.3-1:    12/nov/2014 by Eric Hameleers <alien@slackware.com>
137#             * Update. Added fdk-aac codec by Android Open Source Project,
138#               and X.265 (HEVC) codec by Videolan project..
139# 2.7.2-1:    07/sep/2015 by Eric Hameleers <alien@slackware.com>
140#             * Update. Also updated internal libraries: fdkaac, libass,
141#               libva, libvdpau, speex, x264, x265
142# 2.8-1:      24/sep/2015 by Eric Hameleers <alien@slackware.com>
143#             * Update. Enabled SSL support (openssl in the non-free package,
144#               gnutls in the patent-free package).
145#               Updated internal libraries: libvpx, x264.
146# 3.1.1-1:    06/jul/2016 by Eric Hameleers <alien@slackware.com>
147#             * Update. Updated internal libraries: opus, orc, v4l, vaapi,
148#               vpx, x264, x265.
149#               Support for libvo-aacenc was dropped from ffmpeg.
150#               
151# Run 'sh ffmpeg.SlackBuild' to build a Slackware package.
152# The package (.txz) plus descriptive .txt file are created in /tmp .
153# Install using 'installpkg'.
154#
155# -----------------------------------------------------------------------------
156
157# -- PATENT ALERT! --
158# FFmpeg can be built with MP3 audio encoder (needed for FLV videos) and AAC
159# audio encoder (used in MP4) but these libraries are 'contaminated'
160# with patents from Fraunhofer, Apple etc.
161# You can build these patended algorithms into ffmpeg, and if you are an
162# ordinary end user, no one will bother you for using them.
163# For the binaries based on this SlackBuild that I distribute, it is a
164# different story. I am not allowed to distribute binary packages that
165# incorporate non-free code. So here you go. My Slackware package was built
166# with "USE_PATENTS=NO" i.e. without using the lame mp3 and aac libs.
167#USE_PATENTS="NO"
168USE_PATENTS=${USE_PATENTS:-"YES"}
169
170# I don't care if the user says "no" or "NO":
171USE_PATENTS=$(echo $USE_PATENTS | tr 'a-z' 'A-Z')
172
173PRGNAM=ffmpeg
174VERSION=${VERSION:-3.1.1}
175BUILD=${BUILD:-1}
176NUMJOBS=${NUMJOBS:--j7}
177TAG=${TAG:-"alien"}
178
179DOCS="COPYING* CREDITS Changelog MAINTAINERS README* \
180      doc/TODO doc/*.txt doc/*.html"
181DOCS_AACPLUS="AUTHORS COPYING* ChangeLog NEWS README TODO"
182DOCS_AMR="AUTHORS COPYING ChangeLog LICENSE NEWS README"
183DOCS_AMRWBENC="AUTHORS COPYING ChangeLog LICENSE NEWS NOTICE README"
184DOCS_ASS="COPYING Changelog"
185DOCS_AVC1394="AUTHORS COPYING ChangeLog INSTALL NEWS README"
186DOCS_DC1394="AUTHORS COPYING ChangeLog INSTALL NEWS README"
187DOCS_FAAC="AUTHORS COPYING* ChangeLog NEWS README* TODO"
188DOCS_FAAD2="AUTHORS COPYING* ChangeLog NEWS README* TODO"
189DOCS_FDKAAC="ChangeLog NOTICE"
190DOCS_FRIBIDI="AUTHORS COPYING ChangeLog NEWS README THANKS TODO"
191DOCS_GSM="COPYRIGHT ChangeLog* INSTALL MACHINES MANIFEST README"
192DOCS_LAME="API COPYING ChangeLog HACKING LICENSE README STYLEGUIDE TODO USAGE"
193DOCS_LIBVA="COPYING"
194DOCS_LIBZVBI="AUTHORS BUGS COPYING COPYING.LIB ChangeLog INSTALL NEWS README TODO"
195DOCS_OPUS="AUTHORS COPYING ChangeLog NEWS README"
196DOCS_ORC="COPYING README TODO"
197DOCS_RAW1394="AUTHORS COPYING ChangeLog INSTALL NEWS README"
198DOCS_RTMP="AUTHORS COPYING ChangeLog README"
199DOCS_SCHROEDINGER="AUTHORS COPYING* NEWS TODO"
200DOCS_SPEEX=" AUTHORS COPYING ChangeLog NEWS README* TODO"
201DOCS_V4L2="COPYING* ChangeLog README* TODO"
202DOCS_VDPAU="AUTHORS COPYING ChangeLog NEWS README"
203DOCS_VPX="AUTHORS CHANGELOG LICENSE README"
204DOCS_X264="AUTHORS COPYING"
205DOCS_X265="AUTHORS COPYING"
206
207# Support libraries:
208AACPLUS=2.0.2
209AMRWBENC=0.1.3
210AMR=0.1.3
211ASS=0.12.1
212AVC1394=0.5.4
213DC1394=2.1.2
214FAAC=1.28
215FAAD2=2.7
216FDKAAC=0.1.4
217FRIBIDI=0.19.6
218GSM=1.0.13
219LAME=3.99.5
220LIBVA=1.6.2
221LIBZVBI=0.2.35
222OPUS=1.1.2
223ORC=0.4.25
224RAW1394=2.0.5
225RTMP=2.3
226SCHROEDINGER=1.0.11
227SPEEX=1.2rc2
228V4L=1.10.1
229VDPAU=1.1.1
230VPX=1.5.0
231X264=20160706-2245
232X265=1.9
233
234# Where do we look for sources?
235SRCDIR=$(cd $(dirname $0); pwd)
236
237# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
238TMP=${TMP:-/tmp/build}
239PKG=$TMP/package-$PRGNAM
240OUTPUT=${OUTPUT:-/tmp}
241
242# Check for yasm, abort if not found:
243if ! which yasm >/dev/null 2>&1 ; then
244  echo "##"
245  echo "## The 'yasm' program does not seem to be installed."
246  echo "## The X264/VP8 codec compilation needs yasm (nasm will not do)!"
247  echo "## Aborting the build."
248  echo "##"
249  exit 1
250fi
251
252# ---------------------------------------------------------------------------
253# Source tarballs and source URLs.
254# Sources which are not patented should have SRCPAT[n]="NO"
255# Sources which are patented should have SRCPAT[n]="YES" which prevents then
256#   from being downloaded and used if we build a patent-free package.
257# ---------------------------------------------------------------------------
258
259# FFMPEG sources:
260if [ "$VERSION" == "HEAD"  ]; then
261  # We check out git's HEAD:
262  BRANCH="master"
263  GITURI=git://git.videolan.org/ffmpeg.git
264  SRCVER=$(date +%Y%m%d)
265  SRCURL[0]=""
266elif [ "$(echo $VERSION | cut -c1-2)" == "20"  ]; then
267  # We check out git at a specific date:
268  BRANCH="master"
269  GITURI=git://git.videolan.org/ffmpeg.git
270  SRCVER=$VERSION
271  SRCURL[0]=""
272else
273  BRANCH=""
274  GITURI=""
275  SRCVER=$VERSION
276  SRCURL[0]="http://ffmpeg.org/releases/ffmpeg-${SRCVER}.tar.bz2"
277fi
278
279SOURCE[0]="$SRCDIR/ffmpeg-${SRCVER}.tar.bz2"
280SRCPAT[0]="NO"
281
282# Orc (oil runtime compiler) is a dependency for schroedinger
283SOURCE[1]="$SRCDIR/orc-${ORC}.tar.xz"
284SRCURL[1]="https://gstreamer.freedesktop.org/src/orc/orc-${ORC}.tar.xz"
285SRCPAT[1]="NO"
286
287# Dirac video codec support by schroedinger:
288SOURCE[2]="$SRCDIR/schroedinger-${SCHROEDINGER}.tar.gz"
289SRCURL[2]="http://www.diracvideo.org/download/schroedinger/schroedinger-${SCHROEDINGER}.tar.gz"
290SRCPAT[2]="NO"
291
292# SPEEX audio codec:
293SOURCE[3]="$SRCDIR/speex-${SPEEX}.tar.gz"
294SRCURL[3]="http://downloads.us.xiph.org/releases/speex/speex-${SPEEX}.tar.gz"
295SRCPAT[3]="NO"
296
297# X264 encoder - for H264/AVC video streams, for static linking
298SOURCE[4]="$SRCDIR/x264-snapshot-${X264}.tar.bz2"
299SRCURL[4]="ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-${X264}.tar.bz2"
300SRCPAT[4]="NO"
301
302# FAAD2 support:
303SOURCE[5]="$SRCDIR/faad2-$FAAD2.tar.gz"
304SRCURL[5]="http://downloads.sourceforge.net/faac/faad2-$FAAD2.tar.gz"
305SRCPAT[5]="NO"
306
307# GSM support:
308SOURCE[6]="$SRCDIR/gsm-$GSM.tar.gz"
309SRCURL[6]="http://osxwinebuilder.googlecode.com/files/gsm-$GSM.tar.gz"
310SRCPAT[6]="NO"
311
312# Lame is used for the audio in FLV videos; will statically link with ffmpeg
313SOURCE[7]="$SRCDIR/lame-$LAME.tar.gz"
314SRCURL[7]="http://downloads.sourceforge.net/lame/lame-$LAME.tar.gz"
315SRCPAT[7]="YES"
316
317# Library to support the AVC (Audio/Video Control) Digital Interface Command Set
318SOURCE[8]="$SRCDIR/libavc1394-${AVC1394}.tar.gz"
319SRCURL[8]="http://downloads.sourceforge.net/libavc1394/libavc1394-${AVC1394}.tar.gz"
320SRCPAT[8]="NO"
321
322# Library needed to control IEEE 1394 (firewire-) based cameras
323SOURCE[9]="$SRCDIR/libraw1394-${RAW1394}.tar.gz"
324SRCURL[9]="http://downloads.sourceforge.net/libraw1394/libraw1394-${RAW1394}.tar.gz"
325SRCPAT[9]="NO"
326
327SOURCE[10]="$SRCDIR/libdc1394-${DC1394}.tar.gz"
328SRCURL[10]="http://downloads.sourceforge.net/libdc1394/libdc1394-${DC1394}.tar.gz"
329SRCPAT[10]="NO"
330
331# librtmp library, supporting RTMP streams
332SOURCE[11]="$SRCDIR/rtmpdump-${RTMP}.tgz"
333SRCURL[11]="http://rtmpdump.mplayerhq.hu/download/rtmpdump-${RTMP}.tgz"
334SRCPAT[11]="NO"
335
336# libvpx library, containing the VP8 codec
337SOURCE[12]="$SRCDIR/libvpx-${VPX}.tar.bz2"
338SRCURL[12]="http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-${VPX}.tar.bz2"
339SRCPAT[12]="NO"
340
341# Library supporting VAAPI (GPU-accelerated video playback interface)
342SOURCE[13]="$SRCDIR/libva-${LIBVA}.tar.bz2"
343SRCURL[13]="http://www.freedesktop.org/software/vaapi/releases/libva/libva-${LIBVA}.tar.bz2"
344SRCPAT[13]="NO"
345
346# AMR-WB encoder libraries used to encode 3GPP audio
347SOURCE[14]="$SRCDIR/vo-amrwbenc-${AMRWBENC}.tar.gz"
348SRCURL[14]="http://downloads.sourceforge.net/opencore-amr/vo-amrwbenc-${AMRWBENC}.tar.gz"
349SRCPAT[14]="NO"
350
351# AMR-NB de/encoder and WB decoder libraries used to de/encode 3GPP audio
352SOURCE[15]="$SRCDIR/opencore-amr-${AMR}.tar.gz"
353SRCURL[15]="http://downloads.sourceforge.net/opencore-amr/opencore-amr-${AMR}.tar.gz"
354SRCPAT[15]="NO"
355
356# FAAC library, for AAC (MP4 audio) encoding
357SOURCE[16]="$SRCDIR/faac-$FAAC.tar.gz"
358SRCURL[16]="http://downloads.sourceforge.net/faac/faac-$FAAC.tar.gz"
359SRCPAT[16]="YES"
360
361# Unicode BiDirectional algorithm library, requirement for libass.
362SOURCE[17]="$SRCDIR/fribidi-${FRIBIDI}.tar.bz2"
363SRCURL[17]="http://fribidi.org/download/fribidi-${FRIBIDI}.tar.bz2"
364SRCPAT[17]="NO"
365
366# Libass - portable library for SSA/ASS subtitles rendering
367SOURCE[18]="$SRCDIR/libass-$ASS.tar.xz"
368SRCURL[18]="https://github.com/libass/libass/releases/download/${ASS}/libass-$ASS.tar.xz"
369SRCPAT[18]="NO"
370
371# Collection of video4linux support libraries
372SOURCE[19]="$SRCDIR/v4l-utils-${V4L}.tar.bz2"
373SRCURL[19]="http://linuxtv.org/downloads/v4l-utils/v4l-utils-${V4L}.tar.bz2"
374SRCPAT[19]="NO"
375
376# opus codec:
377SOURCE[20]="$SRCDIR/opus-${OPUS}.tar.gz"
378SRCURL[20]="http://downloads.xiph.org/releases/opus/opus-${OPUS}.tar.gz"
379SRCPAT[20]="NO"
380
381# VDPAU for video hardware acceleration:
382SOURCE[21]="$SRCDIR/libvdpau-${VDPAU}.tar.gz"
383SRCURL[21]="http://people.freedesktop.org/~aplattner/vdpau/libvdpau-${VDPAU}.tar.gz"
384SRCPAT[21]="NO"
385
386# libzvbi for teletext subtitle processing:
387SOURCE[22]="$SRCDIR/zvbi-${LIBZVBI}.tar.bz2"
388SRCURL[22]="http://downloads.sourceforge.net/zapping/zvbi-${LIBZVBI}.tar.bz2"
389SRCPAT[22]="NO"
390
391# fdk-aac en/decoder from the Android Open Source Project (opencore-amr):
392SOURCE[23]="$SRCDIR/fdk-aac-${FDKAAC}.tar.gz"
393SRCURL[23]="http://downloads.sourceforge.net/opencore-amr/fdk-aac-${FDKAAC}.tar.gz"
394SRCPAT[23]="YES"
395
396# Videolan's HEVC (x265) codec:
397SOURCE[24]="$SRCDIR/x265-${X265}.tar.gz"
398SRCURL[24]="http://github.com/videolan/x265/archive/${X265}.tar.gz"
399SRCPAT[24]="NO"
400
401## HE-AAC+ v2 shared library:
402#SOURCE[XX]="$SRCDIR/libaacplus-$AACPLUS.tar.gz"
403#SRCURL[XX]="http://tipok.ath.cx/downloads/media/aac+/libaacplus/libaacplus-${AACPLUS}.tar.gz"
404#SRCPAT[XX]="YES"
405#
406## HE-AAC+ v2 reference implementation:
407#SOURCE[XX]="$SRCDIR/26410-800.zip"
408#SRCURL[XX]="http://www.3gpp.org/ftp/Specs/archive/26_series/26.410/26410-800.zip"
409#SRCPAT[XX]="YES"
410
411
412# Use the src_checkout() function if no downloadable tarball exists.
413# This function checks out sources from SVN/CVS and creates a tarball of them.
414src_checkout() {
415  # Param #1 : index in the SOURCE[] array.
416  # Param #2 : full path to where SOURCE[$i] tarball should be created.
417  # Determine the tarball extension:
418  PEXT=$(echo "${2}" | sed -r -e 's/.*[^.].(tar.xz|tar.gz|tar.bz2|tgz).*/\1/')
419  case "$PEXT" in
420    "tar.xz") TARCOMP="J" ;;
421    "tar.gz") TARCOMP="z" ;;
422    "tgz") TARCOMP="z" ;;
423    "tar.bz2") TARCOMP="j" ;;
424    *) echo "Archive can only have extension 'tar.xz', '.tar.gz' '.tar.bz2' or '.tgz'" ; exit 1 ;;
425  esac
426  case ${1} in
427  0) # ffmpeg-${VERSION}
428     mkdir ${PRGNAM}_temp_checkout_$$ \
429       && cd ${PRGNAM}_temp_checkout_$$
430
431       if [ "$VERSION" = "HEAD" ]; then
432         # Checkout without downloading version history (fast!):
433         echo "Checking out HEAD from '$GITURI':"
434         git clone --depth=1 ${GITURI} ${PRGNAM}-${SRCVER}
435       else
436         # Checkout code from a certain branch and/or date; this will take a
437         # long time because we have to clone the complete git-repository first:
438         echo "Checking out $BRANCH at date $SRCVER from '$GITURI':"
439         git clone ${GITURI} ${PRGNAM}-${SRCVER} \
440         && cd ${PRGNAM}-${SRCVER} \
441         && git checkout $BRANCH \
442         && git checkout $(git rev-list -n 1 --before="`date -d $SRCVER`" $BRANC
443H) \
444         && cd ..
445       fi
446       chown -R root:root . \
447       && tar --exclude .git -${TARCOMP}cf ${2} ${PRGNAM}-${SRCVER}
448     cd ..
449     rm -rf ${PRGNAM}_temp_checkout_$$
450     # If VERSION was "HEAD" we still want a date to appear in the pkgname:
451     VERSION=${SRCVER}
452     ;;
453  13) # We clone the git of libvpx at a certain date:
454     mkdir libvpx-${VPX} \
455       && cd libvpx-${VPX} \
456       && git clone git://review.webmproject.org/libvpx.git . \
457       && git checkout $(git rev-list -n 1 --before="`date -d $VPX`" master) \
458       && chown -R root:root . \
459       && cd .. \
460       && tar --exclude .git -${TARCOMP}cf ${2} libvpx-${VPX}
461     rm -rf libvpx-${VPX}
462     ;;
463  *) # Do nothing
464     ;;
465  esac
466}
467
468if [ "${USE_PATENTS}" == "YES" ]; then
469  echo ""
470  echo "**"
471  echo "** This build uses patented code (MP3 and AAC encoders)"
472  echo "** Run the command 'USE_PATENTS=NO $0 $*' to avoid patent issues."
473  echo "**"
474  echo ""
475  sleep 1
476fi
477
478##
479## --- with a little luck, you won't have to edit below this point --- ##
480##
481
482# Automatically determine the architecture we're building on:
483MARCH=$( uname -m )
484if [ -z "$ARCH" ]; then
485  case "$MARCH" in
486    i?86)    export ARCH=i486 ;;
487    armv7hl) export ARCH=$MARCH ;;
488    arm*)    export ARCH=arm ;;
489    # Unless $ARCH is already set, use uname -m for all other archs:
490    *)       export ARCH=$MARCH ;;
491  esac
492fi
493
494case "$ARCH" in
495  i486)      SLKCFLAGS="-O2 -march=i486 -mtune=i686"
496             SLKLDFLAGS=""; LIBDIRSUFFIX=""
497             ;;
498  x86_64)    SLKCFLAGS="-O2 -fPIC"
499             SLKLDFLAGS="-L/usr/lib64 -fPIC"; LIBDIRSUFFIX="64"
500             ;;
501  arm*)       SLKCFLAGS="-O2 -march=armv5te"
502             SLKLDFLAGS=""; LIBDIRSUFFIX=""
503             ;;
504  armv7hl)   SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16"
505             SLKLDFLAGS=""; LIBDIRSUFFIX=""
506             ;;
507  *)         SLKCFLAGS="-O2"
508             SLKLDFLAGS=""; LIBDIRSUFFIX=""
509             ;;
510esac
511
512case "$ARCH" in
513    arm*) TARGET=$ARCH-slackware-linux-gnueabi ;;
514    *)    TARGET=$ARCH-slackware-linux ;;
515esac
516
517# Exit the script on errors:
518set -e
519#trap 'echo "$0 FAILED at line $LINENO!" | tee $OUTPUT/error-${PRGNAM}.log' ERR
520# Catch unitialized variables:
521set -u
522P1=${1:-1}
523
524# Save old umask and set to 0022:
525_UMASK_=$(umask)
526umask 0022
527
528# Create working directories:
529mkdir -p $TMP/tmp-$PRGNAM # location to build the source
530if [ "$P1" != "--oldbuild" ]; then
531  # If the "--oldbuild" parameter is present, we keep
532  #  the old build files and continue;
533  # By default we remove the remnants of previous build and continue:
534  rm -rf $TMP/tmp-$PRGNAM/* $OUTPUT/*${PRGNAM}*.log
535fi
536mkdir -p $PKG     # place for the package to be built
537rm -rf $PKG/*     # We always erase old package's contents:
538mkdir -p $OUTPUT  # place for the package to be saved
539
540# Source file availability:
541
542# Regular URL downloads follow:
543for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
544  # Only download patented code if we are allowing it:
545  if [ "${USE_PATENTS}" == "YES" -o "${SRCPAT[$i]}" != "YES" ]; then
546    if ! [ -f ${SOURCE[$i]} ]; then
547      echo "Source '$(basename ${SOURCE[$i]})' not available yet..."
548      # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
549      [ -w "$SRCDIR" ] || SOURCE[$i]="$OUTPUT/$(basename ${SOURCE[$i]})"
550      if ! [ "x${SRCURL[$i]}" == "x" ]; then
551        echo "Will download file to $(dirname $SOURCE[$i])"
552        if ! $(wget --no-check-certificate -nv -T 20 -O "${SOURCE[$i]}" "${SRCURL[$i]}"); then
553          echo "Downloading '$(basename ${SOURCE[$i]})' failed.. aborting the build."
554          mv -f "${SOURCE[$i]}" "${SOURCE[$i]}".FAIL
555          exit 1
556        fi
557      else
558        # Try if we have a SVN/CVS download routine for ${SOURCE[$i]}
559        echo "Will checkout sources to $(dirname $SOURCE[$i])"
560        src_checkout $i "${SOURCE[$i]}"
561      fi
562      if [ ! -f "${SOURCE[$i]}" -o ! -s "${SOURCE[$i]}" ]; then
563        echo "File '$(basename ${SOURCE[$i]})' not available.. aborting the build."
564        exit 1
565      fi
566    fi
567  fi
568done
569
570if [ "$P1" == "--download" ]; then
571  echo "Download complete."
572  exit 0
573fi
574
575# --- PACKAGE BUILDING ---
576
577echo "++"
578echo "|| $PRGNAM-$VERSION"
579echo "++"
580
581cd $TMP/tmp-$PRGNAM
582if [ "$P1" != "--oldbuild" ]; then
583  echo "Extracting the source archive(s) for $PRGNAM..."
584  for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
585    # Only extract patented code if we are allowing it:
586    if [ "${USE_PATENTS}" == "YES" -o "${SRCPAT[$i]}" != "YES" ]; then
587      if $(file ${SOURCE[$i]} | grep -qi ": zip"); then
588        unzip ${SOURCE[$i]}
589      else
590        tar -xvf ${SOURCE[$i]}
591      fi
592    fi
593  done
594fi
595chown -R root:root *
596chmod -R u+w,go+r-w,a+X-s *
597
598# --- BUILDING ---
599
600echo Building ...
601
602# We will be installing static libs into the following directory:
603# (when linking ffmpeg together, these libs will be found & used)
604mkdir -p $TMP/tmp-$PRGNAM/ffmpegdeps/usr/{bin,include,lib,man}
605FFMPEGDEPSDIR="$TMP/tmp-$PRGNAM/ffmpegdeps"
606
607# -----------------------------------------------------------------------------
608# Compile lame libraries
609# The ffmpeg will use these
610# -----------------------------------------------------------------------------
611make_lame()
612{
613echo -e "**\n**  lame ...\n**"
614cd $TMP/tmp-$PRGNAM/lame-${LAME}
615# Fix compilation on x86 (xmmintrin.h error: inlining failed)
616cat $SRCDIR/patches/lame_x86-xmmintrin.patch | patch -p1 --verbose \
617  2>&1
618
619CFLAGS="$SLKCFLAGS" \
620CXXFLAGS="$SLKCFLAGS" \
621LDFLAGS="$SLKLDFLAGS" \
622./configure \
623  --prefix=/usr \
624  --libdir=/usr/lib${LIBDIRSUFFIX} \
625  --enable-static \
626  --disable-shared \
627  --program-prefix= \
628  --program-suffix= \
629  --build=$TARGET \
630  2>&1
631make ${NUMJOBS} 2>&1
632# Install lame into a temp location so ffmpeg can pickup the library
633make install DESTDIR=$FFMPEGDEPSDIR \
634  2>&1
635# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
636mkdir -p $FFMPEGDEPSDIR/doc/lame
637cp -a $DOCS_LAME $FFMPEGDEPSDIR/doc/lame/ || true
638cd -
639}
640
641
642# -----------------------------------------------------------------------------
643# Compile amr wideband/narrowband library
644# The ffmpeg will use these
645# -----------------------------------------------------------------------------
646make_amr()
647{
648echo -e "**\n**  amr ...\n**"
649cd $TMP/tmp-$PRGNAM/opencore-amr-${AMR}
650LDFLAGS="$SLKLDFLAGS" \
651CXXFLAGS="$SLKCFLAGS" \
652CFLAGS="$SLKCFLAGS" \
653./configure \
654  --prefix=/usr \
655  --libdir=/usr/lib${LIBDIRSUFFIX} \
656  --mandir=/usr/man \
657  --localstatedir=/var \
658  --sysconfdir=/etc \
659  --disable-shared \
660  --program-prefix= \
661  --program-suffix= \
662  --build=$TARGET \
663  2>&1
664make $NUMJOBS 2>&1
665make install DESTDIR=$FFMPEGDEPSDIR PREFIX=/usr LIBDIR=/usr/lib${LIBDIRSUFFIX} \
666  2>&1
667# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
668mkdir -p $FFMPEGDEPSDIR/doc/amr
669cp -a $DOCS_AMR $FFMPEGDEPSDIR/doc/amr || true
670cd -
671}
672
673
674# -----------------------------------------------------------------------------
675# Compile VisualOn amr wideband encoder library
676# The ffmpeg will use these
677# -----------------------------------------------------------------------------
678make_amrwbenc()
679{
680echo -e "**\n**  amrwbenc ...\n**"
681cd $TMP/tmp-$PRGNAM/vo-amrwbenc-${AMRWBENC}
682LDFLAGS="$SLKLDFLAGS" \
683CXXFLAGS="$SLKCFLAGS" \
684CFLAGS="$SLKCFLAGS" \
685./configure \
686  --prefix=/usr \
687  --libdir=/usr/lib${LIBDIRSUFFIX} \
688  --mandir=/usr/man \
689  --localstatedir=/var \
690  --sysconfdir=/etc \
691  --disable-shared \
692  --program-prefix= \
693  --program-suffix= \
694  --build=$TARGET \
695  2>&1
696make $NUMJOBS 2>&1
697make install DESTDIR=$FFMPEGDEPSDIR PREFIX=/usr LIBDIR=/usr/lib${LIBDIRSUFFIX} \
698  2>&1
699# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
700mkdir -p $FFMPEGDEPSDIR/doc/amrwbenc
701cp -a $DOCS_AMRWBENC $FFMPEGDEPSDIR/doc/amrwbenc || true
702cd -
703}
704
705
706# -----------------------------------------------------------------------------
707# Compile fdk-aac library
708# The ffmpeg will use these
709# -----------------------------------------------------------------------------
710make_fdkaac()
711{
712echo -e "**\n**  fdkaac ...\n**"
713cd $TMP/tmp-$PRGNAM/fdk-aac-${FDKAAC}
714
715CFLAGS="$SLKCFLAGS" \
716CXXFLAGS="$SLKCFLAGS" \
717LDFLAGS="$SLKLDFLAGS" \
718./configure \
719  --prefix=/usr \
720  --libdir=/usr/lib${LIBDIRSUFFIX} \
721  --enable-static \
722  --disable-shared \
723  --program-prefix= \
724  --program-suffix= \
725  --build=$TARGET \
726  2>&1
727make ${NUMJOBS} 2>&1
728# Install fdkaac into a temp location so ffmpeg can pickup the library
729make install DESTDIR=$FFMPEGDEPSDIR \
730  2>&1
731# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
732mkdir -p $FFMPEGDEPSDIR/doc/fdkaac
733cp -a $DOCS_FDKAAC $FFMPEGDEPSDIR/doc/fdkaac || true
734cd -
735}
736
737
738# -----------------------------------------------------------------------------
739# Compile x265 library
740# The ffmpeg will use these
741# -----------------------------------------------------------------------------
742make_x265()
743{
744echo -e "**\n**  x265 ...\n**"
745PREVDIR=$(pwd)
746cd $TMP/tmp-$PRGNAM/x265-${X265}
747
748mkdir -p build_x265
749cd build_x265
750  cmake ../source \
751    -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
752    -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
753    -DCMAKE_LDFLAGS:STRING="$SLKLDFLAGS" \
754    -DCMAKE_INSTALL_PREFIX=/usr \
755    -DLIB_INSTALL_DIR=lib${LIBDIRSUFFIX} \
756    -DENABLE_SHARED=OFF \
757  2>&1
758  make ${NUMJOBS} 2>&1
759  # Install x265 into a temp location so ffmpeg can pickup the library
760  make install DESTDIR=$FFMPEGDEPSDIR \
761    2>&1
762cd -
763# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
764mkdir -p $FFMPEGDEPSDIR/doc/x265
765cp -a $DOCS_X265 $FFMPEGDEPSDIR/doc/x265 || true
766cd $PREVDIR
767}
768
769
770# -----------------------------------------------------------------------------
771# Compile aacplus library
772# The ffmpeg will use this
773# -----------------------------------------------------------------------------
774make_aacplus ()
775{
776echo -e "**\n**  aacplus ...\n**"
777cd $TMP/tmp-$PRGNAM/libaacplus-${AACPLUS}
778
779# This needs the sources of the HE-AAC+ reference implementation:
780cp $SRCDIR/26410-800.zip src/
781
782[ ! -x configure  ] && autoreconf -vif
783
784CFLAGS="$SLKCFLAGS" \
785CXXFLAGS="$SLKCFLAGS" \
786LDFLAGS="$SLKLDFLAGS" \
787./configure \
788  --prefix=/usr \
789  --libdir=/usr/lib${LIBDIRSUFFIX} \
790  --enable-static \
791  --disable-shared \
792  --program-prefix= \
793  --program-suffix= \
794  --build=$TARGET \
795  2>&1
796# Do not use parallel make here:
797make 2>&1
798# Install aacplus into a temp location so ffmpeg can pickup the library
799make install DESTDIR=$FFMPEGDEPSDIR \
800  2>&1
801# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
802mkdir -p $FFMPEGDEPSDIR/doc/aacplus
803cp -a $DOCS_AACPLUS $FFMPEGDEPSDIR/doc/aacplus || true
804cd -
805}
806
807# -----------------------------------------------------------------------------
808# Compile dc1394, avc1394 and raw1394 libraries
809# The ffmpeg will use these
810# -----------------------------------------------------------------------------
811make_1394()
812{
813echo -e "**\n**  1394 ...\n**"
814OLDDIR=$(pwd)
815cd $TMP/tmp-$PRGNAM/libraw1394-${RAW1394}
816CFLAGS="$SLKCFLAGS" \
817CXXFLAGS="$SLKCFLAGS" \
818LDFLAGS="$SLKLDFLAGS" \
819./configure \
820  --prefix=/usr \
821  --libdir=/usr/lib${LIBDIRSUFFIX} \
822  --mandir=/usr/man \
823  --enable-static \
824  --disable-shared \
825  --program-prefix= \
826  --program-suffix= \
827  --build=$TARGET \
828  2>&1
829make ${NUMJOBS} 2>&1
830# Install libraw1394 into a temp location so ffmpeg can pickup the library
831make install DESTDIR=$FFMPEGDEPSDIR \
832  2>&1
833# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
834mkdir -p $FFMPEGDEPSDIR/doc/libraw1394
835cp -a $DOCS_RAW1394 $FFMPEGDEPSDIR/doc/libraw1394 || true
836
837echo -e "**\n**"
838
839cd $TMP/tmp-$PRGNAM/libavc1394-${AVC1394}
840
841CFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
842CPPFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
843LDFLAGS="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} $SLKLDFLAGS" \
844PKG_CONFIG_PATH="$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
845LIBRAW1394_CFLAGS="-I$FFMPEGDEPSDIR/usr/include" \
846LIBRAW1394_LIBS="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} -lraw1394" \
847./configure \
848  --prefix=/usr \
849  --libdir=/usr/lib${LIBDIRSUFFIX} \
850  --enable-static \
851  --disable-shared \
852  --program-prefix= \
853  --program-suffix= \
854  --build=$TARGET \
855  2>&1
856make ${NUMJOBS} 2>&1
857# Install libavc1394 into a temp location so ffmpeg can pickup the library
858make install DESTDIR=$FFMPEGDEPSDIR 2>&1
859# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
860mkdir -p $FFMPEGDEPSDIR/doc/libavc1394
861cp -a $DOCS_AVC1394 $FFMPEGDEPSDIR/doc/libavc1394 || true
862
863echo -e "**\n**"
864
865cd $TMP/tmp-$PRGNAM/libdc1394-${DC1394}
866
867# Make sure that the static libraw1394 is found in the ffmpegdeps:
868CFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
869CPPFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
870LDFLAGS="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} $SLKLDFLAGS" \
871PKG_CONFIG_PATH="$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
872./configure \
873  --prefix=/usr \
874  --libdir=/usr/lib${LIBDIRSUFFIX} \
875  --enable-static \
876  --disable-shared \
877  --disable-examples \
878  --program-prefix= \
879  --program-suffix= \
880  --build=$TARGET \
881  2>&1
882make ${NUMJOBS} 2>&1
883# Install libdc1394 into a temp location so ffmpeg can pickup the library
884make install DESTDIR=$FFMPEGDEPSDIR \
885  2>&1
886# Fix the pkgconfig file to get rid of unresolved symbols at runtime:
887sed -i -e "/^Libs:/s/$/ -lavc1394 -lraw1394/" $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/libdc1394-2.pc
888# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
889mkdir -p $FFMPEGDEPSDIR/doc/libdc1394
890cp -a $DOCS_DC1394 $FFMPEGDEPSDIR/doc/libdc1394 || true
891
892cd $OLDDIR
893}
894
895
896# -----------------------------------------------------------------------------
897# Compile faac library
898# The ffmpeg will use these
899# -----------------------------------------------------------------------------
900make_faac()
901{
902echo -e "**\n**  faac ...\n**"
903cd $TMP/tmp-$PRGNAM/faac-${FAAC}
904
905# Newer gcc/glibc will bail out otherwise:
906cat $SRCDIR/patches/faac_gcc44.diff | patch -p1 --verbose \
907  2>&1
908
909#sh bootstrap
910CFLAGS="$SLKCFLAGS" \
911CXXFLAGS="$SLKCFLAGS" \
912LDFLAGS="$SLKLDFLAGS" \
913./configure \
914  --prefix=/usr \
915  --libdir=/usr/lib${LIBDIRSUFFIX} \
916  --enable-static \
917  --disable-shared \
918  --with-mp4v2 \
919  --program-prefix= \
920  --program-suffix= \
921  --build=$TARGET \
922  2>&1
923make ${NUMJOBS} 2>&1
924# Install faac into a temp location so ffmpeg can pickup the library
925make install DESTDIR=$FFMPEGDEPSDIR \
926  2>&1
927# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
928mkdir -p $FFMPEGDEPSDIR/doc/faac
929cp -a $DOCS_FAAC $FFMPEGDEPSDIR/doc/faac || true
930cd -
931}
932
933
934# -----------------------------------------------------------------------------
935# Compile faad2
936# -----------------------------------------------------------------------------
937make_faad2()
938{
939echo -e "**\n**  faad2 ...\n**"
940#mv $TMP/tmp-$PRGNAM/faad2 $TMP/tmp-$PRGNAM/faad2-${FAAD2}
941cd $TMP/tmp-$PRGNAM/faad2-${FAAD2}
942#autoreconf -vif
943CFLAGS="$SLKCFLAGS" \
944CXXFLAGS="$SLKCFLAGS" \
945LDFLAGS="$SLKLDFLAGS" \
946./configure \
947  --prefix=/usr \
948  --libdir=/usr/lib${LIBDIRSUFFIX} \
949  --without-xmms \
950  --enable-static \
951  --disable-shared \
952  --program-prefix= \
953  --program-suffix= \
954  --build=$TARGET \
955  2>&1
956  # No longer available:
957  #--with-mp4v2 \
958  # Gives errors "faad bitstream value not allowed by specification":
959  #--with-drm \
960make ${NUMJOBS} 2>&1
961# Install faad2 into a temp location so ffmpeg can pickup the library
962make install DESTDIR=$FFMPEGDEPSDIR \
963  2>&1
964# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
965mkdir -p $FFMPEGDEPSDIR/doc/faad2
966cp -a $DOCS_FAAD2 $FFMPEGDEPSDIR/doc/faad2 || true
967cd -
968}
969
970
971# -----------------------------------------------------------------------------
972# Compile speex codec
973# -----------------------------------------------------------------------------
974make_speex()
975{
976echo -e "**\n**  speex  ...\n**"
977cd $TMP/tmp-$PRGNAM/speex-$SPEEX
978CFLAGS="$SLKCFLAGS" \
979CXXFLAGS="$SLKCFLAGS" \
980LDFLAGS="$SLKLDFLAGS" \
981./configure \
982  --prefix=/usr \
983  --libdir=/usr/lib${LIBDIRSUFFIX} \
984  --enable-static \
985  --disable-shared \
986  --program-prefix= \
987  --program-suffix= \
988  --build=$TARGET \
989  2>&1
990make ${NUMJOBS} 2>&1
991# Install speex into a temp location so ffmpeg can pickup the library
992echo -e "\n**\n**\n"
993make install DESTDIR=$FFMPEGDEPSDIR \
994  2>&1
995# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
996mkdir -p $FFMPEGDEPSDIR/doc/speex/
997cp $DOCS_SPEEX $FFMPEGDEPSDIR/doc/speex/ || true
998cd -
999}
1000
1001
1002# -----------------------------------------------------------------------------
1003# Compile x264
1004# -----------------------------------------------------------------------------
1005make_x264()
1006{
1007echo -e "**\n**  x264  ...\n**"
1008if [ "$ARCH" = "x86_64" ]; then
1009  ARCHOPTS="--enable-pic"
1010else
1011  ARCHOPTS=""
1012fi
1013cd $TMP/tmp-$PRGNAM/x264-snapshot-${X264}
1014CFLAGS="$SLKCFLAGS" \
1015CXXFLAGS="$SLKCFLAGS" \
1016LDFLAGS="$SLKLDFLAGS" \
1017./configure \
1018  --prefix=/usr \
1019  --libdir=/usr/lib${LIBDIRSUFFIX} \
1020  --enable-static \
1021  --disable-cli \
1022  $ARCHOPTS \
1023  2>&1
1024make ${NUMJOBS} 2>&1
1025# Install x264 into a temp location so ffmpeg can pickup the library
1026make install DESTDIR=$FFMPEGDEPSDIR \
1027  2>&1
1028# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
1029mkdir -p $FFMPEGDEPSDIR/doc/x264
1030cp -a $DOCS_X264 $FFMPEGDEPSDIR/doc/x264 || true
1031cd -
1032}
1033
1034
1035# -----------------------------------------------------------------------------
1036# Compile gsm
1037# -----------------------------------------------------------------------------
1038make_gsm()
1039{
1040echo -e "**\n**  gsm  ...\n**"
1041GSMMAJ=$(echo $GSM | cut -d. -f1,2)
1042GSMPL=$(echo $GSM | cut -d. -f3)
1043mv $TMP/tmp-$PRGNAM/gsm-${GSMMAJ}-pl${GSMPL} $TMP/tmp-$PRGNAM/gsm-${GSM}
1044cd $TMP/tmp-$PRGNAM/gsm-${GSM}
1045# Without this, x86_64 builds will fail:
1046sed -i -e "/^CCFLAGS/s,-O2 ,$SLKCFLAGS ," \
1047       -e "s,^# LDFLAGS.*,LDFLAGS = $SLKLDFLAGS," Makefile
1048make ${NUMJOBS} 2>&1
1049# Install gsm into a temp location so ffmpeg can pickup the library
1050make install 2>&1
1051mkdir -p $FFMPEGDEPSDIR/usr/{bin,include/gsm,lib${LIBDIRSUFFIX}}
1052cp bin/* $FFMPEGDEPSDIR/usr/bin/
1053cp inc/gsm.h $FFMPEGDEPSDIR/usr/include/gsm/
1054ln -sf gsm/gsm.h $FFMPEGDEPSDIR/usr/include/gsm.h
1055cp lib/* $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/
1056# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:         
1057mkdir -p $FFMPEGDEPSDIR/doc/gsm
1058cp -a $DOCS_GSM $FFMPEGDEPSDIR/doc/gsm || true
1059cd -
1060}
1061
1062
1063# -----------------------------------------------------------------------------
1064# Compile orc
1065# -----------------------------------------------------------------------------
1066make_orc()
1067{
1068echo -e "**\n**  orc ...\n**"
1069cd $TMP/tmp-$PRGNAM/orc-$ORC
1070CFLAGS="$SLKCFLAGS" \
1071CXXFLAGS="$SLKCFLAGS" \
1072LDFLAGS="$SLKLDFLAGS" \
1073./configure \
1074  --prefix=$FFMPEGDEPSDIR/usr \
1075  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1076  --enable-static \
1077  --disable-shared \
1078  --program-prefix= \
1079  --program-suffix= \
1080  --build=$TARGET \
1081  2>&1
1082make ${NUMJOBS} 2>&1
1083# Install orc into a temp location so schroedinger can pickup the library
1084echo -e "\n**\n**\n"
1085# We used --prefix=$FFMPEGDEPSDIR/usr so that schroedinger's build will find the
1086# headers in the $FFMPEGDEPSDIR instead of the filesystem root:
1087make install 2>&1
1088# Add DOCS to the ffmpeg deps to have it added to ffmpeg package later:
1089mkdir -p $FFMPEGDEPSDIR/doc/orc/
1090cp ${DOCS_ORC} $FFMPEGDEPSDIR/doc/orc/  || true
1091cd -
1092}
1093
1094
1095# -----------------------------------------------------------------------------
1096# Compile schroedinger
1097# -----------------------------------------------------------------------------
1098make_schroedinger()
1099{
1100echo -e "**\n**  schroedinger ...\n**"
1101if [ "$ARCH" = "x86_64" ]; then
1102  ARCHOPTS="--with-pic"
1103else
1104  ARCHOPTS=""
1105fi
1106cd $TMP/tmp-$PRGNAM/schroedinger-$SCHROEDINGER
1107
1108# Do not try to build the testsuite, it gives errors about multiple definitions:
1109cat $SRCDIR/patches/schroedinger_notests.patch | patch -p1 --verbose \
1110  2>&1
1111
1112# Because of the patch, run autoreconf:
1113autoreconf -vif
1114
1115CFLAGS="$SLKCFLAGS" \
1116CXXFLAGS="$SLKCFLAGS" \
1117LDFLAGS="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} $SLKLDFLAGS" \
1118PKG_CONFIG_PATH="$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
1119./configure \
1120  --prefix=$FFMPEGDEPSDIR/usr \
1121  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1122  --enable-static \
1123  --disable-shared \
1124  --program-prefix= \
1125  --program-suffix= \
1126  $ARCHOPTS \
1127  --build=$TARGET \
1128  2>&1
1129make ${NUMJOBS} 2>&1
1130# Install schroedinger into a temp location so ffmpeg can pickup the library
1131echo -e "\n**\n**\n"
1132make install 2>&1
1133# Or else the ffmpeg build wil fail:
1134cp schroedinger.pc \
1135  $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/schroedinger.pc
1136cp schroedinger.pc \
1137  $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig/schroedinger-1.0.pc
1138( cd $FFMPEGDEPSDIR/usr/include
1139  ln -sf schroedinger-1.0/schroedinger
1140)
1141# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1142mkdir -p $FFMPEGDEPSDIR/doc/schroedinger/
1143cp -a $DOCS_SCHROEDINGER $FFMPEGDEPSDIR/doc/schroedinger/ || true
1144cd -
1145}
1146
1147
1148# -----------------------------------------------------------------------------
1149# Compile rtmpdump
1150# -----------------------------------------------------------------------------
1151make_rtmp()
1152{
1153echo -e "**\n**  rtmp ...\n**"
1154cd $TMP/tmp-$PRGNAM/rtmpdump-$RTMP
1155make -C librtmp prefix=/usr OPT="$SLKCFLAGS" all librtmp.pc \
1156  2>&1
1157# Install librtmp into a temp location so ffmpeg can pickup the library
1158echo -e "\n**\n**\n"
1159mkdir -p $FFMPEGDEPSDIR/usr/{include/librtmp,lib${LIBDIRSUFFIX}/pkgconfig}
1160cp -a librtmp/librtmp.a $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}
1161cp -a librtmp/{amf.h,http.h,log.h,rtmp.h} $FFMPEGDEPSDIR/usr/include/librtmp
1162cp -a librtmp/librtmp.pc $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig
1163# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1164mkdir -p $FFMPEGDEPSDIR/doc/rtmp/
1165cp -a $DOCS_RTMP $FFMPEGDEPSDIR/doc/rtmp/ || true
1166cd -
1167}
1168
1169
1170# -----------------------------------------------------------------------------
1171# Compile libvdpau
1172# -----------------------------------------------------------------------------
1173make_vdpau()
1174{
1175echo -e "**\n**  vdpau ...\n**"
1176cd $TMP/tmp-$PRGNAM/libvdpau-$VDPAU
1177
1178CFLAGS="$SLKCFLAGS" \
1179CXXFLAGS="$SLKCFLAGS" \
1180LDFLAGS="$SLKLDFLAGS" \
1181./configure \
1182  --prefix=/usr \
1183  --libdir=/usr/lib${LIBDIRSUFFIX} \
1184  --enable-static \
1185  --disable-documentation \
1186  --program-prefix= \
1187  --program-suffix= \
1188  --build=$TARGET \
1189  2>&1
1190make ${NUMJOBS} 2>&1
1191# Strip the static lib to prevent linking errors in 64-bit,
1192find . -name "*.a" | xargs strip --strip-unneeded
1193# Install vdpau into a temp location so ffmpeg can pickup the library
1194echo -e "\n**\n**\n"
1195make install DESTDIR=$FFMPEGDEPSDIR \
1196  2>&1
1197# Remove the .so and .la files; we want static linking:
1198rm -f $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/libvdpau*.so*
1199rm -f $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/libvdpau*.la
1200rm -f $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/vdpau/libvdpau*.so*
1201rm -f $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/vdpau/libvdpau*.la
1202# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1203mkdir -p $FFMPEGDEPSDIR/doc/vdpau/
1204cp $DOCS_VDPAU $FFMPEGDEPSDIR/doc/vdpau/ || true
1205cd -
1206}
1207
1208
1209# -----------------------------------------------------------------------------
1210# Compile VP8
1211# -----------------------------------------------------------------------------
1212make_vpx()
1213{
1214echo -e "**\n**  vpx  ...\n**"
1215cd $TMP/tmp-$PRGNAM/libvpx-${VPX}
1216
1217case "$ARCH" in
1218  i?86)
1219    ARCHOPTS="--target=x86-linux-gcc"
1220    ;;
1221  x86_64)
1222    ARCHOPTS="--target=${ARCH}-linux-gcc --enable-pic"
1223    ;;
1224  armv7hl)
1225    ARCHOPTS="--target=armv7-linux-gcc --enable-pic"
1226    cat $SRCDIR/patches/libvpx_fix-armhf-link.patch | patch -p1 --verbose
1227    export AS=as
1228    export AR=ar
1229    export CROSS="${TARGET}-"
1230    ;;
1231  arm*)
1232    ARCHOPTS="--target=armv5te-linux-gcc --enable-pic"
1233    export AS=as
1234    export AR=ar
1235    export CROSS="${TARGET}-"
1236    ;;
1237  *)
1238    ARCHOPTS="--target=${ARCH}-linux-gcc"
1239    ;;
1240esac
1241
1242CFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
1243CXXFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
1244LDFLAGS="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} $SLKLDFLAGS" \
1245PKG_CONFIG_PATH="$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
1246./configure \
1247  --prefix=$FFMPEGDEPSDIR/usr \
1248  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1249  --disable-examples \
1250  --disable-debug-libs \
1251  --disable-debug \
1252  --disable-unit-tests \
1253  --enable-postproc \
1254  --enable-runtime-cpu-detect \
1255  --enable-vp8 \
1256  --enable-vp9 \
1257  --enable-vp9-postproc \
1258  $ARCHOPTS \
1259  2>&1
1260make ${NUMJOBS} 2>&1
1261# Install libvpx into a temp location so ffmpeg can pickup the library
1262make install 2>&1
1263# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1264mkdir -p $FFMPEGDEPSDIR/doc/vpx
1265cp -a $DOCS_VPX $FFMPEGDEPSDIR/doc/vpx/  || true
1266cd -
1267}
1268
1269
1270# -----------------------------------------------------------------------------
1271# Compile libva
1272# -----------------------------------------------------------------------------
1273make_libva()
1274{
1275echo -e "**\n**  libva ...\n**"
1276cd $TMP/tmp-$PRGNAM/libva-$LIBVA
1277
1278#
1279# == NOTE ON VAAPI ==
1280#
1281# VAAPI can enable hardware accelerated playback for MPEG-2/4, H.264/AVC
1282# and VC-1 video on certain graphics hardware.
1283# The VAAPI support in this ffmeeg package depends on VA drivers that you have
1284# to install yourself for your specific hardware. The drivers should go into
1285# directory /usr/lib${LIBDIRSUFFIX}/va/drivers .
1286# If you install my libva package you can get MPEG-2 hardware acceleration on
1287# Intel graphics. If you additionally install my vdpau-video package, then you
1288# get hardware acceleration on Nvidia graphics (with nvidia's binary driver).
1289# If you own an Ati card and use the fglrx driver, then you can achieve
1290# hardware acceleration by installing the xvba-video driver from here:
1291# http://www.splitted-desktop.com/~gbeauchesne/xvba-video/ (since I do not own
1292# Ati hardware I can not build a package for xvba-video myself)
1293
1294CFLAGS="$SLKCFLAGS" \
1295CXXFLAGS="$SLKCFLAGS" \
1296LDFLAGS="$SLKLDFLAGS" \
1297./configure \
1298  --prefix=/usr \
1299  --libdir=/usr/lib${LIBDIRSUFFIX} \
1300  --enable-dummy-driver \
1301  --enable-shared \
1302  --enable-static \
1303  --program-prefix= \
1304  --program-suffix= \
1305  --build=$TARGET \
1306  2>&1
1307make ${NUMJOBS} 2>&1
1308# Strip the static lib to prevent linking errors in 64-bit,
1309find . -name "*.a" | xargs strip --strip-unneeded
1310# Install libva into a temp location so ffmpeg can pickup the library
1311echo -e "\n**\n**\n"
1312make install DESTDIR=$FFMPEGDEPSDIR \
1313  2>&1
1314# Remove the .so and .la files; we want static linking (but still use
1315# the drivers in $(libdir)/va/drivers):
1316rm -f $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/libva*.so*
1317rm -f $FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/libva*.la
1318# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1319mkdir -p $FFMPEGDEPSDIR/doc/libva
1320cp -a $DOCS_LIBVA $FFMPEGDEPSDIR/doc/libva/  || true
1321cd -
1322}
1323
1324
1325# -----------------------------------------------------------------------------
1326# Compile fribidi
1327# -----------------------------------------------------------------------------
1328make_fribidi()
1329{
1330echo -e "**\n**  fribidi  ...\n**"
1331cd $TMP/tmp-$PRGNAM/fribidi-$FRIBIDI
1332if [ "$ARCH" = "x86_64" ]; then
1333  ARCHOPTS="--with-pic"
1334else
1335  ARCHOPTS=""
1336fi
1337
1338# Allow for internal use of the library:
1339cat $SRCDIR/patches/fribidi.patch | patch -p1 --verbose \
1340  2>&1
1341
1342# And since we patched the Makefile.am we have to bootstrap:
1343rm -f configure
1344./bootstrap
1345
1346CFLAGS="$SLKCFLAGS" \
1347CXXFLAGS="$SLKCFLAGS" \
1348LDFLAGS="$SLKLDFLAGS" \
1349./configure \
1350  --prefix=$FFMPEGDEPSDIR/usr \
1351  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1352  --enable-static \
1353  --disable-shared \
1354  --program-prefix= \
1355  --program-suffix= \
1356  $ARCHOPTS \
1357  --build=$TARGET \
1358  2>&1
1359make ${NUMJOBS} 2>&1
1360# Install fribidi into a temp location so ffmpeg can pickup the library
1361echo -e "\n**\n**\n"
1362make install 2>&1
1363# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1364mkdir -p $FFMPEGDEPSDIR/doc/fribidi
1365cp -a $DOCS_FRIBIDI $FFMPEGDEPSDIR/doc/fribidi/  || true
1366cd -
1367}
1368
1369
1370# -----------------------------------------------------------------------------
1371# Compile libass
1372# -----------------------------------------------------------------------------
1373make_ass()
1374{
1375echo -e "**\n**  ass  ...\n**"
1376cd $TMP/tmp-$PRGNAM/libass-$ASS
1377CFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
1378CXXFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS" \
1379LDFLAGS="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} $SLKLDFLAGS" \
1380PKG_CONFIG_PATH="$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
1381./configure \
1382  --prefix=$FFMPEGDEPSDIR/usr \
1383  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1384  --enable-static \
1385  --disable-shared \
1386  --program-prefix= \
1387  --program-suffix= \
1388  --build=$TARGET \
1389  2>&1
1390make ${NUMJOBS} 2>&1
1391# Install libass into a temp location so ffmpeg can pickup the library
1392echo -e "\n**\n**\n"
1393make install 2>&1
1394# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1395mkdir -p $FFMPEGDEPSDIR/doc/libass
1396cp -a $DOCS_ASS $FFMPEGDEPSDIR/doc/libass/  || true
1397cd -
1398}
1399
1400
1401# -----------------------------------------------------------------------------
1402# Compile v4l libraries
1403# -----------------------------------------------------------------------------
1404make_v4l()
1405{
1406echo -e "**\n**  v4l ...\n**"
1407cd $TMP/tmp-$PRGNAM/v4l-utils-${V4L}
1408
1409mkdir ${FFMPEGDEPSDIR}/etc
1410
1411export CFLAGS="$SLKCFLAGS"
1412export CPPFLAGS="$SLKCFLAGS"
1413export LDFLAGS="$SLKLDFLAGS -ljpeg"
1414./configure \
1415  --prefix=$FFMPEGDEPSDIR/usr \
1416  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1417  --sysconfdir=/etc \
1418  --with-udevdir=/lib/udev \
1419  --enable-static \
1420  --disable-shared \
1421  --disable-libdvbv5 \
1422  --enable-libv4l \
1423  --disable-v4l-utils \
1424  --disable-qv4l2 \
1425  --program-prefix= \
1426  --program-suffix= \
1427  --build=$TARGET \
1428  2>&1
1429
1430make ${NUMJOBS} LINKTYPE=static  2>&1
1431# Strip the static lib to prevent linking errors in 64-bit,
1432# and fix the pkg-config file (to fix unresolved symbols)
1433find . -name "*.a" | xargs strip --strip-unneeded
1434sed -i "/^Libs: /s/$/ -lv4l2 -lv4lconvert -ljpeg/" lib/libv4l1/libv4l1.pc
1435sed -i "/^Libs: /s/ -lv4l2/ -lv4l2 -lv4lconvert -ljpeg/" lib/libv4l2/libv4l2.pc
1436# Install libv4l into a temp directory so that ffmpeg can pick it up later:
1437make install LINKTYPE=static \
1438  sysconfdir=$FFMPEGDEPSDIR/etc \
1439  man1dir=$FFMPEGDEPSDIR/usr/man/man1 \
1440  keytablesystemdir=$FFMPEGDEPSDIR/lib/udev/rc_keymaps \
1441  udevrulesdir=$FFMPEGDEPSDIR/lib/udev/rules.d \
1442  2>&1
1443# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1444mkdir -p $FFMPEGDEPSDIR/doc/v4l-utils
1445cp -a $DOCS_V4L2 $FFMPEGDEPSDIR/doc/v4l-utils/  || true
1446
1447cd -
1448}
1449
1450
1451# -----------------------------------------------------------------------------
1452# Compile ogg opus libraries
1453# -----------------------------------------------------------------------------
1454make_opus()
1455{
1456echo -e "**\n**  opus ...\n**"
1457cd $TMP/tmp-$PRGNAM/opus-${OPUS}
1458
1459CFLAGS="$SLKCFLAGS" \
1460CXXFLAGS="$SLKCFLAGS" \
1461LDFLAGS="$SLKLDFLAGS" \
1462./configure \
1463  --prefix=$FFMPEGDEPSDIR/usr \
1464  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1465  --enable-static \
1466  --disable-shared \
1467  --disable-doc \
1468  --program-prefix= \
1469  --program-suffix= \
1470  --build=$TARGET \
1471  2>&1
1472# Install opus into a temp location so ffmpeg can pickup the library
1473make install 2>&1
1474# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1475mkdir -p $FFMPEGDEPSDIR/doc/opus/
1476cp $DOCS_OPUS $FFMPEGDEPSDIR/doc/opus/ || true
1477cd -
1478}
1479
1480
1481# ----------------------------------------------------------------------------
1482# Compile libzvbi, a library that allows ffmpeg to process teletext subtitles
1483# ----------------------------------------------------------------------------
1484
1485make_zvbi()
1486{
1487echo -e "**\n**  zvbi ...\n**"
1488cd $TMP/tmp-$PRGNAM/zvbi-${LIBZVBI}
1489CFLAGS="$SLKCFLAGS" \
1490CXXFLAGS="$SLKCFLAGS" \
1491LDFLAGS="$SLKLDFLAGS" \
1492./configure \
1493  --prefix=$FFMPEGDEPSDIR/usr \
1494  --libdir=$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} \
1495  --enable-static \
1496  --disable-shared \
1497  --program-prefix= \
1498  --program-suffix= \
1499  --build=$TARGET \
1500  2>&1
1501make 2>&1
1502# Install zvbi into a temp location so ffmpeg can pickup the library
1503make install 2>&1
1504# Add DOCS to the ffmpegdeps to have it added to ffmpeg package later:
1505mkdir -p $FFMPEGDEPSDIR/doc/zvbi/
1506cp $DOCS_LIBZVBI $FFMPEGDEPSDIR/doc/zvbi/ || true
1507cd -
1508}
1509
1510
1511# -----------------------------------------------------------------------------
1512# Compile ffmpeg with additional support for -
1513#   LAME (MP3), XVID, AAC (MP4), FAAD2 , SPEEX, X264, GSM, SCHROEDINGER
1514# -----------------------------------------------------------------------------
1515make_ffmpeg()
1516{
1517echo -e "**\n**  ffmpeg ...\n**"
1518OLDDIR=$(pwd)
1519cd $TMP/tmp-$PRGNAM
1520# Take care of snaphot directory:
1521if [ -d ffmpeg-export-* ]; then
1522  rm -rf ffmpeg-${VERSION}
1523  mv ffmpeg-export-* ffmpeg-${VERSION}
1524fi
1525
1526# Only use non-free code if we are allowing it:
1527if [ "${USE_PATENTS}" == "YES" ]; then
1528  USE_NONFREE="--enable-libmp3lame \
1529                --enable-libfaac \
1530                --enable-libfdk-aac \
1531                --enable-openssl \
1532                --enable-nonfree"
1533                # to be added once I get it to work: --enable-libaacplus \
1534else
1535  USE_NONFREE="--enable-gnutls"
1536fi
1537
1538cd $TMP/tmp-$PRGNAM/ffmpeg-${VERSION}
1539
1540if [ "$ARCH" = "x86_64" ]; then
1541  ARCHOPTS="--arch=x86_64 --enable-pic"
1542else
1543  ARCHOPTS=""
1544fi
1545
1546# Fix SDL header location:
1547sed -e '/#include/ s,<SDL,<SDL/SDL,' -i ffplay.c
1548
1549# Or else orc's library will not be used in the static linking (orc is listed
1550# as a private lib for schroedinger):
1551sed -i -e "s/pkg_config --libs/pkg_config --static --libs/" \
1552  configure
1553
1554# Stamp the version into the source:
1555[ -f version.sh ] && sed -i -e "s/UNKNOWN/$VERSION/" version.sh
1556
1557TMPDIR="$TMP" \
1558CFLAGS="-I$FFMPEGDEPSDIR/usr/include $SLKCFLAGS -I/usr/X11R6/include/" \
1559CPPFLAGS="-I$FFMPEGDEPSDIR/usr/include -I$FFMPEGDEPSDIR/usr/include/SDL -I/usr/X11R6/include/" \
1560CXXFLAGS="-I$FFMPEGDEPSDIR/usr/include -I$FFMPEGDEPSDIR/usr/include/SDL $SLKCFLAGS -I/usr/X11R6/include/" \
1561LDFLAGS="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} $SLKLDFLAGS -lpng -lXext" \
1562PKG_CONFIG_PATH="$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX}/pkgconfig" \
1563PATH="$FFMPEGDEPSDIR/usr/bin:$PATH" \
1564./configure \
1565  --prefix=/usr \
1566  --libdir=/usr/lib${LIBDIRSUFFIX} \
1567  --shlibdir=/usr/lib${LIBDIRSUFFIX} \
1568  --docdir=/usr/doc/${PRGNAM}-${VERSION} \
1569  --mandir=/usr/man \
1570  --enable-gpl \
1571  --enable-version3 \
1572  --enable-avfilter \
1573  --enable-avresample \
1574  --enable-libass \
1575  --enable-libdc1394 \
1576  --enable-libgsm \
1577  --enable-libopencore-amrnb \
1578  --enable-libopencore-amrwb \
1579  --enable-libopus \
1580  --enable-libschroedinger \
1581  --enable-libspeex \
1582  --enable-libtheora \
1583  --enable-libv4l2 \
1584  --enable-libvo-amrwbenc \
1585  --enable-libvorbis \
1586  --enable-libvpx \
1587  --enable-libx264 \
1588  --enable-libx265 \
1589  --enable-libzvbi \
1590  --enable-postproc \
1591  --enable-runtime-cpudetect \
1592  --enable-vaapi \
1593  --enable-vdpau \
1594  --enable-memalign-hack \
1595  --enable-pthreads \
1596  --enable-x11grab \
1597  --enable-bzlib \
1598  --enable-zlib \
1599  --enable-shared \
1600  --enable-static \
1601  --disable-debug \
1602  ${USE_NONFREE} \
1603  $ARCHOPTS \
1604  --extra-cflags="-I$FFMPEGDEPSDIR/usr/include -I$FFMPEGDEPSDIR/usr/include/SDL -DRUNTIME_CPUDETECT" \
1605  --extra-ldflags="-L$FFMPEGDEPSDIR/usr/lib${LIBDIRSUFFIX} -L/usr/X11R6/lib/ -ldl -lssl -lcrypto -lz -lusb" \
1606  --pkg-config-flags="--static" \
1607  2>&1
1608  # Use ffmpeg's own implementation:
1609  #--enable-librtmp \
1610# Need to add "-lfftw3f" to --extra-ldflags if libaacplus gets used
1611make ${NUMJOBS} 2>&1
1612
1613cd $OLDDIR
1614}
1615
1616#
1617# OK, we packaged the compile process for the various software libraries
1618# into convenient functions... let's call them one by one now:
1619#
1620
1621#if [ 'xy' != 'xy' ]; then # use this block if you want to skip a lot
1622
1623# Needed before ffmpeg:
1624# Based on the value of $USE_PATENTS enable or disable non-free code:
1625if [ "${USE_PATENTS}" = "YES" ]; then
1626  make_lame
1627  make_faac
1628  #make_aacplus
1629  make_fdkaac
1630fi
1631
1632make_amr
1633make_amrwbenc
1634make_1394
1635make_v4l
1636make_opus
1637make_speex
1638make_gsm
1639#make_rtmp
1640make_orc
1641make_schroedinger
1642make_x264
1643make_x265
1644make_vpx
1645make_libva
1646make_vdpau
1647make_fribidi
1648make_ass
1649make_zvbi
1650
1651#fi # end of 'xy'
1652
1653# ffmpeg uses the above static libraries:
1654make_ffmpeg
1655
1656# End of compilation, proceed to packaging the binaries:
1657cd $TMP/tmp-${PRGNAM}/ffmpeg-${VERSION}
1658
1659# Install all the needed stuff to the package dir
1660make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log
1661
1662# Add x264 & vpx presets.  See 'Preset files' in the man pages.
1663echo "** Adding ffmpeg presets:"
1664mkdir -p $PKG/usr/share/ffmpeg
1665cp -a presets/*.ffpreset $PKG/usr/share/ffmpeg/
1666
1667# The pkg-config files are full of library dependencies which we built
1668# statically, so we need to edit those out so that programs that try to link
1669# against our ffmpeg will not get confused:
1670echo "** Fixing up pkgconfig files:"
1671for PCFILE in $(ls $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/*.pc) ; do
1672  sed -i -e 's/-lraw1394//g' -e 's/-lavc1394//g' -e 's/-ldc1394//g' \
1673         -e 's/-lspeex//g' -e 's/-lgsm//g' -e 's/-lrtmp//g' \
1674         -e 's/-lopencore-amrnb//g' -e 's/-lopencore-amrwb//g' \
1675         -e 's/-lfaac//g' -e 's/-lfaad//g' \
1676         -e 's/-lvo-amrwbenc//g' -e 's/-lfdk-aac//g'  \
1677         -e 's/-lmp3lame//g' \
1678         -e 's/-lopus//g' \
1679         -e 's/-lschroedinger-[^ ]*//g' -e 's/-lorc-[^ ]*//g' \
1680         -e 's/-lx264//g' -e 's/-lx265//g' -e 's/-lvpx//g' -e 's/-lzvbi//g' \
1681         -e "s#-L/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/lib${LIBDIRSUFFIX}##" \
1682         $PCFILE
1683done
1684
1685# Add a configuration file for the ffserver:
1686mkdir -p $PKG/etc
1687cp -a doc/ffserver.conf  $PKG/etc/ffserver.conf.new
1688
1689# Add this to the doinst.sh:
1690! [ -d $PKG/install ] && mkdir -p $PKG/install
1691cat <<EOINS >> $PKG/install/doinst.sh
1692# Handle the incoming configuration files:
1693config() {
1694  for infile in \$1; do
1695    NEW="\$infile"
1696    OLD="\`dirname \$NEW\`/\`basename \$NEW .new\`"
1697    # If there's no config file by that name, mv it over:
1698    if [ ! -r \$OLD ]; then
1699      mv \$NEW \$OLD
1700    elif [ "\`cat \$OLD | md5sum\`" = "\`cat \$NEW | md5sum\`" ]; then
1701      # toss the redundant copy
1702      rm \$NEW
1703    fi
1704    # Otherwise, we leave the .new copy for the admin to consider...
1705  done
1706}
1707
1708config etc/ffserver.conf.new
1709
1710EOINS
1711
1712# Add  documentation (for all the deps as well)
1713mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
1714cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true
1715# Add all the supporting packages' documentation too:
1716cp -a $FFMPEGDEPSDIR/doc/* $PKG/usr/doc/$PRGNAM-$VERSION || true
1717cp -a $SRCDIR/patches $PKG/usr/doc/$PRGNAM-$VERSION/ 2>/dev/null || true
1718cat $SRCDIR/$(basename $0) > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
1719find $PKG/usr/doc -type f -exec chmod 644 {} \;
1720chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION/*
1721
1722# Compress the man page(s)
1723if [ -d $PKG/usr/man ]; then
1724  find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
1725  for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
1726fi
1727
1728# Strip binaries
1729find $PKG | xargs file | grep -e "executable" -e "shared object" \
1730  | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
1731
1732# Add package description:
1733mkdir -p $PKG/install
1734cat $SRCDIR/slack-desc > $PKG/install/slack-desc
1735if [ -f $SRCDIR/doinst.sh ]; then
1736  cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
1737fi
1738
1739# Build the package:
1740cd $PKG
1741makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz 2>&1
1742cd $OUTPUT
1743md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz.md5
1744cd -
1745cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
1746
1747# Restore the original umask:
1748umask ${_UMASK_}
1749
Note: See TracBrowser for help on using the repository browser.