Advertisement
Guest User

Opencv3 deps(in progress)

a guest
Oct 5th, 2017
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 14.60 KB | None | 0 0
  1. mydir="$HOME/LFS"
  2. mycores="-j4"
  3. set -euf -o pipefail #sipb.mit.ede safe scripting tutorial
  4.  
  5. #pyside , spyder
  6. #  https://github.com/baoboa/pyqt5
  7. function installThese
  8. {
  9. echo "http://www.portaudio.com/usinggit.html"
  10. git clone git@git.assembla.com:portaudio.git
  11. tar -nc http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz
  12. # https://github.com/jleb/pyaudio #bindings for port audio.
  13.  
  14. }
  15.  
  16.  
  17.  
  18. function aptDependiesUbuntu
  19. {
  20. sudo apt install -y libfreetype6-dev libgtk2.0-dev libgtk-3-dev libv4l-dev gfortran libeigen3-dev
  21. #  libhdf5-dev
  22. # libv4l-dev is the v4l video 4 linux project.
  23. #http://www.linuxfromscratch.org/blfs/view/svn/general/freetype2.html
  24. #wget -nc https://downloads.sourceforge.net/freetype/freetype-2.8.1.tar.bz2 # source installno works.
  25. }
  26.  
  27. function qt5build {
  28. echo "linuxfromscratch build instructions"
  29. cd "$mydir"
  30.  
  31. export QT5PREFIX=/opt/qt5
  32. wget -nc https://download.qt.io/archive/qt/5.9/5.9.1/single/qt-everywhere-opensource-src-5.9.1.tar.xz
  33. if ! [ -d "$mydir/qt-everywhere-opensource-src-5.9.1" ];then
  34.   tar -xJfv qt-everywhere-opensource-src-5.9.1.tar.xz
  35. fi
  36. cd qt-everywhere-opensource-src-5.9.1
  37. export QT5PREFIX=/opt/qt5
  38. mkdir  /opt/qt-5.9.1
  39. ln -sfnv qt-5.9.1 /opt/qt5
  40. #echo "INCLUDEPATH += /usr/include/openssl-1.0" >> qtbase/src/network/network.pro
  41. #export OPENSSL_LIBS='-L/usr/lib/openssl-1.0 -lssl -lcrypto'
  42. #comment
  43. #cd "$mydir/qt-everywhere-opensource-src-5.9.1"
  44. #./configure -prefix $QT5PREFIX                          \
  45. #            -sysconfdir /etc/xdg                        \
  46. #            -confirm-license                            \
  47. #            -opensource                                 \
  48. #            -dbus-linked                                \
  49. #            -openssl-linked                             \
  50. #            -system-harfbuzz                            \
  51. #            -system-sqlite                              \
  52. #            -nomake examples                            \
  53. #            -no-rpath                                   \
  54. #            -skip qtwebengine
  55. ## stripped out ssl stuff , no need for this.
  56. ./configure -prefix $QT5PREFIX                          \
  57.             -sysconfdir /etc/xdg                        \
  58.             -confirm-license                            \
  59.             -opensource                                 \
  60.             -dbus-linked                                \
  61.             -no-openssl                                 \
  62.             -system-harfbuzz                            \
  63.             -system-sqlite                              \
  64.             -nomake examples                            \
  65.             -no-rpath                                   \
  66.             -skip qtwebengine
  67. make "$mycores" && sudo make install
  68. # sudo find $QT5PREFIX/ -name \*.prl \
  69. #   -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
  70. # exit 1
  71.  
  72. for file in moc uic rcc qmake lconvert lrelease lupdate; do
  73.   ln -sfrvn $QT5BINDIR/$file /usr/bin/$file-qt5
  74. done
  75. cat >> /etc/ld.so.conf << EOF
  76. # Begin Qt addition
  77. /opt/qt5/lib
  78. # End Qt addition
  79. EOF
  80. sudo ldconfig
  81.  
  82. cat > /etc/profile.d/qt5.sh << "EOF"
  83. # Begin /etc/profile.d/qt5.sh
  84. echo "FIX THIS qt5" #with
  85. #http://www.linuxfromscratch.org/blfs/view/svn/postlfs/profile.html  pathappend funtion
  86. # stored in some startup folder. Not native to linux, lfs custom function.
  87. exit 1
  88. QT5DIR=/opt/qt5
  89. pathappend $QT5DIR/bin           PATH
  90. pathappend $QT5DIR/lib/pkgconfig PKG_CONFIG_PATH
  91. export QT5DIR
  92. # End /etc/profile.d/qt5.sh
  93. EOF
  94. }
  95.  
  96. function build_nasm
  97. {
  98.     cd "$mydir"
  99.     wget -nc http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.tar.bz2
  100.     if ! [ -d "$mydir/nasm-2.13.01" ]; then
  101.       tar xjvf nasm-2.13.01.tar.bz2
  102.     fi
  103.     cd nasm-2.13.01
  104.     ./configure
  105.     make "$mycores"
  106.     sudo make install
  107. }
  108. function build_yasm
  109. {
  110.     cd "$mydir"
  111.     wget -nc http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
  112.     if ! [ -d "$mydir/yasm-1.3.0" ]; then
  113.       echo "yasm no exist"
  114.       tar xzvf yasm-1.3.0.tar.gz
  115.     fi
  116.     cd yasm-1.3.0
  117.     ./configure
  118.     make "$mycores"
  119.     sudo make install
  120. }
  121.  
  122. function build_lame
  123. {
  124.     cd "$mydir"
  125.     wget -nc http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.tar.gz
  126.     if ! [ -d "$mydir/lame-3.99" ]; then
  127.       echo "lame direct not exist"
  128.       tar xzvf lame-3.99.tar.gz
  129.     fi
  130.     cd lame-3.99
  131.     ./configure --enable-nasm --disable-shared
  132.     make "$mycores"
  133.     sudo make install
  134. }
  135. #trap build_lame EXIT
  136.  
  137. #################### FFMPEG ################
  138. # sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \
  139. #  libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
  140. #  libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev
  141. function build_ffmpeg
  142. {
  143. # --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no] https://github.com/mstorsjo/fdk-aac
  144. #  faad2 and faac are compiled for libfdk-aac?
  145. #  --enable-libopenh264     enable H.264 encoding via OpenH264 [no]
  146. #  --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
  147. #  --enable-libx264         enable H.264 encoding via x264 [no]
  148. #  --enable-libx265         enable HEVC encoding via x265 [no]
  149.     cd "$mydir"
  150.     if ! [ -d "$mydir/ffmpeg" ]; then
  151.        git clone git://source.ffmpeg.org/ffmpeg.git
  152.        cd ffmpeg
  153.     else
  154.        cd ffmpeg
  155.        git pull
  156.     fi
  157. #     https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=53936
  158. #     https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
  159. #    ./configure --enable-shared --enable-gpl --prefix=/usr/local --enable-nonfree \
  160. #                --enable-libmp3lame --enable-libfaac --enable-libx264 \
  161. #                --enable-version3 --disable-mmx
  162.  
  163.     ./configure --enable-shared --enable-gpl --enable-nonfree  --enable-libfdk-aac \
  164.                 --enable-libmp3lame --enable-libx264  --enable-libass \
  165.                 --enable-version3
  166.     make "$mycores" &&  sudo make install
  167. }
  168. #trap build_ffmpeg EXIT
  169. ################################################
  170.  
  171. ##################
  172. ### LIBTIFF ######
  173. ##################
  174. function mylibtiff11
  175. {
  176. echo "tiff build"
  177. cd "$mydir"  #home/lfs
  178. if [ -d "$mydir/libtiff" ]; then
  179.   pushd libtiff && pwd
  180.   echo "pulling git libtiff"
  181.   git pull  # get latest code updat
  182. else
  183.   cd "$mydir"
  184.   git clone https://github.com/vadz/libtiff.git
  185.   pushd libtiff
  186. fi
  187. ./autogen.sh
  188. ./configure --prefix=/usr/local --disable-static
  189. make && sudo make install
  190. pwd
  191. }
  192. #trap mylibtiff11 EXIT
  193.  
  194. #################
  195. #####  libpng ###
  196. #################
  197. function mylibpng11
  198. {
  199. echo "png build"
  200. cd "$mydir"  #home/lfs
  201. if [ -d "$mydir/libpng" ]; then
  202.   pushd libpng
  203.   echo "pulling git png"
  204.   git pull  # get latest code updat
  205. else
  206.   git clone https://github.com/glennrp/libpng.git
  207.   pushd libpng
  208. fi
  209. #./autogen.sh
  210. ./configure --prefix=/usr/local --disable-static
  211. make && sudo make install
  212. }
  213. #trap mylibpng11 EXIT  #http://redsymbol.net/articles/bash-exit-traps/
  214.  
  215. ############################
  216. ############  libjpeg ######
  217. ############################
  218. function mylibjpeg11
  219. {
  220. echo "jpeg build"
  221. cd "$mydir"
  222. # http://www.linuxfromscratch.org/blfs/view/cvs/general/libjpeg.html
  223. wget -nc https://downloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-1.5.2.tar.gz
  224. if ! [ -d "$mydir/libjpeg-turbo-1.5.2" ]; then
  225.   tar zxvf libjpeg-turbo-1.5.2.tar.gz
  226. fi
  227. pushd libjpeg-turbo-1.5.2
  228. #sudo rm -rf /usr/lib/libjpeg.so*
  229. # opencv need jpeg8
  230. ./configure --prefix=/usr           \
  231.             --mandir=/usr/share/man \
  232.             --with-jpeg8            \
  233.             --disable-static        \
  234.             --docdir=/usr/share/doc/libjpeg-turbo-1.5.2
  235. make
  236. sudo make install
  237. }
  238. #trap mylibjpeg11 EXIT
  239.  
  240. ###########################################
  241. ############## JASPER #####################
  242. function myjasper1
  243. {
  244. echo "jasper build"
  245. cd "$mydir"  #home/lfs
  246. if [ -d "$mydir/jasper" ]; then
  247.   cd "$mydir/jasper"
  248.   echo "pulling git jasper"
  249.   git pull  # get latest code updat
  250. else
  251.  git clone https://github.com/mdadams/jasper.git
  252. fi
  253. SOURCE_DIR="$mydir/jasper"
  254. BUILD_DIR="$mydir/jasper/build1"
  255. INSTALL_DIR="/usr/local"
  256. rm -rf "$BUILD_DIR"
  257. mkdir -p "$BUILD_DIR"
  258. pushd "$BUILD_DIR"
  259. cmake -G "Unix Makefiles" -H"$SOURCE_DIR" -B"$BUILD_DIR" \
  260.                           -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR"
  261. make clean install
  262. make test
  263. sudo make install
  264. popd
  265. rm -rf "$BUILD_DIR"
  266. }
  267. #trap myjasper1 EXIT
  268. ##########################################
  269.  
  270.  
  271. ######################## FFMPEG DEPENDENCIES #########################
  272. function build_h264
  273. {
  274. echo "build h264"
  275.     # h.264 video encoder
  276.     cd "$mydir"
  277.     if ! [ -d "$mydir/x264" ]; then
  278.       git clone git://git.videolan.org/x264
  279.       cd x264
  280.     else
  281.       cd x264
  282.       git pull
  283.     fi
  284.     ./configure  --enable-shared
  285.     make
  286.     sudo make install
  287. }
  288. #trap build_h264 EXIT
  289.  
  290. function build_faac
  291. {
  292.     echo "build faac"
  293.     # https://github.com/knik0/faad2  mirror of sourceforge , https://github.com/knik0/faac
  294.     # aac encoder
  295.     cd "$mydir"
  296.     #    curl -#LO http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
  297.     if ! [ -d "$mydir/faac" ]; then
  298.       git clone https://github.com/knik0/faac.git
  299.       cd faac
  300.     else
  301.       cd faac
  302.       git pull
  303.     fi
  304.     ./configure
  305.     make
  306.     make install
  307. }
  308. #trap build_faac EXIT
  309.  
  310. function build_faad
  311. {
  312.     echo "build faad"
  313.     # https://github.com/knik0/faad2
  314.     cd "$mydir"
  315.     if ! [ -d "$mydir/faad2" ]; then
  316.       git clone https://github.com/knik0/faad2.git
  317.       cd faad2
  318.     else
  319.       cd faad2
  320.       git pull
  321.     fi
  322.     ./bootstrap
  323.     ./configure
  324.     make "$mycores"
  325.     sudo make install
  326. }
  327.  
  328.  
  329. function build_fribidi
  330. {
  331. echo "build fribidi"
  332.     cd "$mydir"
  333.     if ! [ -d "$mydir/fribidi" ]; then
  334.        git clone https://github.com/behdad/fribidi.git
  335.        cd fribidi
  336.     else
  337.        cd fribidi
  338.        git pull
  339.     fi
  340.     ./bootstrap
  341.     ./configure
  342.     make && sudo make install
  343. }
  344. #trap build_fribidi EXIT
  345.  
  346.  
  347. function build_libass
  348. {
  349.     cd "$mydir"
  350.     if ! [ -d "$mydir/libass" ]; then
  351.        git clone https://github.com/libass/libass.git
  352.        cd libass
  353.     else
  354.        cd libass
  355.        git pull
  356.     fi
  357.     ./configure
  358.     make && sudo make install
  359. }
  360. #trap build_libass EXIT
  361.  
  362. function build_fdkaac
  363. {
  364.     cd "$mydir"
  365.     if ! [ -d "$mydir/fdk-aac" ]; then
  366.        git clone https://github.com/mstorsjo/fdk-aac.git
  367.        cd fdk-aac
  368.     else
  369.        cd fdk-aac
  370.        git pull
  371.     fi
  372.     ./autogen.sh
  373.     ./configure
  374.     make "$mycores"  && sudo make install
  375. }
  376. #trap build_libass EXIT
  377.  
  378.  
  379. function build_libva
  380. {
  381. #https://01.org/linuxmedia
  382.     cd "$mydir"
  383.     if ! [ -d "$mydir/libva" ]; then
  384.        git clone https://github.com/01org/libva.git
  385.        cd libva
  386.     else
  387.        cd libva
  388.        git pull
  389.     fi
  390.     ./autogen.sh
  391. :q    ./configure
  392.     make "$mycores"  && sudo make install
  393. }
  394.  
  395. function build_LIBAV
  396. {
  397. #  https://github.com/libav/libav  ,   https://www.libav.org/
  398. #  ubuntu packages   libavcodec-dev libavformat-dev
  399. #  libswscale-dev   part of ffmpeg install.
  400.    cd "$mydir"
  401.     if ! [ -d "$mydir/libav" ]; then
  402.        git clone https://github.com/libav/libav.git
  403.        cd libav
  404.     else
  405.        cd libav
  406.        git pull
  407.     fi
  408.     ./configure
  409.     make "$mycores"  && sudo make install
  410. }
  411.  
  412.  
  413. function build_libsdl2
  414. {
  415. # https://github.com/soulik/libsdl2  ,  http://www.libsdl.org/
  416. cd "$mydir"
  417. wget -nc http://www.libsdl.org/release/SDL2-2.0.6.tar.gz
  418. if ! [ -d "$mydir/SDL2-2.0.6" ]; then
  419.   tar zxvf SDL2-2.0.6.tar.gz
  420. fi
  421. cd SDL2-2.0.6
  422. ./autogen.sh
  423. ./configure
  424. make "$mycores"
  425. sudo make install
  426. }
  427.  
  428.  
  429. function xvid
  430. {
  431. # libxvidcore-dev libxvidcore4
  432. # http://www.linuxfromscratch.org/blfs/view/svn/multimedia/xvid.html
  433. # https://github.com/soulik/libsdl2  ,  http://www.libsdl.org/
  434. cd "$mydir"
  435. wget -nc http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz
  436. if ! [ -d "$mydir/xvidcore" ]; then
  437.   tar zxvf xvidcore-1.3.4.tar.gz
  438. fi
  439. cd xvidcore; cd build; cd generic
  440. ./bootstrap.sh
  441. ./configure && make "$mycores" && sudo make install
  442. }
  443.  
  444. function dymmyfunction
  445. {
  446. echo "bug workaround"
  447. }
  448.  
  449. function build_texinfo6
  450. {
  451. cd "$mydir"
  452. wget -nc ftp://ftp.gnu.org/gnu/texinfo/texinfo-6.5.tar.gz
  453. if -! [ -d "$mydir/texinfo-6.5" ]; then
  454.   tar zxvf texinfo-6.5.tar.gz
  455. fi
  456. cd texinfo-6.5
  457. ./configure
  458. make "$mycores" && sudo make install
  459. }
  460.  
  461.  
  462. add2path() {
  463.   #opt/qt5
  464.   if ! echo "$PATH" | PATH=$(getconf PATH) grep -Eq '(^|:)'"${1:?missing argument}"'(:|\$)' ; then # Use the POSIX grep implementation
  465.     if [ -d "$1" ]; then # Don't add a non existing directory to the PATH
  466.       if [ "$2" = front ]; then # Use a standard shell test
  467.         PATH="$1:$PATH"
  468.       else
  469.         PATH="$PATH:$1"
  470.       fi
  471.       echo PATH
  472.       #export PATH
  473.     fi
  474.   fi
  475. }
  476.  
  477. addthepath() {
  478.   #echo "into addpath"
  479.   if ! echo $PATH | egrep "(^|:)$1(:|\$)" > /dev/null ; then
  480.   #if ! echo $PATH  | egrep "(^|:)$1(:|\$)" ; then
  481.     if [[ $2 = "front" ]]; then
  482.       #echo "yy"
  483.       PATH="$1:$PATH"
  484.     else
  485.       #echo "lll"
  486.       PATH="$PATH:$1"
  487.     #  echo $thepath
  488.     fi
  489.     echo PATH
  490.     export PATH
  491.   else
  492.      echo "direct already in path"
  493.   fi
  494. }
  495.  
  496.  
  497. testme() {
  498. # echo $PATH  | egrep "(^|:)$1(:|\$)"
  499. echo $PATH | egrep "$1"
  500. }
  501.  
  502. buildlibevent() {
  503. # http://libevent.org/
  504. cd $mydir
  505. if ! [ -d "$mydir/libevent" ]; then
  506.    git clone https://github.com/libevent/libevent.git
  507.    pushd libevent
  508. else
  509.  pushd libevent
  510.  git pull
  511. fi
  512. ./autogen.sh && ./configure && make "$mycores" && make install
  513. }
  514.  
  515. buildtmux() {
  516.   # buildlibevent is a dependency.
  517.   cd $mydir
  518.   if ! [ -d "$mydir/tmux" ]; then
  519.    git clone https://github.com/tmux/tmux.git
  520.    pushd tmux
  521.   else
  522.    pushd tmux
  523.    git pull
  524.   fi
  525.   ./autogen.sh && ./configure && make "$mycores" && make install
  526. }
  527.  
  528. # https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
  529. echo "Run script as sudo bash opencv3.sh "
  530. mkdir -p "$mydir" >/dev/null 2>&1
  531. #aptDependiesUbuntu  #freetype , cannot get installed from source.
  532. #buildlibevent; buildtmux
  533. #add2path opt/qt5 back
  534. #addthepath /opt/qt5/bin back
  535. #testme bin
  536. ### uncomment all below for ffmpeg install.
  537. #build_texinfo6
  538. #build_yasm
  539. #build_nasm
  540. #build_lame
  541. #build_fribidi
  542. #build_libass   # --enable-libass  option manually set in ffmpeg, subtitle rendering
  543. #build_fdkaac  #fraunhover aac , android --enable-libfdk-aac , set manually in ffmpeg
  544. #build_faad
  545. #build_libva
  546. #build_libsdl2  #--enable option to select??
  547. #myjasper1
  548. #mylibjpeg11
  549. #build_faac
  550. #build_h264  #asm enabled , else mpeg4 conversion slow
  551. #mylibpng11
  552. #mylibtiff11
  553. #xvid       # source install for package libxvidcore-dev
  554. #build_LIBAV
  555. #build_ffmpeg   #19 packages so far.
  556. #qt5build
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement