Guest User

Untitled

a guest
Jul 18th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.32 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # forked/adapted from http://www.github.com/markus-perl
  4. # Version 0.3rg
  5.  
  6. CWD=`pwd`
  7. PACKAGES="$CWD/packages"
  8. WORKSPACE="$CWD/workspace"
  9. CC=clang
  10. LDFLAGS="-L${WORKSPACE}/lib -lm"
  11. CFLAGS="-I${WORKSPACE}/include"
  12. PKG_CONFIG_PATH="${WORKSPACE}/lib/pkgconfig"
  13.  
  14. make_dir () {
  15. if [ ! -d $1 ]; then
  16. if ! mkdir $1; then
  17. echo "\nFailed to create dir $1";
  18. exit 1
  19. fi
  20. fi
  21. }
  22.  
  23. remove_dir () {
  24. if [ -d $1 ]; then
  25. rm -r "$1"
  26. fi
  27.  
  28. }
  29.  
  30. download () {
  31. if [ ! -f "$PACKAGES/$2" ]; then
  32.  
  33. printf "Downloading $1"
  34. curl -L --silent -o "$PACKAGES/$2" "$1"
  35. EXITCODE=$?
  36. if [ $EXITCODE -ne 0 ]; then
  37. echo ""
  38. echo "Failed to download $1. Exitcode $EXITCODE";
  39. exit 1
  40. fi
  41.  
  42. printf " ... Done\n"
  43.  
  44. if ! tar -xvf "$PACKAGES/$2" -C "$PACKAGES" 2>/dev/null >/dev/null; then
  45. echo "Failed to extract $2";
  46. exit 1
  47. fi
  48.  
  49. fi
  50. }
  51.  
  52. execute () {
  53. echo "$ $@"
  54. OUTPUT="$($@ 2>&1)"
  55.  
  56. if [ $? -ne 0 ]; then
  57. echo $OUTPUT
  58. echo ""
  59. echo "Failed to Execute $@" >&2
  60. exit 1
  61. fi
  62.  
  63. }
  64.  
  65. build () {
  66.  
  67. echo ""
  68. echo "building $1"
  69. echo "======================="
  70.  
  71. if [ -f "$PACKAGES/$1.done" ]; then
  72. echo "$1 already built. Remove $PACKAGES/$1.done lockfile to rebuild it."
  73. return 1
  74. fi
  75.  
  76.  
  77.  
  78. return 0
  79. }
  80.  
  81. build_done () {
  82. touch "$PACKAGES/$1.done"
  83. }
  84.  
  85.  
  86.  
  87. case "$1" in
  88. "--cleanup")
  89. remove_dir $PACKAGES
  90. remove_dir $WORKSPACE
  91. echo "Cleanup done"
  92. exit 0
  93. ;;
  94. "--build")
  95.  
  96. ;;
  97. *)
  98. echo "Usage: $0"
  99. echo " --build: start building process"
  100. echo " --cleanup: remove all working dirs"
  101. echo " --help: show this help"
  102. exit 0
  103. ;;
  104. esac
  105.  
  106.  
  107.  
  108. make_dir $PACKAGES
  109. make_dir $WORKSPACE
  110. make_dir $CMPL
  111.  
  112. export PATH=${WORKSPACE}/bin:$PATH
  113.  
  114.  
  115. if build "yasm"; then
  116. download "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz" "yasm-1.3.0.tar.gz"
  117. cd $PACKAGES/yasm-1.3.0
  118. execute ./configure --prefix=${WORKSPACE}
  119. execute make -j 4
  120. execute make install
  121. build_done "yasm"
  122. fi
  123.  
  124.  
  125. if build "opencore"; then
  126. 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"
  127. cd $PACKAGES/opencore-amr-0.1.3
  128. execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
  129. execute make -j 4
  130. execute make install
  131. build_done "opencore"
  132. fi
  133.  
  134. if build "libvpx"; then
  135. download "http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2" "libvpx-v1.3.0.tar.bz2"
  136. cd $PACKAGES/libvpx-v1.3.0
  137. execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
  138. execute make -j 4
  139. execute make install
  140. build_done "libvpx"
  141. fi
  142.  
  143. if build "lame"; then
  144. download "http://kent.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz" "lame-3.99.5.tar.gz"
  145. cd $PACKAGES/lame-3.99.5
  146. execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
  147. execute make -j 4
  148. execute make install
  149. build_done "lame"
  150. fi
  151.  
  152. if build "xvidcore"; then
  153. download "http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz" "xvidcore-1.3.3.tar.gz"
  154. cd $PACKAGES/xvidcore
  155. cd build/generic
  156. execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
  157. execute make -j 4
  158. execute make install
  159.  
  160. if [ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]; then
  161. execute rm ${WORKSPACE}/lib/libxvidcore.4.dylib
  162. fi
  163.  
  164. build_done "xvidcore"
  165. fi
  166.  
  167.  
  168. if build "x264"; then
  169. # download "ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2" "last_x264.tar.bz2" if firewall allows ftp
  170. download "http://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2" "last_x264.tar.bz2"
  171. cd $PACKAGES/x264-snapshot-*
  172. execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
  173. execute make -j 4
  174. execute make install
  175. execute make install-lib-static
  176. build_done "x264"
  177. fi
  178.  
  179. if build "libogg"; then
  180. download "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz" "libogg-1.3.2.tar.gz"
  181. cd $PACKAGES/libogg-1.3.2
  182. execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
  183. execute make -j 4
  184. execute make install
  185. build_done "libogg"
  186. fi
  187.  
  188.  
  189. if build "libvorbis"; then
  190. download "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz" "libvorbis-1.3.4.tar.gz"
  191. cd $PACKAGES/libvorbis-1.3.4
  192. execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest
  193. execute make -j 4
  194. execute make install
  195. build_done "libvorbis"
  196. fi
  197.  
  198. if build "libtheora"; then
  199. download "http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz" "libtheora-1.1.1.tar.bz"
  200. cd $PACKAGES/libtheora-1.1.1
  201. sed "s/-fforce-addr//g" configure > configure.patched
  202. chmod +x configure.patched
  203. mv configure.patched configure
  204. 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
  205. execute make -j 4
  206. execute make install
  207. build_done "libtheora"
  208. fi
  209.  
  210. if build "pkg-config"; then
  211. download "http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz" "pkg-config-0.28.tar.gz"
  212. cd $PACKAGES/pkg-config-0.28
  213. execute ./configure --silent --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --with-internal-glib
  214. execute make -j 4
  215. execute make install
  216. build_done "pkg-config"
  217. fi
  218.  
  219.  
  220. if build "freetype"; then
  221. download "http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2" "freetype-2.4.0.tar.bz2"
  222. cd $PACKAGES/freet*
  223. execute ./configure --silent --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --disable-shared --enable-static
  224. execute make -j 4
  225. execute make install
  226. build_done "freetype"
  227. fi
  228.  
  229.  
  230.  
  231. if build "libxml2"; then
  232. download "ftp://xmlsoft.org/libxml2/libxml2-sources-2.9.2.tar.gz" "libxml2-sources-2.9.2.tar.gz"
  233. cd $PACKAGES/libxm*
  234. execute ./configure --prefix=${WORKSPACE} --enable-shared=yes --enable-static=yes --with-python=NO --with-python-install-dir=${WORKSPACE}/libxmlpython
  235. execute make -j 4
  236. execute make install
  237. build_done "libxml2"
  238. fi
  239.  
  240. if build "fontconfig"; then
  241. download "http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.94.tar.gz" "fontconfig-2.11.94.tar.gz"
  242. cd $PACKAGES/fontc*
  243.  
  244. execute ./configure --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --enable-shared=no --enable-static=yes --enable-libxml2
  245. execute make -j 4
  246. execute make install
  247. build_done "fontconfig"
  248. fi
  249.  
  250.  
  251. if build "cmake"; then
  252. download "http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz" "cmake-3.0.2.tar.gz"
  253. cd $PACKAGES/cmake*
  254. rm Modules/FindJava.cmake
  255. perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
  256. perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
  257. execute ./configure --prefix=${WORKSPACE}
  258. execute make -j 4
  259. execute make install
  260. build_done "cmake"
  261. fi
  262.  
  263. if build "vid_stab"; then
  264. 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"
  265. cd $PACKAGES/georgmartius-vid*
  266. perl -p -i -e "s/vidstab SHARED/vidstab STATIC/" CMakeLists.txt
  267. execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
  268. execute make -s install
  269. build_done "vid_stab"
  270. fi
  271.  
  272. if build "x265"; then
  273. download "https://bitbucket.org/multicoreware/x265/downloads/x265_1.7.tar.gz" "x265-1.7.tar.gz"
  274. cd $PACKAGES/x265_1.7
  275. cd source
  276. execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
  277. execute make -j 4
  278. execute make install
  279. sed "s/-lx265/-lx265 -lstdc++/g" "$WORKSPACE/lib/pkgconfig/x265.pc" > "$WORKSPACE/lib/pkgconfig/x265.pc.tmp"
  280. mv "$WORKSPACE/lib/pkgconfig/x265.pc.tmp" "$WORKSPACE/lib/pkgconfig/x265.pc"
  281. build_done "x265"
  282. fi
  283.  
  284. if build "fdk_aac"; then
  285. # download "http://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.3.tar.gz" "fdk-aac-0.1.3.tar.gz"
  286. 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"
  287.  
  288. cd $PACKAGES/fdk-aac*
  289. execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
  290. execute make -j 4
  291. execute make install
  292. build_done "fdk_aac"
  293. fi
  294.  
  295. if build "frei0r"; then
  296. download "https://files.dyne.org/frei0r/snapshots/frei0r-snapshot-27-01-15.tar.gz" "frei0r-snapshot-27-01-15.tar.gz"
  297.  
  298. cd $PACKAGES/frei0r*
  299. perl -p -i -e "s/OpenCV\" OFF/OpenCV\" ON/" CMakeLists.txt
  300. execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
  301. #execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
  302. execute make -s install
  303. for file in ${WORKSPACE}/lib/frei0r-1/*.so ; do
  304. cp $file "${file%.*}.dylib"
  305. done
  306. build_done "frei0r"
  307. fi
  308.  
  309. build "ffmpeg"
  310. download "http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 " "ffmpeg-snapshot.tar.bz2 "
  311. cd $PACKAGES/ffmpeg*
  312. CFLAGS="-I$WORKSPACE/include" LDFLAGS="-L$WORKSPACE/lib"
  313. echo "pkgconfig is `which pkg-config` and fontconfig lib is `pkg-config fontconfig --libs`"
  314. 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
  315. # ./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
  316. execute make -j 4
  317. execute make install
  318.  
  319. echo ""
  320. echo "Building done. The binary can be found here: $WORKSPACE/bin/ffmpeg"
  321. echo ""
  322. read -r -p "Install the binary to your /usr/local/bin/ folder? [Y/n] " response
  323.  
  324. case $response in
  325. [yY][eE][sS]|[yY])
  326. sudo cp "$WORKSPACE/bin/ffmpeg" "/usr/local/bin/ffmpeg"
  327. sudo cp "$WORKSPACE/bin/ffprobe" "/usr/local/bin/ffprobe"
  328. echo "Done. ffmpeg is now installed to your system"
  329. ;;
  330. esac
  331.  
  332. echo ""
  333. echo "The frei0r plugins can be found here: $WORKSPACE/lib/ in a folder named \"frei0r-1\""
  334. echo ""
  335. read -r -p "Copy frei0r plugins to your /usr/local/lib/frei0r-1 folder [Y/n] " response
  336.  
  337. case $response in
  338. [yY][eE][sS]|[yY])
  339. sudo cp -Rv "$WORKSPACE/lib/frei0r-1" "/usr/local/lib/"
  340. echo "Done. frei0r plugins are now installed to your system"
  341. ;;
  342. esac
Advertisement
Add Comment
Please, Sign In to add comment