From a4c221cab6b1026fc37874fb64dfda83a81aff1e Mon Sep 17 00:00:00 2001 From: Happy-Neko Date: Tue, 7 Feb 2012 02:40:03 +0400 Subject: [PATCH] Separate download and build logic, added documentation --- contrib/README | 21 + contrib/build-pms-binaries.sh | 214 ++----- contrib/download-pms-binaries-source.sh | 764 ++++++++++++++++++++++++ 3 files changed, 847 insertions(+), 152 deletions(-) create mode 100644 contrib/README create mode 100755 contrib/download-pms-binaries-source.sh diff --git a/contrib/README b/contrib/README new file mode 100644 index 000000000..3e49ac005 --- /dev/null +++ b/contrib/README @@ -0,0 +1,21 @@ +# BUILD PMS BINARIES + +These scripts are only meant for enthusiasts that want to bundle their PMS with custom built versions of libraries and tools, replacing the standard versions shipped with the regular PMS distribution. + +## Downloading (and updating) sources + + contrib/download-pms-binaries-source.sh + +Sources archives will be strored in _target/bin-tools/src/_ + +## Building bainaries + + contrib/build-pms-binaries.sh + +Search _target/bin-tools/target/bin/_ for compiled binaries and _target/bin-tools/target/lib/_ for libs + +## Cleaning up + + rm -rf target/bin-tools/build/ + rm -rf target/bin-tools/target/ + diff --git a/contrib/build-pms-binaries.sh b/contrib/build-pms-binaries.sh index b20f04e7c..789524351 100755 --- a/contrib/build-pms-binaries.sh +++ b/contrib/build-pms-binaries.sh @@ -71,11 +71,6 @@ # # CONFIGURATION # -# Set FIXED_REVISIONS to "no" to check out the latest revisions. -# Default is "yes" to check out the last known working revision. -FIXED_REVISIONS="yes" - - # Set TARGET_ARCHITECTURE for building binaries. Choose one of the following: # # OSX: @@ -95,7 +90,7 @@ FIXED_REVISIONS="yes" TARGET_ARCHITECTURE="default" -# Set MINIMUM_ARCHITECTURE for building binaries. Valid only for Linux builds. +# Set optional MINIMUM_ARCHITECTURE for building binaries. Valid only for Linux builds. # Resulting binaries will require MINIMUM_ARCHITECTURE to run and have extra optimization for TARGET_ARCHITECTURE. # generic: Produce code optimized for the most common IA32/AMD64/EM64T processors. # native: build for your own computer @@ -103,7 +98,7 @@ TARGET_ARCHITECTURE="default" # pentium2: Intel Pentium2 CPU based on PentiumPro core with MMX instruction set support. # pentium4: Intel Pentium4 CPU with MMX, SSE and SSE2 instruction set support. # For a list of other options see: http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html -MINIMUM_ARCHITECTURE="pentium4" +MINIMUM_ARCHITECTURE="" # Set the amount of threads that are used for compiling everything. This @@ -117,7 +112,7 @@ THREADS="2" # binaries deps versions -. ./binaries-deps-versions +. contrib/binaries-deps-versions ########################################## @@ -379,19 +374,16 @@ LIBTOOL=`check_binary libtool` MAKE=`check_binary make` MVN=`check_binary mvn` SED=`check_binary sed` -SVN=`check_binary svn` TAR=`check_binary tar` YASM=`check_binary yasm` UNZIP=`check_binary unzip` if is_osx; then GCC2=`check_binary gcc-4.2` - CURL=`check_binary curl` HDID=`check_binary hdid` HDIUTIL=`check_binary hdiutil` else GCC2=$GCC - WGET=`check_binary wget` AUTOMAKE=`check_binary automake` AUTOCONF=`check_binary autoconf` STRIP=`check_binary strip` @@ -427,21 +419,6 @@ createdir() { } -########################################## -# Download a file from a URL -# -download() { - URL=$1 - FILENAME=`echo $URL | $SED "s/.*\///g"` - - if is_osx; then - $CURL -L $URL > $FILENAME - else - $WGET $URL - fi -} - - ########################################## # Exit if the previous command ended with an error status # @@ -462,7 +439,7 @@ initialize() { # Directories for statically compiled libraries TARGET="$WORKDIR/target/bin-tools/target" - SRC="$WORKDIR/target/bin-tools/src" + SRC="$WORKDIR/target/bin-tools/build" createdir "$SRC" createdir "$TARGET" @@ -537,9 +514,15 @@ set_flags() { LDFLAGS="$LDFLAGS -arch $ARCHITECTURE" CXXFLAGS="$CXXFLAGS -arch $ARCHITECTURE" else - CFLAGS="$CFLAGS -march=$MINIMUM_ARCHITECTURE -mtune=$ARCHITECTURE" - CXXFLAGS="$CXXFLAGS -march=$MINIMUM_ARCHITECTURE -mtune=$ARCHITECTURE" - LDFLAGS="$LDFLAGS -march=$MINIMUM_ARCHITECTURE -mtune=$ARCHITECTURE" + if [ "$MINIMUM_ARCHITECTURE" == "" ]; then + CFLAGS="$CFLAGS -mtune=$ARCHITECTURE" + CXXFLAGS="$CXXFLAGS -mtune=$ARCHITECTURE" + LDFLAGS="$LDFLAGS -mtune=$ARCHITECTURE" + else + CFLAGS="$CFLAGS -march=$MINIMUM_ARCHITECTURE -mtune=$ARCHITECTURE" + CXXFLAGS="$CXXFLAGS -march=$MINIMUM_ARCHITECTURE -mtune=$ARCHITECTURE" + LDFLAGS="$LDFLAGS -march=$MINIMUM_ARCHITECTURE -mtune=$ARCHITECTURE" + fi fi fi @@ -581,9 +564,8 @@ build_bzip2() { cd $SRC if [ ! -d bzip2-$VERSION_BZIP2 ]; then - download http://bzip.org/$VERSION_BZIP2/bzip2-$VERSION_BZIP2.tar.gz + $TAR zxf ./../src/bzip2-$VERSION_BZIP2.tar.gz exit_on_error - $TAR xzf bzip2-$VERSION_BZIP2.tar.gz fi cd bzip2-$VERSION_BZIP2 @@ -611,9 +593,8 @@ build_dcraw() { cd $SRC if [ ! -d dcraw-$VERSION_DCRAW ]; then - download http://www.cybercom.net/~dcoffin/dcraw/archive/dcraw-$VERSION_DCRAW.tar.gz + $TAR zxf ./../src/dcraw-$VERSION_DCRAW.tar.gz exit_on_error - $TAR xzf dcraw-$VERSION_DCRAW.tar.gz mv ./dcraw ./dcraw-$VERSION_DCRAW fi @@ -640,9 +621,8 @@ build_enca() { cd $SRC if [ ! -d enca-$VERSION_ENCA ]; then - download http://dl.cihar.com/enca/enca-$VERSION_ENCA.tar.gz + $TAR zxf ./../src/enca-$VERSION_ENCA.tar.gz exit_on_error - $TAR xzf enca-$VERSION_ENCA.tar.gz fi cd enca-$VERSION_ENCA @@ -665,9 +645,8 @@ build_expat() { cd $SRC if [ ! -d expat-$VERSION_EXPAT ]; then - download http://downloads.sourceforge.net/project/expat/expat/$VERSION_EXPAT/expat-$VERSION_EXPAT.tar.gz + $TAR zxf ./../src/expat-$VERSION_EXPAT.tar.gz exit_on_error - $TAR xzf expat-$VERSION_EXPAT.tar.gz fi cd expat-$VERSION_EXPAT @@ -689,9 +668,8 @@ build_faad2() { cd $SRC if [ ! -d faad2-$VERSION_FAAD2 ]; then - download http://downloads.sourceforge.net/project/faac/faad2-src/faad2-$VERSION_FAAD2/faad2-$VERSION_FAAD2.tar.gz + $TAR zxf ./../src/faad2-$VERSION_FAAD2.tar.gz exit_on_error - $TAR xzf faad2-$VERSION_FAAD2.tar.gz fi cd faad2-$VERSION_FAAD2 @@ -712,26 +690,12 @@ build_ffmpeg() { start_build ffmpeg cd $SRC - if [ -d ffmpeg ]; then - cd ffmpeg - $GIT pull git://git.videolan.org/ffmpeg.git - exit_on_error - else - $GIT clone git://git.videolan.org/ffmpeg.git ffmpeg - exit_on_error - cd ffmpeg - fi - - if [ "$FIXED_REVISIONS" == "yes" ]; then - $GIT checkout tags/$VERSION_FFMPEG - exit_on_error - fi + cp -a ./../src/ffmpeg ./ + exit_on_error + cd ffmpeg + exit_on_error if is_osx; then - # Fix path to git in "version.sh" to avoid version "UNKNOWN" - GIT_STR=`echo $GIT | $SED -e "s/\//\\\\\\\\\\\//g"` - $SED -i -e "s/ git / $GIT_STR /g" version.sh - set_flags # VDA disabled for mplayer, also disabled here to avoid build errors @@ -771,9 +735,8 @@ build_flac() { cd $SRC if [ ! -d flac-$VERSION_FLAC ]; then - download http://downloads.xiph.org/releases/flac/flac-$VERSION_FLAC.tar.gz + $TAR zxf ./../src/flac-$VERSION_FLAC.tar.gz exit_on_error - $TAR xzf flac-$VERSION_FLAC.tar.gz fi cd flac-$VERSION_FLAC @@ -816,9 +779,8 @@ build_fontconfig() { cd $SRC if [ ! -d fontconfig-$VERSION_FONTCONFIG ]; then - download http://www.freedesktop.org/software/fontconfig/release/fontconfig-$VERSION_FONTCONFIG.tar.gz + $TAR zxf ./../src/fontconfig-$VERSION_FONTCONFIG.tar.gz exit_on_error - $TAR xzf fontconfig-$VERSION_FONTCONFIG.tar.gz fi cd fontconfig-$VERSION_FONTCONFIG @@ -857,9 +819,8 @@ build_freetype() { cd $SRC if [ ! -d freetype-$VERSION_FREETYPE ]; then - download http://download.savannah.gnu.org/releases/freetype/freetype-$VERSION_FREETYPE.tar.gz + $TAR zxf ./../src/freetype-$VERSION_FREETYPE.tar.gz exit_on_error - $TAR xzf freetype-$VERSION_FREETYPE.tar.gz fi cd freetype-$VERSION_FREETYPE @@ -883,9 +844,8 @@ build_fribidi() { cd $SRC if [ ! -d fribidi-$VERSION_FRIBIDI ]; then - download http://fribidi.org/download/fribidi-$VERSION_FRIBIDI.tar.gz + $TAR zxf ./../src/fribidi-$VERSION_FRIBIDI.tar.gz exit_on_error - $TAR xzf fribidi-$VERSION_FRIBIDI.tar.gz fi cd fribidi-$VERSION_FRIBIDI @@ -907,9 +867,8 @@ build_giflib() { cd $SRC if [ ! -d giflib-$VERSION_GIFLIB ]; then - download http://downloads.sourceforge.net/project/giflib/giflib%204.x/giflib-$VERSION_GIFLIB/giflib-$VERSION_GIFLIB.tar.bz2 + $TAR xjf ./../src/giflib-$VERSION_GIFLIB.tar.bz2 exit_on_error - $TAR xjf giflib-$VERSION_GIFLIB.tar.bz2 fi cd giflib-$VERSION_GIFLIB @@ -931,9 +890,8 @@ build_iconv() { cd $SRC if [ ! -d libiconv-$VERSION_ICONV ]; then - download http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$VERSION_ICONV.tar.gz + $TAR zxf ./../src/libiconv-$VERSION_ICONV.tar.gz exit_on_error - $TAR xzf libiconv-$VERSION_ICONV.tar.gz fi cd libiconv-$VERSION_ICONV @@ -955,9 +913,8 @@ build_jpeg() { cd $SRC if [ ! -d jpeg-$VERSION_JPEG ]; then - download http://www.ijg.org/files/jpegsrc.v$VERSION_JPEG.tar.gz + $TAR zxf ./../src/jpegsrc.v$VERSION_JPEG.tar.gz exit_on_error - $TAR xzf jpegsrc.v$VERSION_JPEG.tar.gz fi cd jpeg-$VERSION_JPEG @@ -979,11 +936,8 @@ build_lame() { cd $SRC if [ ! -d lame-$VERSION_LAME ]; then - #download http://downloads.sourceforge.net/project/lame/lame/$VERSION_LAME/lame-$VERSION_LAME.tar.gz - # Blah! 3.99.2 resides in the directory 3.99. Hardcoding that for now. - download http://downloads.sourceforge.net/project/lame/lame/3.99/lame-$VERSION_LAME.tar.gz + $TAR zxf ./../src/lame-$VERSION_LAME.tar.gz exit_on_error - $TAR xzf lame-$VERSION_LAME.tar.gz fi cd lame-$VERSION_LAME @@ -1004,16 +958,10 @@ build_libbluray() { start_build libbluray cd $SRC - rm -rf libbluray - $GIT clone git://git.videolan.org/libbluray.git libbluray + cp -a ./../src/libbluray ./ exit_on_error cd libbluray - - - if [ "$FIXED_REVISIONS" == "yes" ]; then - $GIT checkout "`$GIT rev-list master -n 1 --first-parent --before=$VERSION_LIBBLURAY`" - exit_on_error - fi + exit_on_error ./bootstrap ./configure --disable-shared --disable-dependency-tracking --prefix=$TARGET @@ -1033,9 +981,8 @@ build_libdca() { cd $SRC if [ ! -d libdca-$VERSION_LIBDCA ]; then - download http://download.videolan.org/pub/videolan/libdca/$VERSION_LIBDCA/libdca-$VERSION_LIBDCA.tar.bz2 + $TAR xjf ./../src/libdca-$VERSION_LIBDCA.tar.bz2 exit_on_error - $TAR xjf libdca-$VERSION_LIBDCA.tar.bz2 fi cd libdca-$VERSION_LIBDCA @@ -1057,9 +1004,8 @@ build_libdv() { cd $SRC if [ ! -d libdv-$VERSION_LIBDV ]; then - download http://downloads.sourceforge.net/project/libdv/libdv/$VERSION_LIBDV/libdv-$VERSION_LIBDV.tar.gz + $TAR zxf ./../src/libdv-$VERSION_LIBDV.tar.gz exit_on_error - $TAR xzf libdv-$VERSION_LIBDV.tar.gz fi cd libdv-$VERSION_LIBDV @@ -1090,9 +1036,8 @@ build_libmad() { cd $SRC if [ ! -d libmad-$VERSION_LIBMAD ]; then - download ftp://ftp.mars.org/pub/mpeg/libmad-$VERSION_LIBMAD.tar.gz + $TAR zxf ./../src/libmad-$VERSION_LIBMAD.tar.gz exit_on_error - $TAR xzf libmad-$VERSION_LIBMAD.tar.gz fi cd libmad-$VERSION_LIBMAD @@ -1114,12 +1059,12 @@ build_libmediainfo() { cd $SRC if [ ! -d libmediainfo_$VERSION_LIBMEDIAINFO ]; then - download http://downloads.sourceforge.net/project/mediainfo/source/libmediainfo/$VERSION_LIBMEDIAINFO/libmediainfo_$VERSION_LIBMEDIAINFO.tar.bz2 - exit_on_error if is_osx; then - $TAR xjf libmediainfo_$VERSION_LIBMEDIAINFO.tar.bz2 -s /MediaInfoLib/libmediainfo_$VERSION_LIBMEDIAINFO/ + $TAR xjf ./../src/libmediainfo_$VERSION_LIBMEDIAINFO.tar.bz2 -s /MediaInfoLib/libmediainfo_$VERSION_LIBMEDIAINFO/ + exit_on_error else - $TAR xjf libmediainfo_$VERSION_LIBMEDIAINFO.tar.bz2 + $TAR xjf ./../src/libmediainfo_$VERSION_LIBMEDIAINFO.tar.bz2 + exit_on_error mv ./MediaInfoLib/ ./libmediainfo_$VERSION_LIBMEDIAINFO fi fi @@ -1148,9 +1093,8 @@ build_libpng() { cd $SRC if [ ! -d libpng-$VERSION_LIBPNG ]; then - download http://downloads.sourceforge.net/project/libpng/libpng15/older-releases/$VERSION_LIBPNG/libpng-$VERSION_LIBPNG.tar.gz + $TAR zxf ./../src/libpng-$VERSION_LIBPNG.tar.gz exit_on_error - $TAR xzf libpng-$VERSION_LIBPNG.tar.gz fi cd libpng-$VERSION_LIBPNG @@ -1172,9 +1116,8 @@ build_libogg() { cd $SRC if [ ! -d libogg-$VERSION_LIBOGG ]; then - download http://downloads.xiph.org/releases/ogg/libogg-$VERSION_LIBOGG.tar.gz + $TAR zxf ./../src/libogg-$VERSION_LIBOGG.tar.gz exit_on_error - $TAR xzf libogg-$VERSION_LIBOGG.tar.gz fi cd libogg-$VERSION_LIBOGG @@ -1196,9 +1139,8 @@ build_libvorbis() { cd $SRC if [ ! -d libvorbis-$VERSION_LIBVORBIS ]; then - download http://downloads.xiph.org/releases/vorbis/libvorbis-$VERSION_LIBVORBIS.tar.gz + $TAR zxf ./../src/libvorbis-$VERSION_LIBVORBIS.tar.gz exit_on_error - $TAR xzf libvorbis-$VERSION_LIBVORBIS.tar.gz fi cd libvorbis-$VERSION_LIBVORBIS @@ -1220,9 +1162,8 @@ build_libtheora() { cd $SRC if [ ! -d libtheora-$VERSION_LIBTHEORA ]; then - download http://downloads.xiph.org/releases/theora/libtheora-$VERSION_LIBTHEORA.tar.bz2 + $TAR xjf ./../src/libtheora-$VERSION_LIBTHEORA.tar.bz2 exit_on_error - $TAR xjf libtheora-$VERSION_LIBTHEORA.tar.bz2 fi cd libtheora-$VERSION_LIBTHEORA @@ -1245,9 +1186,8 @@ build_libzen() { cd $SRC if [ ! -d libzen_$VERSION_LIBZEN ]; then - download http://downloads.sourceforge.net/project/zenlib/ZenLib%20-%20Sources/$VERSION_LIBZEN/libzen_$VERSION_LIBZEN.tar.bz2 + $TAR xjf ./../src/libzen_$VERSION_LIBZEN.tar.bz2 exit_on_error - $TAR xjf libzen_$VERSION_LIBZEN.tar.bz2 # For consistency and the check above have the same directory name as the .bz2 file available ln -s ZenLib libzen_$VERSION_LIBZEN @@ -1281,9 +1221,8 @@ build_lzo() { cd $SRC if [ ! -d lzo-$VERSION_LZO ]; then - download http://www.oberhumer.com/opensource/lzo/download/lzo-$VERSION_LZO.tar.gz + $TAR zxf ./../src/lzo-$VERSION_LZO.tar.gz exit_on_error - $TAR xzf lzo-$VERSION_LZO.tar.gz fi cd lzo-$VERSION_LZO @@ -1314,21 +1253,10 @@ build_mplayer() { start_build mplayer cd $SRC - if [ "$FIXED_REVISIONS" == "yes" ]; then - REVISION="-r $VERSION_MPLAYER" - else - REVISION="" - fi - - if [ -d mplayer ]; then - cd mplayer - $SVN update $REVISION - exit_on_error - else - $SVN checkout $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mplayer - exit_on_error - cd mplayer - fi + cp -a ./../src/mplayer ./ + exit_on_error + cd mplayer + exit_on_error # Copy ffmpeg source to avoid making another git clone by configure rm -rf ffmpeg @@ -1346,7 +1274,7 @@ build_mplayer() { # See https://svn.macports.org/ticket/30279 # Apply SB patch that was used for the Windows version - patch -p0 < ./../../../contrib/mplayer-r34587-SB22.patch + patch -p0 < ./../../../../contrib/mplayer-r34587-SB22.patch exit_on_error # Theora and vorbis support seems broken in this revision, disable it for now @@ -1364,15 +1292,12 @@ build_mplayer() { export CFLAGS="$CFLAGS -O4 -fomit-frame-pointer -pipe" export LDFLAGS="$LDFLAGS -O4 -fomit-frame-pointer -pipe" - $SVN revert * - $SVN revert libao2/* - $SVN revert libvo/* # Apply SB patch that was used for the Windows version - patch -p0 < ./../../../contrib/mplayer-r34587-SB22.patch + patch -p0 < ./../../../../contrib/mplayer-r34587-SB22.patch exit_on_error # mplayer configure patch for r34587-SB22 - patch -p0 < ./../../../contrib/mplayer-r34587-configure.patch + patch -p0 < ./../../../../contrib/mplayer-r34587-configure.patch exit_on_error # libvorbis support seems broken in this revision, disable it for now @@ -1412,9 +1337,8 @@ build_ncurses() { cd $SRC if [ ! -d ncurses-$VERSION_NCURSES ]; then - download http://ftp.gnu.org/pub/gnu/ncurses/ncurses-$VERSION_NCURSES.tar.gz + $TAR zxf ./../src/ncurses-$VERSION_NCURSES.tar.gz exit_on_error - $TAR xzf ncurses-$VERSION_NCURSES.tar.gz fi cd ncurses-$VERSION_NCURSES @@ -1509,8 +1433,6 @@ build_tsMuxeR() { if is_osx; then if [ ! -d tsMuxeR_$VERSION_TSMUXER ]; then - $CURL -H "Referer: http://www.videohelp.com/tools/tsMuxeR" -L http://www.videohelp.com/download/tsMuxeR_$VERSION_TSMUXER.dmg > tsMuxeR_$VERSION_TSMUXER.dmg - exit_on_error createdir tsMuxeR_$VERSION_TSMUXER fi @@ -1526,7 +1448,7 @@ build_tsMuxeR() { cd tsMuxeR_$VERSION_TSMUXER $WGET --referer="http://www.videohelp.com/tools/tsMuxeR" http://www.videohelp.com/download/tsMuxeR_$VERSION_TSMUXER.tar.gz exit_on_error - $TAR xzf tsMuxeR_$VERSION_TSMUXER.tar.gz + $TAR zxf ./../src/tsMuxeR_$VERSION_TSMUXER.tar.gz cd .. fi @@ -1546,20 +1468,10 @@ build_x264() { start_build x264 cd $SRC - if [ -d x264 ]; then - cd x264 - $GIT pull git://git.videolan.org/x264.git - exit_on_error - else - $GIT clone git://git.videolan.org/x264.git x264 -b stable - exit_on_error - cd x264 - fi - - if [ "$FIXED_REVISIONS" == "yes" ]; then - $GIT checkout "`$GIT rev-list stable -n 1 --first-parent --before=$VERSION_X264`" - exit_on_error - fi + cp -a ./../src/x264 ./ + exit_on_error + cd x264 + exit_on_error set_flags @@ -1595,9 +1507,8 @@ build_xvid() { cd $SRC if [ ! -d xvidcore-$VERSION_XVID ]; then - download http://downloads.xvid.org/downloads/xvidcore-$VERSION_XVID.tar.gz + $TAR zxf ./../src/xvidcore-$VERSION_XVID.tar.gz exit_on_error - $TAR xzf xvidcore-$VERSION_XVID.tar.gz mv xvidcore xvidcore-$VERSION_XVID fi @@ -1638,9 +1549,8 @@ build_zlib() { cd $SRC if [ ! -d zlib-$VERSION_ZLIB ]; then - download http://zlib.net/zlib-$VERSION_ZLIB.tar.gz + $TAR xzf ./../src/zlib-$VERSION_ZLIB.tar.gz exit_on_error - $TAR xzf zlib-$VERSION_ZLIB.tar.gz fi cd zlib-$VERSION_ZLIB @@ -1674,7 +1584,7 @@ build_yasm() { cd $SRC if [ ! -d yasm-$VERSION_YASM ]; then - $TAR xzf yasm-$VERSION_YASM.tar.gz + $TAR zxf ./../src/yasm-$VERSION_YASM.tar.gz exit_on_error fi @@ -1743,4 +1653,4 @@ build_ffmpeg build_mplayer # Build PS3 Media Server itself -build_ps3mediaserver +# build_ps3mediaserver diff --git a/contrib/download-pms-binaries-source.sh b/contrib/download-pms-binaries-source.sh new file mode 100755 index 000000000..c917e3bfe --- /dev/null +++ b/contrib/download-pms-binaries-source.sh @@ -0,0 +1,764 @@ +#!/bin/bash +# +# download-pms-binaries-source.sh +# +# Version: 1.0 +# Last updated: 2012-01-26 +# Authors: Happy-Neko +# Based on build-pms-binaries.sh by Patrick Atoon and Happy-Neko +# +# +# DESCRIPTION +# Download sources for binary tools and their dependencies. +# +# REQUIREMENTS +# sed, git, subversion, wget (for Linux) or curl (for Mac OS X) +# +# CONFIGURATION +# +# Set FIXED_REVISIONS to "no" to check out the latest revisions. +# Default is "yes" to check out the last known working revision. +FIXED_REVISIONS="yes" + +# binaries deps versions +. contrib/binaries-deps-versions + +########################################## +# Determine the name of the operating system. +# +UNAME=`which uname` +SYSTEM_NAME=`$UNAME -s | tr "[:upper:]" "[:lower:]"` + + +########################################## +# Test to see if we are on Mac OSX. +# +is_osx() { + test "$SYSTEM_NAME" = "darwin" +} + + +########################################## +# Test to see if we are on Linux. +# +is_linux() { + # This assumes the world only consist of Linux and OS X. Should be + # fine for now as the script does not cater for Windows. + test "$SYSTEM_NAME" != "darwin" +} + + +########################################## +# Check to see if a binary exists. Displays an instruction on how to +# resolve the problem when a binary cannot be found. +# +check_binary() { + BINARY=$1 + BINARY_PATH=`command -v $BINARY` + + if [ "$BINARY_PATH" == "" ]; then + case "$BINARY" in + git) + if is_osx; then + cat >&2 << EOM +It seems you are missing "git", which is required to run this script. +Please go to http://code.google.com/p/git-osx-installer/, download git +and install it. + +EOM + else + cat >&2 << EOM +It seems you are missing "git", which is required to run this script. +You can install Git with following command on Debian based systems (Debian, Ubuntu, etc): + + sudo apt-get install git + +Or (for older systems): + + sudo apt-get install git-core + +EOM + fi + exit;; + + svn) + if is_osx; then + cat >&2 << EOM +It seems you are missing Xcode from Apple ("svn"), which is required to run this script. + +Please go to http://developer.apple.com/technologies/xcode.html, create a free +Apple developer account and download Xcode and install it. + +EOM + else + cat >&2 << EOM +It seems you are missing "svn", which is required to run this script. +You can install Subversion with following command on Debian based systems (Debian, Ubuntu, etc): + + sudo apt-get install subversion + +EOM + fi + exit;; + + wget) + cat >&2 << EOM +It seems you are missing "wget", which is required to run this script. +You can install Wget with following command on Debian based systems (Debian, Ubuntu, etc): + + sudo apt-get install wget + +EOM + exit;; + + *) + cat >&2 << EOM +It seems you are missing "$BINARY", which is required to run this script. +Please make sure the binary is installed, executable and available in the PATH +("which $BINARY" should print a path when you execute it). +EOM + exit;; + esac + fi + + # If we didn't exit by now, we're fine. + echo $BINARY_PATH +} + + +# Binaries +GIT=`check_binary git` +SED=`check_binary sed` +SVN=`check_binary svn` + +if is_osx; then + CURL=`check_binary curl` +else + WGET=`check_binary wget` +fi + + +########################################## +# Create a directory when it does not exist +# +createdir() { + if [ ! -d $1 ]; then + mkdir -p $1 + fi +} + + +########################################## +# Download a file from a URL +# +download() { + URL=$1 + FILENAME=`echo $URL | $SED "s/.*\///g"` + + if is_osx; then + $CURL -L $URL > $FILENAME + else + $WGET $URL + fi +} + + +########################################## +# Exit if the previous command ended with an error status +# +exit_on_error() { + if [ "$?" != "0" ]; then + ER=$? + echo Fatal error occurred, aborting build. + cd $WORKDIR + exit $ER + fi +} + + +########################################## +# Initialize environment +# +initialize() { + WORKDIR=`pwd` + SRC="$WORKDIR/target/bin-tools/src" + createdir "$SRC" +} + + +########################################## +# Download start marker to more easily follow the downloading process +# +start_download() { + cat << EOM + + +-------------------------------------------------------------------------------------- +Downloading $1 +-------------------------------------------------------------------------------------- + +EOM +} + + +########################################## +# BZIP2 +# http://bzip.org/ +# +download_bzip2() { + start_download bzip2 + cd $SRC + + if [ ! -f bzip2-$VERSION_BZIP2.tar.gz ]; then + download http://bzip.org/$VERSION_BZIP2/bzip2-$VERSION_BZIP2.tar.gz + exit_on_error + fi +} + + +########################################## +# DCRAW +# http://www.cybercom.net/~dcoffin/dcraw/ +# +download_dcraw() { + start_download dcraw + cd $SRC + + if [ ! -f dcraw-$VERSION_DCRAW.tar.gz ]; then + download http://www.cybercom.net/~dcoffin/dcraw/archive/dcraw-$VERSION_DCRAW.tar.gz + exit_on_error + fi +} + + +########################################## +# EXPAT +# http://expat.sourceforge.net/ +# +download_expat() { + start_download expat + cd $SRC + + if [ ! -f expat-$VERSION_EXPAT.tar.gz ]; then + download http://downloads.sourceforge.net/project/expat/expat/$VERSION_EXPAT/expat-$VERSION_EXPAT.tar.gz + exit_on_error + fi +} + + +########################################## +# FAAD2 +# http://www.audiocoding.com/faad2.html +# +download_faad2() { + start_download faad2 + cd $SRC + + if [ ! -f faad2-$VERSION_FAAD2.tar.gz ]; then + download http://downloads.sourceforge.net/project/faac/faad2-src/faad2-$VERSION_FAAD2/faad2-$VERSION_FAAD2.tar.gz + exit_on_error + fi +} + + +########################################## +# FFMPEG +# http://www.ffmpeg.org/ +# +download_ffmpeg() { + start_download ffmpeg + cd $SRC + + if [ -d ffmpeg ]; then + rm -rf ffmpeg + fi + $GIT clone git://git.videolan.org/ffmpeg.git ffmpeg + exit_on_error + cd ffmpeg + + if [ "$FIXED_REVISIONS" == "yes" ]; then + $GIT checkout tags/$VERSION_FFMPEG + exit_on_error + fi + rm -rf ./.git +} + + +########################################## +# FLAC +# http://flac.sourceforge.net/ +# +download_flac() { + start_download flac + cd $SRC + + if [ ! -f flac-$VERSION_FLAC.tar.gz ]; then + download http://downloads.xiph.org/releases/flac/flac-$VERSION_FLAC.tar.gz + exit_on_error + fi +} + + +########################################## +# FONTCONFIG +# http://fontconfig.org/wiki/ +# +download_fontconfig() { + start_download fontconfig + cd $SRC + + if [ ! -f fontconfig-$VERSION_FONTCONFIG.tar.gz ]; then + download http://www.freedesktop.org/software/fontconfig/release/fontconfig-$VERSION_FONTCONFIG.tar.gz + exit_on_error + fi +} + + +########################################## +# FREETYPE +# http://www.freetype.org/ +# +download_freetype() { + start_download freetype + cd $SRC + + if [ ! -f freetype-$VERSION_FREETYPE.tar.gz ]; then + download http://download.savannah.gnu.org/releases/freetype/freetype-$VERSION_FREETYPE.tar.gz + exit_on_error + fi +} + + +########################################## +# FRIBIDI +# http://fribidi.org/ +# +download_fribidi() { + start_download fribidi + cd $SRC + + if [ ! -f fribidi-$VERSION_FRIBIDI.tar.gz ]; then + download http://fribidi.org/download/fribidi-$VERSION_FRIBIDI.tar.gz + exit_on_error + fi +} + + +########################################## +# GIFLIB +# http://sourceforge.net/projects/giflib/ +# +download_giflib() { + start_download giflib + cd $SRC + + if [ ! -f giflib-$VERSION_GIFLIB.tar.bz2 ]; then + download http://downloads.sourceforge.net/project/giflib/giflib%204.x/giflib-$VERSION_GIFLIB/giflib-$VERSION_GIFLIB.tar.bz2 + exit_on_error + fi +} + + +########################################## +# ICONV +# http://www.gnu.org/software/libiconv/ +# +download_iconv() { + start_download iconv + cd $SRC + + if [ ! -f libiconv-$VERSION_ICONV.tar.gz ]; then + download http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$VERSION_ICONV.tar.gz + exit_on_error + fi +} + + +########################################## +# JPEG +# http://www.ijg.org/ +# +download_jpeg() { + start_download jpeg + cd $SRC + + if [ ! -f jpegsrc.v$VERSION_JPEG.tar.gz ]; then + download http://www.ijg.org/files/jpegsrc.v$VERSION_JPEG.tar.gz + exit_on_error + fi +} + + +########################################## +# LAME +# http://lame.sourceforge.net/ +# +download_lame() { + start_download lame + cd $SRC + + if [ ! -f lame-$VERSION_LAME.tar.gz ]; then + #download http://downloads.sourceforge.net/project/lame/lame/$VERSION_LAME/lame-$VERSION_LAME.tar.gz + # Blah! 3.99.2 resides in the directory 3.99. Hardcoding that for now. + download http://downloads.sourceforge.net/project/lame/lame/3.99/lame-$VERSION_LAME.tar.gz + exit_on_error + fi +} + + +########################################## +# LIBBLURAY +# http://www.videolan.org/developers/libbluray.html +# +download_libbluray() { + start_download libbluray + cd $SRC + + if [ -d libbluray ]; then + rm -rf libbluray + fi + $GIT clone git://git.videolan.org/libbluray.git libbluray + exit_on_error + cd libbluray + + if [ "$FIXED_REVISIONS" == "yes" ]; then + $GIT checkout $VERSION_LIBBLURAY + exit_on_error + fi + rm -rf ./.git +} + + +########################################## +# LIBDCA +# http://www.videolan.org/developers/libdca.html +# +download_libdca() { + start_download libdca + cd $SRC + + if [ ! -f libdca-$VERSION_LIBDCA.tar.bz2 ]; then + download http://download.videolan.org/pub/videolan/libdca/$VERSION_LIBDCA/libdca-$VERSION_LIBDCA.tar.bz2 + exit_on_error + fi +} + + +########################################## +# LIBDV +# http://libdv.sourceforge.net/ +# +download_libdv() { + start_download libdv + cd $SRC + + if [ ! -f libdv-$VERSION_LIBDV.tar.gz ]; then + download http://downloads.sourceforge.net/project/libdv/libdv/$VERSION_LIBDV/libdv-$VERSION_LIBDV.tar.gz + exit_on_error + fi +} + + +########################################## +# LIBMAD +# http://www.underbit.com/products/mad/ +# +download_libmad() { + start_download libmad + cd $SRC + + if [ ! -f libmad-$VERSION_LIBMAD.tar.gz ]; then + download ftp://ftp.mars.org/pub/mpeg/libmad-$VERSION_LIBMAD.tar.gz + exit_on_error + fi +} + + +########################################## +# LIBMEDIAINFO +# http://sourceforge.net/projects/mediainfo/ +# +download_libmediainfo() { + start_download libmediainfo + cd $SRC + + if [ ! -f libmediainfo_$VERSION_LIBMEDIAINFO.tar.bz2 ]; then + download http://downloads.sourceforge.net/project/mediainfo/source/libmediainfo/$VERSION_LIBMEDIAINFO/libmediainfo_$VERSION_LIBMEDIAINFO.tar.bz2 + exit_on_error + fi +} + + +########################################## +# LIBPNG +# http://www.libpng.org/pub/png/libpng.html +# +download_libpng() { + start_download libpng + cd $SRC + + if [ ! -f libpng-$VERSION_LIBPNG.tar.gz ]; then + download http://downloads.sourceforge.net/project/libpng/libpng15/older-releases/$VERSION_LIBPNG/libpng-$VERSION_LIBPNG.tar.gz + exit_on_error + fi +} + + +########################################## +# LIBOGG +# http://xiph.org/downloads/ +# +download_libogg() { + start_download libogg + cd $SRC + + if [ ! -f libogg-$VERSION_LIBOGG.tar.gz ]; then + download http://downloads.xiph.org/releases/ogg/libogg-$VERSION_LIBOGG.tar.gz + exit_on_error + fi +} + + +########################################## +# LIBVORBIS +# http://xiph.org/downloads/ +# +download_libvorbis() { + start_download libvorbis + cd $SRC + + if [ ! -f libvorbis-$VERSION_LIBVORBIS.tar.gz ]; then + download http://downloads.xiph.org/releases/vorbis/libvorbis-$VERSION_LIBVORBIS.tar.gz + exit_on_error + fi +} + + +########################################## +# LIBTHEORA +# http://xiph.org/downloads/ +# +download_libtheora() { + start_download libtheora + cd $SRC + + if [ ! -f libtheora-$VERSION_LIBTHEORA.tar.bz2 ]; then + download http://downloads.xiph.org/releases/theora/libtheora-$VERSION_LIBTHEORA.tar.bz2 + exit_on_error + fi +} + + +########################################## +# LIBZEN +# http://sourceforge.net/projects/zenlib/ +# +download_libzen() { + start_download libzen + cd $SRC + + if [ ! -f libzen_$VERSION_LIBZEN.tar.bz2 ]; then + download http://downloads.sourceforge.net/project/zenlib/ZenLib%20-%20Sources/$VERSION_LIBZEN/libzen_$VERSION_LIBZEN.tar.bz2 + exit_on_error + fi +} + + +########################################## +# LZO +# http://www.oberhumer.com/opensource/lzo/ +# +download_lzo() { + start_download lzo + cd $SRC + + if [ ! -f lzo-$VERSION_LZO.tar.gz ]; then + download http://www.oberhumer.com/opensource/lzo/download/lzo-$VERSION_LZO.tar.gz + exit_on_error + fi +} + + +########################################## +# MPLAYER +# http://www.mplayerhq.hu/design7/news.html +# +download_mplayer() { + start_download mplayer + cd $SRC + + if [ "$FIXED_REVISIONS" == "yes" ]; then + REVISION="-r $VERSION_MPLAYER" + else + REVISION="" + fi + + if [ -d mplayer ]; then + rm -rf mplayer + fi + $SVN export $REVISION svn://svn.mplayerhq.hu/mplayer/trunk mplayer + exit_on_error +} + + +########################################## +# NCURSES +# http://www.gnu.org/software/ncurses/ +# +download_ncurses() { + start_download ncurses + cd $SRC + + if [ ! -f ncurses-$VERSION_NCURSES.tar.gz ]; then + download http://ftp.gnu.org/pub/gnu/ncurses/ncurses-$VERSION_NCURSES.tar.gz + exit_on_error + fi +} + + +########################################## +# TSMUXER +# http://www.smlabs.net/en/products/tsmuxer/ +# http://www.videohelp.com/tools/tsMuxeR +# Interesting Open Source followup project in development: https://github.com/kierank/libmpegts +# +download_tsMuxeR() { + start_download tsMuxeR + cd $SRC + + if is_osx; then + if [ ! -f tsMuxeR_$VERSION_TSMUXER.dmg ]; then + $CURL -H "Referer: http://www.videohelp.com/tools/tsMuxeR" -L http://www.videohelp.com/download/tsMuxeR_$VERSION_TSMUXER.dmg > tsMuxeR_$VERSION_TSMUXER.dmg + exit_on_error + fi + fi +} + + +########################################## +# X264 +# svn://svn.videolan.org/x264/trunk +# +download_x264() { + start_download x264 + cd $SRC + + if [ -d x264 ]; then + rm -rf x264 + fi + $GIT clone git://git.videolan.org/x264.git x264 -b stable + exit_on_error + cd x264 + + #if [ "$FIXED_REVISIONS" == "yes" ]; then + # $GIT checkout $VERSION_X264 + # exit_on_error + #fi + rm -rf ./.git +} + + +########################################## +# XVID +# http://www.xvid.org/ +# +download_xvid() { + start_download xvid + cd $SRC + + if [ ! -f xvidcore-$VERSION_XVID.tar.gz ]; then + download http://downloads.xvid.org/downloads/xvidcore-$VERSION_XVID.tar.gz + exit_on_error + fi +} + + +########################################## +# ZLIB +# http://zlib.net/ +# +download_zlib() { + start_download zlib + cd $SRC + + if [ ! -f zlib-$VERSION_ZLIB.tar.gz ]; then + download http://sourceforge.net/projects/libpng/files/zlib/$VERSION_ZLIB/zlib-$VERSION_ZLIB.tar.gz + exit_on_error + fi +} + + +########################################## +# ENCA Extremely Naive Charset Analyser +# http://cihar.com/software/enca/ +# +download_enca() { + start_download enca + cd $SRC + + if [ ! -f enca-$VERSION_ENCA.tar.gz ]; then + download http://dl.cihar.com/enca/enca-$VERSION_ENCA.tar.gz + exit_on_error + fi +} + + +########################################## +# YASM +# http://yasm.tortall.net/ +# +download_yasm() { + start_download yasm + cd $SRC + + if [ ! -f yasm-$VERSION_YASM.tar.gz ]; then + download http://www.tortall.net/projects/yasm/releases/yasm-$VERSION_YASM.tar.gz + exit_on_error + fi +} + + +########################################## +# Finally, execute the script... +# + +initialize + +download_yasm +download_zlib +download_bzip2 +download_expat +download_faad2 +download_freetype +download_iconv +# Note: fontconfig requires freetype and iconv to build +download_fontconfig +download_fribidi +download_giflib +download_jpeg +download_ncurses +download_lame +download_libbluray +download_libdca +download_libdv +download_libmad +download_libzen +# Note: libmediainfo requires libzen to build +download_libmediainfo +download_libpng +download_libogg +download_libvorbis +download_libtheora +download_lzo +download_x264 +download_xvid + +# Build tools for including with PS3 Media Server +download_flac +download_dcraw +if is_osx; then + download_tsMuxeR +fi +download_enca +download_ffmpeg +download_mplayer