ffmpeg.SlackBuild 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. #!/bin/bash
  2. # Slackware build script for ffmpeg
  3. # Copyright 2010-2017 Heinz Wiesinger, Amsterdam, The Netherlands
  4. # Copyright 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA
  5. # All rights reserved.
  6. #
  7. # Redistribution and use of this script, with or without modification, is
  8. # permitted provided that the following conditions are met:
  9. #
  10. # 1. Redistributions of this script must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. #
  13. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
  14. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  16. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  19. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  20. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  21. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  22. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. # Originally written by core (eroc@linuxmail.org)
  24. # Modified by Robby Workman <rworkman@slackbuilds.org>
  25. cd $(dirname $0) ; CWD=$(pwd)
  26. PKGNAM=ffmpeg
  27. VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
  28. BUILD=${BUILD:-1}
  29. if [ -z "$ARCH" ]; then
  30. case "$( uname -m )" in
  31. i?86) ARCH=i586 ;;
  32. arm*) ARCH=arm ;;
  33. *) ARCH=$( uname -m ) ;;
  34. esac
  35. fi
  36. TMP=${TMP:-/tmp}
  37. PKG=$TMP/package-$PKGNAM
  38. NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}
  39. if [ "$ARCH" = "i586" ]; then
  40. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  41. LIBDIRSUFFIX=""
  42. elif [ "$ARCH" = "i686" ]; then
  43. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  44. LIBDIRSUFFIX=""
  45. elif [ "$ARCH" = "x86_64" ]; then
  46. SLKCFLAGS="-O2 -fPIC"
  47. LIBDIRSUFFIX="64"
  48. else
  49. SLKCFLAGS="-O2"
  50. LIBDIRSUFFIX=""
  51. fi
  52. # If PulseAudio is not found, use the _alsa $TAG and disable it in the build:
  53. if [ ! -r /usr/lib${LIBDIRSUFFIX}/pkgconfig/libpulse.pc ]; then
  54. TAG="_alsa"
  55. PULSEAUDIO=no
  56. fi
  57. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  58. # the name of the created package would be, and then exit. This information
  59. # could be useful to other scripts.
  60. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  61. echo "$PKGNAM-$VERSION-$ARCH-$BUILD$TAG.txz"
  62. exit 0
  63. fi
  64. # Configure ffmpeg features not autodetected by default.
  65. # You can enable a lot of optional (not-autodetected) features by
  66. # passing variables to the script (VAR=yes/no ./ffmpeg.SlackBuild).
  67. # Unfortunately ffmpeg's configure doesn't support --enable-feature=yes
  68. # syntax, so we have to do it the complicated way :/
  69. # Additional optional (autodetected) dependencies are:
  70. # - jack-audio-connection-kit
  71. # - libva
  72. # - libvdpau
  73. # - libX11
  74. # - libxcb
  75. # - sdl2
  76. # - xz
  77. # - zlib
  78. libx264="" ; [ "${X264:-yes}" != "no" ] && libx264="--enable-libx264"
  79. libcelt="" ; [ "${CELT:-no}" != "no" ] && libcelt="--enable-libcelt"
  80. libdc1394="" ; [ "${DC1394:-no}" != "no" ] && libdc1394="--enable-libdc1394"
  81. libfrei0r="" ; [ "${FREI0R:-no}" != "no" ] && libfrei0r="--enable-frei0r"
  82. libgsm="" ; [ "${GSM:-no}" != "no" ] && libgsm="--enable-libgsm"
  83. librtmp="" ; [ "${RTMP:-no}" != "no" ] && librtmp="--enable-librtmp"
  84. libspeex="" ; [ "${SPEEX:-yes}" != "no" ] && libspeex="--enable-libspeex"
  85. libxvid="" ; [ "${XVID:-no}" != "no" ] && libxvid="--enable-libxvid"
  86. libass="" ; [ "${ASS:-yes}" != "no" ] && libass="--enable-libass"
  87. libopenal="" ; [ "${OPENAL:-no}" != "no" ] && libopenal="--enable-openal"
  88. libiec61883=""; [ "${IEC61883:-no}" != "no" ] && libiec61883="--enable-libiec61883"
  89. libilbc="" ; [ "${ILBC:-no}" != "no" ] && libilbc="--enable-libilbc"
  90. libmodplug="" ; [ "${MODPLUG:-no}" != "no" ] && libmodplug="--enable-libmodplug"
  91. libopus="" ; [ "${OPUS:-yes}" != "no" ] && libopus="--enable-libopus"
  92. libtwolame="" ; [ "${TWOLAME:-yes}" != "no" ] && libtwolame="--enable-libtwolame"
  93. ladspa="" ; [ "${LADSPA:-no}" != "no" ] && ladspa="--enable-ladspa"
  94. libflite="" ; [ "${FLITE:-no}" != "no" ] && libflite="--enable-libflite"
  95. libvidstab="" ; [ "${VIDSTAB:-no}" != "no" ] && libvidstab="--enable-libvidstab"
  96. libx265="" ; [ "${X265:-yes}" != "no" ] && libx265="--enable-libx265"
  97. libzvbi="" ; [ "${ZVBI:-no}" != "no" ] && libzvbi="--enable-libzvbi"
  98. libopencv="" ; [ "${OPENCV:-no}" != "no" ] && libopencv="--enable-libopencv"
  99. libgme="" ; [ "${GME:-no}" != "no" ] && libgme="--enable-libgme"
  100. libsnappy="" ; [ "${SNAPPY:-no}" != "no" ] && libsnappy="--enable-libsnappy"
  101. libzmq="" ; [ "${ZMQ:-no}" != "no" ] && libzmq="--enable-libzmq"
  102. libbs2b="" ; [ "${BS2B:-no}" != "no" ] && libbs2b="--enable-libbs2b"
  103. libebur128="" ; [ "${EBUR128:-no}" != "no" ] && libebur128="--enable-libebur128"
  104. rubberband="" ; [ "${RUBBERBAND:-no}" != "no" ] && rubberband="--enable-librubberband"
  105. tesseract="" ; [ "${TESSERACT:-no}" != "no" ] && tesseract="--enable-libtesseract"
  106. netcdf="" ; [ "${NETCDF:-no}" != "no" ] && netcdf="--enable-netcdf"
  107. chromaprint="" ; [ "${CHROMAPRINT:-no}" != "no" ] && chromaprint="--enable-chromaprint"
  108. opencore_amr="" ; [ "${OPENCORE:-no}" != "no" ] && \
  109. opencore_amr="--enable-libopencore-amrnb --enable-libopencore-amrwb"
  110. fdk="" ; [ "${FDK_AAC:-no}" != "no" ] && \
  111. { fdk="--enable-libfdk-aac"; non_free="--enable-nonfree" ; }
  112. ssl="" ; [ "${OPENSSL:-no}" != "no" ] && \
  113. { ssl="--enable-openssl" ; non_free="--enable-nonfree" ; }
  114. decklink="" ; [ "${DECKLINK:-no}" != "no" ] && \
  115. { decklink="--enable-decklink" ; \
  116. SLKCFLAGS="$SLKCFLAGS -I/usr/include/decklink" ; }
  117. # Default enabled features:
  118. fontconfig="" ; [ "${FONTCONFIG:-yes}" != "no" ] && fontconfig="--enable-libfontconfig"
  119. freetype="" ; [ "${FREETYPE:-yes}" != "no" ] && freetype="--enable-libfreetype"
  120. fribidi="" ; [ "${FRIBIDI:-yes}" != "no" ] && fribidi="--enable-libfribidi"
  121. gnutls="" ; [ "${GNUTLS:-yes}" != "no" ] && gnutls="--enable-gnutls"
  122. libbluray="" ; [ "${BLURAY:-yes}" != "no" ] && libbluray="--enable-libbluray"
  123. libcaca="" ; [ "${CACA:-yes}" != "no" ] && libcaca="--enable-libcaca"
  124. libcdio="" ; [ "${LIBCDIO:-yes}" != "no" ] && libcdio="--enable-libcdio"
  125. libssh="" ; [ "${LIBSSH:-yes}" != "no" ] && libssh="--enable-libssh"
  126. libtheora="" ; [ "${THEORA:-yes}" != "no" ] && libtheora="--enable-libtheora"
  127. libv4l2="" ; [ "${V4L2:-yes}" != "no" ] && libv4l2="--enable-libv4l2"
  128. libvorbis="" ; [ "${VORBIS:-yes}" != "no" ] && libvorbis="--enable-libvorbis"
  129. libvpx="" ; [ "${VPX:-yes}" != "no" ] && libvpx="--enable-libvpx"
  130. libwebp="" ; [ "${WEBP:-yes}" != "no" ] && libwebp="--enable-libwebp"
  131. mp3lame="" ; [ "${LAME:-yes}" != "no" ] && mp3lame="--enable-libmp3lame"
  132. opencl="" ; [ "${OPENCL:-yes}" != "no" ] && opencl="--enable-opencl"
  133. opengl="" ; [ "${OPENGL:-yes}" != "no" ] && opengl="--enable-opengl"
  134. openjpeg="" ; [ "${JP2:-yes}" != "no" ] && openjpeg="--enable-libopenjpeg"
  135. pulse="" ; [ "${PULSEAUDIO:-yes}" != "no" ] && pulse="--enable-libpulse"
  136. samba="" ; [ "${SAMBA:-yes}" != "no" ] && samba="--enable-libsmbclient"
  137. wavpack="" ; [ "${WAVPACK:-yes}" != "no" ] && wavpack="--enable-libwavpack"
  138. # No default patent encumbered features:
  139. aac="" ; [ "${AAC:-no}" = "no" ] && aac="--disable-encoder=aac"
  140. rm -rf $PKG
  141. mkdir -p $TMP $PKG
  142. cd $TMP
  143. rm -rf $PKGNAM-$VERSION
  144. tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1
  145. cd $PKGNAM-$VERSION || exit 1
  146. chown -R root:root .
  147. find -L . \
  148. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  149. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  150. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  151. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  152. # Fix linking with flite:
  153. sed -i "s| -lflite\"| -lflite -lm -lasound\"|" \
  154. ./configure
  155. CFLAGS="$SLKCFLAGS" \
  156. CXXFLAGS="$SLKCFLAGS" \
  157. ./configure \
  158. --prefix=/usr \
  159. --libdir=/usr/lib${LIBDIRSUFFIX} \
  160. --shlibdir=/usr/lib${LIBDIRSUFFIX} \
  161. --docdir=/usr/doc/$PKGNAM-$VERSION/html \
  162. --mandir=/usr/man \
  163. --disable-debug \
  164. --enable-shared \
  165. --disable-static \
  166. --enable-gpl \
  167. --enable-version3 \
  168. --enable-avresample \
  169. --arch=$ARCH \
  170. $non_free \
  171. $aac \
  172. $chromaprint \
  173. $decklink \
  174. $fdk \
  175. $fontconfig \
  176. $freetype \
  177. $fribidi \
  178. $gnutls \
  179. $ladspa \
  180. $libass \
  181. $libbluray \
  182. $libbs2b \
  183. $libcaca \
  184. $libcdio \
  185. $libcelt \
  186. $libdc1394 \
  187. $libebur128 \
  188. $libflite \
  189. $libfrei0r \
  190. $libgme \
  191. $libgsm \
  192. $libiec61883 \
  193. $libilbc \
  194. $libmodplug \
  195. $libopenal \
  196. $libopencv \
  197. $libopus \
  198. $librtmp \
  199. $libsnappy \
  200. $libspeex \
  201. $libssh \
  202. $libtheora \
  203. $libtwolame \
  204. $libv4l2 \
  205. $libvidstab \
  206. $libvorbis \
  207. $libvpx \
  208. $libwebp \
  209. $libx264 \
  210. $libx265 \
  211. $libxvid \
  212. $libzmq \
  213. $libzvbi \
  214. $mp3lame \
  215. $netcdf \
  216. $opencl \
  217. $opencore_amr \
  218. $opengl \
  219. $openjpeg \
  220. $pulse \
  221. $rubberband \
  222. $samba \
  223. $ssl \
  224. $tesseract \
  225. $wavpack || exit 1
  226. make $NUMJOBS || make || exit 1
  227. make install DESTDIR=$PKG || exit 1
  228. make install-man DESTDIR=$PKG || exit 1
  229. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | \
  230. grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  231. find $PKG/usr/man -type f -exec gzip -9 {} \+
  232. mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION/txt
  233. cp -a \
  234. Changelog COPYING* CREDITS INSTALL* LICENSE* MAINTAINERS README* \
  235. RELEASE VERSION \
  236. $PKG/usr/doc/$PKGNAM-$VERSION
  237. cp -a doc/*.txt $PKG/usr/doc/$PKGNAM-$VERSION/txt/
  238. find . -name "RELEASE_NOTES" -exec cp -a {} $PKG/usr/doc/$PKGNAM-$VERSION/ \;
  239. # If there's a ChangeLog, installing at least part of the recent history
  240. # is useful, but don't let it get totally out of control:
  241. if [ -r ChangeLog ]; then
  242. DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION)
  243. cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog
  244. touch -r ChangeLog $DOCSDIR/ChangeLog
  245. fi
  246. mkdir -p $PKG/install
  247. cat $CWD/slack-desc > $PKG/install/slack-desc
  248. cd $PKG
  249. /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD$TAG.txz