Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # forked/adapted from http://www.github.com/markus-perl
- # Version 0.3rg
- CWD=`pwd`
- PACKAGES="$CWD/packages"
- WORKSPACE="$CWD/workspace"
- CC=clang
- LDFLAGS="-L${WORKSPACE}/lib -lm"
- CFLAGS="-I${WORKSPACE}/include"
- PKG_CONFIG_PATH="${WORKSPACE}/lib/pkgconfig"
- make_dir () {
- if [ ! -d $1 ]; then
- if ! mkdir $1; then
- echo "\nFailed to create dir $1";
- exit 1
- fi
- fi
- }
- remove_dir () {
- if [ -d $1 ]; then
- rm -r "$1"
- fi
- }
- download () {
- if [ ! -f "$PACKAGES/$2" ]; then
- printf "Downloading $1"
- curl -L --silent -o "$PACKAGES/$2" "$1"
- EXITCODE=$?
- if [ $EXITCODE -ne 0 ]; then
- echo ""
- echo "Failed to download $1. Exitcode $EXITCODE";
- exit 1
- fi
- printf " ... Done\n"
- if ! tar -xvf "$PACKAGES/$2" -C "$PACKAGES" 2>/dev/null >/dev/null; then
- echo "Failed to extract $2";
- exit 1
- fi
- fi
- }
- execute () {
- echo "$ $@"
- OUTPUT="$($@ 2>&1)"
- if [ $? -ne 0 ]; then
- echo $OUTPUT
- echo ""
- echo "Failed to Execute $@" >&2
- exit 1
- fi
- }
- build () {
- echo ""
- echo "building $1"
- echo "======================="
- if [ -f "$PACKAGES/$1.done" ]; then
- echo "$1 already built. Remove $PACKAGES/$1.done lockfile to rebuild it."
- return 1
- fi
- return 0
- }
- build_done () {
- touch "$PACKAGES/$1.done"
- }
- case "$1" in
- "--cleanup")
- remove_dir $PACKAGES
- remove_dir $WORKSPACE
- echo "Cleanup done"
- exit 0
- ;;
- "--build")
- ;;
- *)
- echo "Usage: $0"
- echo " --build: start building process"
- echo " --cleanup: remove all working dirs"
- echo " --help: show this help"
- exit 0
- ;;
- esac
- make_dir $PACKAGES
- make_dir $WORKSPACE
- make_dir $CMPL
- export PATH=${WORKSPACE}/bin:$PATH
- if build "yasm"; then
- download "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz" "yasm-1.3.0.tar.gz"
- cd $PACKAGES/yasm-1.3.0
- execute ./configure --prefix=${WORKSPACE}
- execute make -j 4
- execute make install
- build_done "yasm"
- fi
- if build "opencore"; then
- download "http://garr.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz" "opencore-amr-0.1.3.tar.gz"
- cd $PACKAGES/opencore-amr-0.1.3
- execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
- execute make -j 4
- execute make install
- build_done "opencore"
- fi
- if build "libvpx"; then
- download "http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2" "libvpx-v1.3.0.tar.bz2"
- cd $PACKAGES/libvpx-v1.3.0
- execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
- execute make -j 4
- execute make install
- build_done "libvpx"
- fi
- if build "lame"; then
- download "http://kent.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz" "lame-3.99.5.tar.gz"
- cd $PACKAGES/lame-3.99.5
- execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
- execute make -j 4
- execute make install
- build_done "lame"
- fi
- if build "xvidcore"; then
- download "http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz" "xvidcore-1.3.3.tar.gz"
- cd $PACKAGES/xvidcore
- cd build/generic
- execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
- execute make -j 4
- execute make install
- if [ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]; then
- execute rm ${WORKSPACE}/lib/libxvidcore.4.dylib
- fi
- build_done "xvidcore"
- fi
- if build "x264"; then
- # download "ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2" "last_x264.tar.bz2" if firewall allows ftp
- download "http://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2" "last_x264.tar.bz2"
- cd $PACKAGES/x264-snapshot-*
- execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
- execute make -j 4
- execute make install
- execute make install-lib-static
- build_done "x264"
- fi
- if build "libogg"; then
- download "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz" "libogg-1.3.2.tar.gz"
- cd $PACKAGES/libogg-1.3.2
- execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
- execute make -j 4
- execute make install
- build_done "libogg"
- fi
- if build "libvorbis"; then
- download "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz" "libvorbis-1.3.4.tar.gz"
- cd $PACKAGES/libvorbis-1.3.4
- execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest
- execute make -j 4
- execute make install
- build_done "libvorbis"
- fi
- if build "libtheora"; then
- download "http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz" "libtheora-1.1.1.tar.bz"
- cd $PACKAGES/libtheora-1.1.1
- sed "s/-fforce-addr//g" configure > configure.patched
- chmod +x configure.patched
- mv configure.patched configure
- execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --with-vorbis-libraries=${WORKSPACE}/lib --with-vorbis-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm
- execute make -j 4
- execute make install
- build_done "libtheora"
- fi
- if build "pkg-config"; then
- download "http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz" "pkg-config-0.28.tar.gz"
- cd $PACKAGES/pkg-config-0.28
- execute ./configure --silent --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --with-internal-glib
- execute make -j 4
- execute make install
- build_done "pkg-config"
- fi
- if build "freetype"; then
- download "http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2" "freetype-2.4.0.tar.bz2"
- cd $PACKAGES/freet*
- execute ./configure --silent --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --disable-shared --enable-static
- execute make -j 4
- execute make install
- build_done "freetype"
- fi
- if build "libxml2"; then
- download "ftp://xmlsoft.org/libxml2/libxml2-sources-2.9.2.tar.gz" "libxml2-sources-2.9.2.tar.gz"
- cd $PACKAGES/libxm*
- execute ./configure --prefix=${WORKSPACE} --enable-shared=yes --enable-static=yes --with-python=NO --with-python-install-dir=${WORKSPACE}/libxmlpython
- execute make -j 4
- execute make install
- build_done "libxml2"
- fi
- if build "fontconfig"; then
- download "http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.94.tar.gz" "fontconfig-2.11.94.tar.gz"
- cd $PACKAGES/fontc*
- execute ./configure --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --enable-shared=no --enable-static=yes --enable-libxml2
- execute make -j 4
- execute make install
- build_done "fontconfig"
- fi
- if build "cmake"; then
- download "http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz" "cmake-3.0.2.tar.gz"
- cd $PACKAGES/cmake*
- rm Modules/FindJava.cmake
- perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
- perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
- execute ./configure --prefix=${WORKSPACE}
- execute make -j 4
- execute make install
- build_done "cmake"
- fi
- if build "vid_stab"; then
- download "https://codeload.github.com/georgmartius/vid.stab/legacy.tar.gz/release-0.98b" "vid.stab-0.98b-transcode-1.1-binary-x86_64.tgz"
- cd $PACKAGES/georgmartius-vid*
- perl -p -i -e "s/vidstab SHARED/vidstab STATIC/" CMakeLists.txt
- execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
- execute make -s install
- build_done "vid_stab"
- fi
- if build "x265"; then
- download "https://bitbucket.org/multicoreware/x265/downloads/x265_1.7.tar.gz" "x265-1.7.tar.gz"
- cd $PACKAGES/x265_1.7
- cd source
- execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
- execute make -j 4
- execute make install
- sed "s/-lx265/-lx265 -lstdc++/g" "$WORKSPACE/lib/pkgconfig/x265.pc" > "$WORKSPACE/lib/pkgconfig/x265.pc.tmp"
- mv "$WORKSPACE/lib/pkgconfig/x265.pc.tmp" "$WORKSPACE/lib/pkgconfig/x265.pc"
- build_done "x265"
- fi
- if build "fdk_aac"; then
- # download "http://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.3.tar.gz" "fdk-aac-0.1.3.tar.gz"
- download "http://ftp.cc.uoc.gr/mirrors/linux/lfs/LFS/7.6/f/fdk-aac-0.1.3.tar.gz" "fdk-aac-0.1.3.tar.gz"
- cd $PACKAGES/fdk-aac*
- execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
- execute make -j 4
- execute make install
- build_done "fdk_aac"
- fi
- if build "frei0r"; then
- download "https://files.dyne.org/frei0r/snapshots/frei0r-snapshot-27-01-15.tar.gz" "frei0r-snapshot-27-01-15.tar.gz"
- cd $PACKAGES/frei0r*
- perl -p -i -e "s/OpenCV\" OFF/OpenCV\" ON/" CMakeLists.txt
- execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
- #execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
- execute make -s install
- for file in ${WORKSPACE}/lib/frei0r-1/*.so ; do
- cp $file "${file%.*}.dylib"
- done
- build_done "frei0r"
- fi
- build "ffmpeg"
- download "http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 " "ffmpeg-snapshot.tar.bz2 "
- cd $PACKAGES/ffmpeg*
- CFLAGS="-I$WORKSPACE/include" LDFLAGS="-L$WORKSPACE/lib"
- echo "pkgconfig is `which pkg-config` and fontconfig lib is `pkg-config fontconfig --libs`"
- execute ./configure --arch=64 --prefix=${WORKSPACE} --pkg-config-flags="--static" --extra-cflags="-I$WORKSPACE/include" --extra-ldflags="-L$WORKSPACE/lib -static" --extra-version=static --disable-debug --disable-shared --enable-static --disable-ffplay --disable-ffserver --disable-doc --enable-version3 --enable-libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-gpl --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-nonfree --enable-filters --enable-libvidstab --enable-libx265 --enable-runtime-cpudetect --enable-libfdk-aac --enable-frei0r --enable-libfreetype --enable-fontconfig
- # ./configure --arch=64 --prefix=${WORKSPACE} --extra-cflags="-I$WORKSPACE/include" --extra-ldflags="-L$WORKSPACE/lib" --extra-version=static --disable-debug --disable-shared --enable-static --extra-cflags=--static --disable-ffplay --disable-ffserver --disable-doc --enable-version3 --enable-libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-gpl --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-nonfree --enable-filters --enable-libvidstab --enable-libx265 --enable-runtime-cpudetect --enable-libfdk-aac --enable-frei0r --enable-libfreetype --enable-fontconfig
- execute make -j 4
- execute make install
- echo ""
- echo "Building done. The binary can be found here: $WORKSPACE/bin/ffmpeg"
- echo ""
- read -r -p "Install the binary to your /usr/local/bin/ folder? [Y/n] " response
- case $response in
- [yY][eE][sS]|[yY])
- sudo cp "$WORKSPACE/bin/ffmpeg" "/usr/local/bin/ffmpeg"
- sudo cp "$WORKSPACE/bin/ffprobe" "/usr/local/bin/ffprobe"
- echo "Done. ffmpeg is now installed to your system"
- ;;
- esac
- echo ""
- echo "The frei0r plugins can be found here: $WORKSPACE/lib/ in a folder named \"frei0r-1\""
- echo ""
- read -r -p "Copy frei0r plugins to your /usr/local/lib/frei0r-1 folder [Y/n] " response
- case $response in
- [yY][eE][sS]|[yY])
- sudo cp -Rv "$WORKSPACE/lib/frei0r-1" "/usr/local/lib/"
- echo "Done. frei0r plugins are now installed to your system"
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment