Advertisement
Guest User

build_gnuradio for Odroid U3

a guest
Sep 13th, 2014
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 38.20 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Build script for UHD+GnuRadio on Fedora and Ubuntu
  4. #
  5. #
  6. #
  7. # Updates: https://github.com/guruofquality/grextras/wiki
  8. # Updates: https://github.com/balint256/gr-baz.git
  9. #
  10. #
  11. #
  12. # Exit function--Id like to be able to upload stats to a website somewhere...
  13. #
  14. function doexit
  15. {
  16.     cat <<"!EOF!"
  17.  
  18. =======================================================================
  19. If you have found this script useful and time-saving, consider a
  20. donation to help me keep build-gnuradio, simple_ra, SIDsuite,
  21. meteor_detector, simple_fm_rcv, and multimode maintained and up to date.
  22. A simple paypal transfer to mleech@ripnet.com is all you need to do.
  23. ======================================================================
  24. !EOF!
  25.  
  26.     echo -n "Send success/fail info to sbrac.org?"
  27.     read ans
  28.         case $ans in
  29.             y|Y|YES|yes|Yes)
  30.                 wget http://www.sbrac.org/bgrstats.php?status="$1"?systype=${SYSTYPE}?sysinfo="`uname -a`" >/dev/null 2>&1
  31.                 echo Thanks
  32.                 ;;
  33.         esac
  34.     exit
  35. }
  36.    
  37. function help {
  38.     cat <<!EOF!
  39.    
  40. Usage: build-gnuradio [--help|-h] [-v|--verbose] [-jN] [-ja]
  41.                       [-l|--logfile logfile ] [-u|--users ulist] [-m] funcs
  42.  
  43. -m             - Use HEAD of master branch, rather than 3.7.1.  Use compatible extras as well
  44. -o             - User v3.6.5.1 and compatible extras.
  45.  
  46. -v|--verbose   - turn on verbose logging to stdout
  47.  
  48. -jN            - have make use N concurrent jobs
  49.  
  50. -ja            - have make use N concurrent jobs with auto setting of N
  51.                  (based on number of cpu cores on build system)
  52.                  
  53. -josh          - use Josh Blums enhanced Gnu Radio GIT repo
  54.  
  55. -u|--users ul  - add comma-separated users to 'usrp' group in addition
  56.                  to calling user ( $USER )
  57.                  
  58.                
  59. -l|--logfile lf - log messages to 'lf'
  60. -ut <tag>       - set tag for UHD checkout to <tag>
  61. -gt <tag>       - set tag for Gnu Radio checkout to <tag>
  62. -e|--extras     - add an item to "extras" to be built after Gnu Radio/UHD/gs-osmosdr
  63. available funcs are:
  64.  
  65. all             - do all functions
  66. prereqs         - install prerequisites
  67. gitfetch        - use GIT to fetch Gnu Radio and UHD
  68. uhd_build       - build only UHD
  69. firmware        - fetch firmware/FPGA
  70. gnuradio_build  - build only Gnu Radio
  71. mod_groups      - modify the /etc/groups and add user to group 'usrp'
  72. mod_udev        - add UDEV rule for USRP1
  73. mod_sysctl      - modify SYSCTL for larger net buffers
  74. !EOF!
  75.  
  76. }
  77.  
  78. if [ $USER = root -o $UID -eq 0 ]
  79. then
  80.     echo Please run this script as an ordinary user
  81.     echo   it will acquire root privileges as it needs them via \"sudo\".
  82.     exit
  83. fi
  84.  
  85. VERBOSE=No
  86. JFLAG=""
  87. LOGDEV=/dev/null
  88. USERSLIST=None
  89. JOSHMODE=False
  90. UTAG=None
  91. GTAG=None
  92. export LC_LANG=C
  93. EXTRAS=""
  94. MASTER_MODE=0
  95. OLD_MODE=0
  96. TEST=-DCMAKE_CXX_FLAGS:STRING="-march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard"
  97. TEST2=-DCMAKE_C_FLAGS:STRING="-march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard"
  98. PULLED_LIST="gnuradio uhd rtl-sdr gr-osmosdr gr-iqbal hackrf gr-baz bladeRF"
  99. which python3 >/dev/null 2>&1
  100. if [ $? -eq 0 ]
  101. then
  102.             CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  103.             CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  104. fi
  105. while :
  106. do
  107.     case $1 in
  108.         -ja)
  109.             cnt=`grep 'processor.*:' /proc/cpuinfo|wc -l`
  110.             cnt=`expr $cnt - 1`
  111.             if [ $cnt -lt 1 ]
  112.             then
  113.                 cnt=1
  114.             fi
  115.             JFLAG=-j$cnt
  116.             shift
  117.             ;;
  118.            
  119.         -j[123456789])
  120.             JFLAG=$1
  121.             shift
  122.             ;;
  123.  
  124.         -josh)
  125.             JOSHMODE=True
  126.             shift
  127.             ;;
  128.            
  129.         -v|--verbose)
  130.             LOGDEV=/dev/stdout
  131.             shift
  132.             ;;
  133.            
  134.         -l|--logfile)
  135.             case $2 in
  136.                 /*)
  137.                     LOGDEV=$2
  138.                 ;;
  139.                 *)
  140.                     LOGDEV=`pwd`/$2
  141.                 ;;
  142.             esac
  143.             shift
  144.             shift
  145.             rm -f $LOGDEV
  146.             echo $LOGDEV Starts at: `date` >>$LOGDEV 2>&1
  147.             ;;
  148.            
  149.         -u|--users)
  150.             USERSLIST=$2
  151.             shift
  152.             shift
  153.             ;;
  154.        
  155.         -m|--master)
  156.             MASTER_MODE=1
  157.             shift
  158.             ;;
  159.  
  160.         -o|--old)
  161.             OLD_MODE=1
  162.             shift
  163.             ;;
  164.            
  165.         -h|--help)
  166.             help
  167.             exit
  168.             ;;
  169.            
  170.         -ut)
  171.             UTAG=$2
  172.             shift
  173.             shift
  174.             ;;
  175.            
  176.         -gt)
  177.             GTAG=$2
  178.             shift
  179.             shift
  180.             ;;
  181.            
  182.         -e|--extras)
  183.             EXTRAS=$EXTRAS" "$2
  184.             shift 2
  185.             ;;
  186.            
  187.         -*)
  188.             echo Unrecognized option: $1
  189.             echo
  190.             help
  191.             exit
  192.             break
  193.             ;;
  194.         *)
  195.             break
  196.             ;;
  197.     esac
  198. done
  199.  
  200. CWD=`pwd`
  201. SUDOASKED=n
  202. SYSTYPE=unknown
  203. good_to_go=no
  204. for file in /etc/fedora-release /etc/linuxmint/info /etc/lsb-release /etc/debian_version /etc/redhat-release
  205. do
  206.     if [ -f $file ]
  207.     then
  208.         good_to_go=yes
  209.     fi
  210. done
  211. if [ $good_to_go = no ]
  212. then
  213.     echo Supported systems: Fedora, Ubuntu, Redhat, Debian, Mint, OpenSuse
  214.     echo You appear to be running none of the above, exiting
  215.     exit
  216. fi
  217.  
  218. echo This script will install Gnu Radio from current GIT sources
  219. echo You will require Internet access from the computer on which this
  220. echo script runs.  You will also require SUDO access.  You will require
  221. echo approximately 500MB of free disk space to perform the build.
  222. echo " "
  223. echo This script will, as a side-effect, remove any existing Gnu Radio
  224. echo installation that was installed from your Linux distribution packages.
  225. echo It must do this to prevent problems due to interference between
  226. echo a linux-distribution-installed Gnu Radio/UHD and one installed from GIT source.
  227. echo " "
  228. echo The whole process may take up to two hours to complete, depending on the
  229. echo capabilities of your system.
  230. echo
  231. echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  232. echo NOTE: if you run into problems while running this script, you can re-run it with
  233. echo the --verbose option to produce lots of diagnostic output to help debug problems.
  234. echo This script has been written to anticipate some of the more common problems one might
  235. echo encounter building ANY large, complex software package.  But it is not pefect, and
  236. echo there are certainly some situations it could encounter that it cannot deal with
  237. echo gracefully.  Altering the system configuration from something reasonably standard,
  238. echo removing parts of the filesystem, moving system libraries around arbitrarily, etc,
  239. echo it likely cannot cope with.  It is just a script.  It isn\'t intuitive or artificially
  240. echo intelligent.  It tries to make life a little easier for you, but at the end of the day
  241. echo if it runs into trouble, a certain amount of knowledge on your part about
  242. echo system configuration and idiosyncrasies will inevitably be necessary.
  243. echo
  244. echo
  245. echo -n Proceed?
  246.  
  247. read ans
  248. case $ans in
  249.     y|Y|YES|yes|Yes)
  250.         PROCEED=y
  251.     ;;
  252.     *)
  253.         exit
  254. esac
  255.  
  256. SPACE=`df $HOME| grep -v blocks|grep '%'`
  257. SPACE=`echo $SPACE | awk '/./ {n=NF-2; printf ("%d\n", $n/1.0e3)}'`
  258.  
  259.  
  260. if [ $SPACE -lt 500 ]
  261. then
  262.     echo "You don't appear to have enough free disk space on $HOME"
  263.     echo to complete this build/install
  264.     echo exiting
  265.     doexit DISKSPACE
  266. fi
  267.  
  268. total=0
  269. for file in $PULLED_LIST
  270. do
  271.     found=0
  272.     for instance in ${file}.20*
  273.     do
  274.         if [ -d $instance ]
  275.         then
  276.             found=1
  277.             sz=`du -s $instance|awk '{print $1}'`
  278.             total=`expr $total + $sz`
  279.         fi
  280.     done
  281. done
  282. total=`expr $total '*' 1024`
  283. total=`expr $total / 1000000`
  284. if [ $total -gt 100 ]
  285. then
  286.     echo Your old 'uhd.*' and 'gnuradio.*' etc directories are using roughly $total MB
  287.     echo of disk space:
  288.     for file in $PULLED_LIST
  289.     do
  290.         for instance in ${file}.20*
  291.         do
  292.             if [ -d $instance ]
  293.             then
  294.                 ls -ld $instance
  295.             fi
  296.         done
  297.     done
  298.     echo " "
  299.     echo -n Remove them'?'
  300.     read ans
  301.    
  302.     case $ans in
  303.         y|Y|YES|yes|Yes)
  304.             for file in $PULLED_LIST
  305.             do
  306.                 for instance in ${file}.20*
  307.                 do
  308.                     if [ -d $instance ]
  309.                     then
  310.                         echo removing ${instance}
  311.                         rm -rf ${instance}
  312.                     fi
  313.                 done
  314.             done
  315.             echo Done
  316.             ;;
  317.     esac
  318. fi
  319. rm -rf *.20*.bgmoved
  320.  
  321. function my_echo {
  322.     if [ $LOGDEV = /dev/stdout ]
  323.     then
  324.         echo $*
  325.     else
  326.         echo $*
  327.         echo $* >>$LOGDEV 2>&1
  328.     fi
  329. }
  330.  
  331. function checkcmd {
  332.     found=0
  333.     which $1 >/dev/null 2>&1
  334.     x=$?
  335.     if [ $x -eq 0 ]
  336.     then
  337.         found=1
  338.     fi
  339.     for place in /bin /usr/bin /usr/local/bin /sbin /usr/sbin /usr/local/sbin /opt/bin /opt/local/bin
  340.     do
  341.         if [ -e $place/$1 ]
  342.         then
  343.             found=1
  344.         fi
  345.     done
  346.     if [ $found -eq 0 ]
  347.     then
  348.         which $1 >/dev/null 2>&1
  349.         if [ $? -eq 0 ]
  350.         then
  351.             found=1
  352.         fi
  353.     fi
  354.     if [ $found -eq 0 ]
  355.     then
  356.         my_echo Failed to find just-installed command \'$1\' after pre-requisite installation.
  357.         my_echo This very likely indicates that the pre-requisite installation failed
  358.         my_echo to install one or more critical pre-requisites for Gnu Radio/UHD
  359.         doexit PREREQFAIL-CMD-$1
  360.     fi
  361. }
  362.  
  363. function checklib {
  364.     found=0
  365.     my_echo -n Checking for library $1 ...
  366.     for dir in /lib /usr/lib /usr/lib64 /lib64 /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu \
  367.         /usr/lib/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabi
  368.     do
  369.         for file in $dir/${1}*.so*
  370.         do
  371.             if [ -e "$file" ]
  372.             then
  373.                 found=1
  374.             fi
  375.         done
  376.     done
  377.     if [ $found -le 0 ]
  378.     then
  379.         my_echo Failed to find libraries with prefix \'$1\' after pre-requisite installation.
  380.         my_echo This very likely indicates that the pre-requisite installation failed
  381.         my_echo to install one or more critical pre-requisites for Gnu Radio/UHD
  382.         my_echo exiting build
  383.         doexit PREREQFAIL-LIB-$1
  384.     else
  385.         my_echo Found library $1
  386.     fi
  387. }
  388.  
  389. function checkpkg {
  390.     my_echo Checking for package $1
  391.     if [ `apt-cache search $1 | wc -l` -eq 0 ]
  392.     then
  393.         my_echo Failed to find package \'$1\' in known package repositories
  394.         my_echo Perhaps you need to add the Ubuntu universe or multiverse PPA?
  395.         my_echo see https://help.ubuntu.com/community/Repositories/Ubuntu
  396.         my_echo exiting build
  397.         doexit PREREQFAIL-PKG-$1
  398.     fi
  399. }
  400.        
  401. function prereqs {
  402.     sudocheck
  403.     my_echo Installing prerequisites.
  404.     my_echo "====>" THIS MAY TAKE QUITE SOME TIME "<====="
  405.     #
  406.     # It's a Fedora system
  407.     #
  408.     if [ -f /etc/fedora-release ]
  409.     then
  410.         SYSTYPE=Fedora
  411.         case `cat /etc/fedora-release` in
  412.         *12*|*13*|*14*|*15*|*16*|*17*|*18*)
  413.             sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1
  414.             sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1
  415.             sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1
  416.             sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" \
  417.                     "Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1
  418.             sudo yum -y install fftw-devel cppunit-devel wxPython-devel \
  419.               boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \
  420.               python-cheetah python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \
  421.               PyQt4-devel qwt-devel qwtplot3d-qt4-devel libusb-devel libusb \
  422.               libusb1 libusb1-devel cmake git wget python-docutils \
  423.               PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" tkinter orc \
  424.               orc-devel python-sphinx SDL-devel swig >>$LOGDEV 2>&1
  425.         ;;
  426.        
  427.         *19*|*20*)
  428.             sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1
  429.             sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1
  430.             sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1
  431.             sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" \
  432.                 "Software Development Tools" "C Development Tools and Libraries" >>$LOGDEV 2>&1
  433.             sudo yum -y install fftw-devel cppunit-devel wxPython-devel \
  434.               boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \
  435.               python-cheetah python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \
  436.               PyQt4-devel qwt-devel qwtplot3d-qt4-devel \
  437.               libusbx-devel cmake git wget python-docutils \
  438.               PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" tkinter orc \
  439.               orc-devel python-sphinx SDL-devel swig >>$LOGDEV 2>&1
  440.         ;;
  441.         *)
  442.             my_echo Only Fedora release 12 - 20 are supported by this script
  443.             doexit WRONGRELEASE
  444.             ;;
  445.         esac
  446.    
  447.     #
  448.     # It's a RedHat system
  449.     elif [ -f /etc/redhat-release ]
  450.     then
  451.         SYSTYPE=Redhat
  452.         case `cat /etc/redhat-release` in
  453.         *elease*6*)
  454.             sudo yum -y erase 'gnuradio*' >>$LOGDEV 2>&1
  455.             sudo yum -y erase 'libgruel-*' >>$LOGDEV 2>&1
  456.             sudo yum -y erase 'libgruel*' >>$LOGDEV 2>&1
  457.             sudo yum -y groupinstall "Engineering and Scientific" "Development Tools" >>$LOGDEV 2>&1
  458.             sudo yum -y install fftw-devel cppunit-devel wxPython-devel libusb-devel \
  459.               boost-devel alsa-lib-devel numpy gsl-devel python-devel pygsl \
  460.               python-cheetah python-lxml PyOpenGL qt-devel qt qt4 qt4-devel \
  461.               PyQt4-devel qwt-devel qwtplot3d-qt4-devel libusb libusb-devel \
  462.               libusb1 libusb1-devel cmake git wget python-docutils \
  463.               PyQwt PyQwt-devel qwt-devel gtk2-engines xmlrpc-c-"*" tkinter orc >>$LOGDEV 2>&1
  464.         ;;
  465.         *)
  466.             my_echo Your Redhat system release must be release 6 to proceed
  467.             doexit WRONGRELEASE
  468.             ;;
  469.         esac
  470.  
  471.     #
  472.     # It's a Mint system
  473.     #
  474.     elif [ -f /etc/linuxmint/info ]
  475.     then
  476.         SYSTYPE=Mint
  477.         sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  478.         sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  479.         sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  480.         sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  481.         sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  482.         sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  483.         case `grep RELEASE /etc/linuxmint/info` in
  484.         *11*|*12*|*13*|*14*|*15*)
  485.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  486.             automake autoconf libtool python-dev libfftw3-dev
  487.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  488.             libsdl1.2-dev python-wxgtk2.8 git-core
  489.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  490.             python-cheetah python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  491.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  492.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  493.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2"
  494.             ;;
  495.            
  496.         *)
  497.             my_echo Your Mint release must be at least Linux Mint 11 to proceed
  498.             doexit WRONGRELEASE
  499.             ;;
  500.         esac
  501.         for pkg in $PKGLIST; do checkpkg $pkg; done
  502.         sudo apt-get -y --ignore-missing install $PKGLIST >>$LOGDEV 2>&1
  503.  
  504.     #
  505.     # It's a Ubuntu system
  506.     #
  507.     elif [ -f /etc/lsb-release -a ! -f /etc/SuSE-release ]
  508.     then
  509.         SYSTYPE=Ubuntu
  510.         sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  511.         sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  512.         sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  513.         sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  514.         sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  515.         sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  516.         case `grep DISTRIB_RELEASE /etc/lsb-release` in
  517.         *13.*|*14.*)
  518.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  519.             automake autoconf libtool python-dev libfftw3-dev
  520.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  521.             libsdl1.2-dev python-wxgtk2.8 git-core
  522.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  523.             python-cheetah python-lxml doxygen qt4-default qt4-dev-tools libusb-1.0-0-dev
  524.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  525.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  526.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2"
  527.             CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  528.             CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  529.             ;;
  530.            
  531.         *11.*|*12.10*)
  532.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  533.             automake autoconf libtool python-dev libfftw3-dev
  534.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  535.             libsdl1.2-dev python-wxgtk2.8 git-core
  536.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  537.             python-cheetah python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  538.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  539.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  540.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2"
  541.             CMAKE_FLAG1=-DPythonLibs_FIND_VERSION:STRING="2.7"
  542.             CMAKE_FLAG2=-DPythonInterp_FIND_VERSION:STRING="2.7"
  543.             ;;
  544.        
  545.         *12.04*)
  546.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  547.             automake autoconf libtool python-dev libfftw3-dev
  548.             libcppunit-dev libboost1.48-all-dev libusb-dev libusb-1.0-0-dev fort77
  549.             libsdl1.2-dev python-wxgtk2.8 git-core
  550.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  551.             python-cheetah python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  552.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  553.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  554.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2"
  555.             ;;
  556.            
  557.         *10.04*|*10.10*)
  558.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  559.             automake autoconf libtool python-dev libfftw3-dev
  560.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  561.             libsdl1.2-dev python-wxgtk2.8 git-core
  562.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  563.             python-cheetah python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  564.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  565.             cmake git-core wget python-docutils gtk2-engines-pixbuf python-tk libasound2-dev python-gtk2"
  566.             ;;
  567.            
  568.         *9.10*)
  569.             PKGLIST="swig g++ automake autoconf libtool python-dev libfftw3-dev
  570.             libcppunit-dev libboost1.38-dev libusb-dev libusb-1.0-0-dev fort77
  571.             libsdl1.2-dev python-wxgtk2.8 git-core
  572.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  573.             python-cheetah python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  574.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools
  575.             cmake git wget python-docutils python-tk libasound2-dev"
  576.             ;;
  577.            
  578.         *9.04*)
  579.             sudo apt-get purge python-wxgtk2.6
  580.             PKGLIST="swig g++ automake1.9 autoconf libtool python-dev fftw3-dev
  581.             libcppunit-dev libboost1.35-dev libusb-dev libusb-1.0-0-dev
  582.             libsdl1.2-dev python-wxgtk2.8 git-core
  583.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  584.             python-cheetah python-lxml doxygen qt4-dev-tools
  585.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools
  586.             cmake git wget python-docutils python-tk libasound2-dev"
  587.             ;;
  588.            
  589.         *)
  590.             my_echo Your Ubuntu release must be at least 9.04 to proceed
  591.             doexit WRONGRELEASE
  592.             ;;
  593.         esac
  594.         for pkg in $PKGLIST; do checkpkg $pkg; done
  595.         my_echo Done checking packages
  596.         sudo apt-get -y --ignore-missing install $PKGLIST >>$LOGDEV 2>&1
  597.     #
  598.     # It's a Debian system
  599.     #
  600.     elif [ -f /etc/debian_version ]
  601.     then
  602.         SYSTYPE=Debian
  603.         sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
  604.         sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
  605.         sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
  606.         sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
  607.         sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
  608.         sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
  609.         case `cat /etc/debian_version` in
  610.         *6.0*|*wheezy*|*sid*|*7.1*|*7.0*|*7.2*|*7.3*|*7.4*)
  611.             PKGLIST="libfontconfig1-dev libxrender-dev libpulse-dev swig g++
  612.             automake autoconf libtool python-dev libfftw3-dev
  613.             libcppunit-dev libboost-all-dev libusb-dev libusb-1.0-0-dev fort77
  614.             libsdl1.2-dev python-wxgtk2.8 git-core
  615.             libqt4-dev python-numpy ccache python-opengl libgsl0-dev
  616.             python-cheetah python-lxml doxygen qt4-dev-tools libusb-1.0-0-dev
  617.             libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  618.             cmake git-core wget libxi-dev python-docutils gtk2-engines-pixbuf r-base-dev python-tk
  619.             liborc-0.4-0 liborc-0.4-dev libasound2-dev python-gtk2 libportaudio2 portaudio19-dev
  620.             ca-certificates"
  621.             ;;
  622.         *)
  623.             my_echo Unsupported Debian version `cat /etc/debian_version`
  624.             doexit WRONGRELEASE
  625.             ;;
  626.         esac
  627.         for pkg in $PKGLIST; do checkpkg $pkg; done
  628.         sudo apt-get -y --ignore-missing install $PKGLIST >>$LOGDEV 2>&1
  629.     elif [ -f /etc/SuSE-release ]
  630.     then
  631.         SYSTYPE=OpenSuSE
  632.         if grep -q 12.1 /etc/SuSE-release
  633.         then
  634.             cool=1
  635.         else
  636.             my_echo Only OpenSuSE 12.1 is supported by this script
  637.             doexit WRONGRELEASE
  638.         fi
  639.         sudo zypper install cmake cppunit-devel doxygen fftw3-devel \
  640.         git gsl-devel libjack-devel libqt4-devel libqwtplot3d-devel \
  641.         libSDL-devel libusb-1_0-devel orc portaudio portaudio-devel \
  642.         python-cheetah python-devel python-lxml python-wxGTK python-wxWidgets-devel \
  643.         qwt-devel wxWidgets-devel boost-devel xmlto texlive-latex >>$LOGDEV 2>&1
  644.        
  645.     else
  646.         my_echo This script supports only Ubuntu,Mint,Fedora, Debian and OpenSuse systems
  647.         my_echo Your Fedora system must be at least Fedora 12
  648.         my_echo Your Ubuntu system must be at least Ubuntu 9.04
  649.         my_echo Your Mint system must be at least Mint 11
  650.         my_echo Your Debian system must be release 6
  651.         doexit WRONGSYSTEM
  652.     fi
  653.     PATH=$PATH
  654.     export PATH
  655.  
  656.     checkcmd git
  657.     checkcmd cmake
  658.    
  659.     if [ $SYSTYPE = Fedora ]
  660.     then
  661.         checklib libusb-0 0
  662.         checklib libusb-1 0
  663.     else
  664.         checklib libusb 2
  665.     fi
  666.    
  667.     checklib libboost 5
  668.     checklib libcppunit 0
  669.     checklib libfftw 5
  670.     checklib libgsl 0
  671.    
  672.     my_echo Done
  673. }
  674.  
  675.  
  676. function gitfetch {
  677.     date=`date +%Y%m%d%H%M%S`
  678.     V=3.7/maint
  679.     if [ $MASTER_MODE -eq 1 ]
  680.     then
  681.         V=Master/HEAD
  682.     fi
  683.     if [ $OLD_MODE -eq 1 ]
  684.     then
  685.         V=3.6.5.1
  686.     fi
  687.     echo This script will fetch Gnu Radio version $V from the repositories, along with compatible
  688.     echo  extras.
  689.     echo -n Is this OK?
  690.     read ans
  691.    
  692.     case $ans in
  693.         Y|y|YES|yes|Yes)
  694.             ;;
  695.         *)
  696.             exit
  697.             ;;
  698.     esac
  699.        
  700.  
  701.     my_echo "Fetching various packages (Gnu Radio, UHD, gr-osmosdr, gr-iqbal, etc)"
  702.     my_echo "  via the Internet"
  703.     my_echo "=======> THIS MAY TAKE QUITE SOME TIME <========="
  704.  
  705.     cd $CWD
  706.     for dir in ${PULLED_LIST}
  707.     do
  708.         if [ -d $dir ]
  709.         then
  710.             mv $dir ${dir}.$date
  711.         fi
  712.     done
  713.    
  714.     #
  715.     # GIT the gnu radio source tree
  716.     #
  717.     my_echo -n Fetching Gnu Radio via GIT...
  718.     if [ $JOSHMODE = False ]
  719.     then
  720.         git clone --progress http://git.gnuradio.org/git/gnuradio.git >>$LOGDEV 2>&1
  721.         if [ ! -d gnuradio/gnuradio-core -a ! -d gnuradio/gnuradio-runtime ]
  722.         then
  723.             my_echo "Could not find gnuradio/gnuradio-{core,runtime} after GIT checkout"
  724.             my_echo GIT checkout of Gnu Radio failed!
  725.             doexit FETCH-GR-FAIL
  726.         fi
  727.         if [ $OLD_MODE -eq 1 ]
  728.         then
  729.             cd gnuradio
  730.             git checkout v3.6.5.1  >>$LOGDEV 2>&1
  731.             cd $CWD
  732.         elif [ $MASTER_MODE -eq 0 ]
  733.         then
  734.             cd gnuradio
  735.             git checkout maint >>$LOGDEV 2>&1
  736.             cd $CWD
  737.         fi
  738.        
  739.         if [ $GTAG != None ]
  740.         then
  741.             cd gnuradio
  742.             git checkout $GTAG >/dev/null 2>&1
  743.             git name-rev HEAD >tmp$$ 2>&1
  744.             if grep -q "HEAD tags/$GTAG" tmp$$
  745.             then
  746.                 whee=yes
  747.                 rm -f tmp$$
  748.             else
  749.                 my_echo Could not fetch Gnu Radio tagged $GTAG from GIT
  750.                 rm -f tmp$$
  751.                 doexit FETCH-GR-FAIL-$GTAG
  752.             fi
  753.             cd ..
  754.         fi
  755.     else
  756.         git clone --progress git://git.gnuradio.org/jblum.git >>$LOGDEV 2>&1
  757.         if [ $GTAG != "None" ]
  758.         then
  759.             git checkout $GTAG
  760.         else
  761.             git checkout next
  762.         fi
  763.         if [ ! -d jblum/gnuradio-core ]
  764.         then
  765.             my_echo GIT checkout of Gnu Radio from jblum.git failed!
  766.             doexit FETCH-GR-JOSH-FAIL
  767.         fi
  768.     fi
  769.     my_echo Done
  770.  
  771.     #
  772.     # GIT the UHD source tree
  773.     #
  774.     rm -rf uhd
  775.     my_echo -n Fetching UHD via GIT...
  776.     git clone --progress  https://github.com/EttusResearch/uhd >>$LOGDEV 2>&1
  777.  
  778.     if [ ! -d uhd/host ]
  779.     then
  780.         my_echo GIT checkout of UHD FAILED
  781.         rm -f tmp$$
  782.         doexit FETCH-UHD-FAIL
  783.     fi
  784.     if [ $UTAG != None ]
  785.     then
  786.         cd uhd
  787.         git checkout $UTAG >/dev/null 2>&1
  788.         git status >tmp$$ 2>&1
  789.         if grep -q "On branch $UTAG" tmp$$
  790.         then
  791.             whee=yes
  792.             rm -f tmp$$
  793.         else
  794.             my_echo Could not fetch UHD tagged $UTAG from GIT
  795.             rm -f tmp$$
  796.         fi
  797.         cd ..
  798.     fi
  799.    
  800.     #
  801.     # GIT the RTL-SDR source tree
  802.     #
  803.     rm -rf rtl-sdr
  804.     rm -rf gr-osmosdr
  805.     rm  -rf gr-baz
  806.     rm -rf hackrf
  807.     rm -rf bladeRF
  808.     my_echo Fetching rtl-sdr "(rtl-sdr, gr-osmosdr, gr-iqbal, hackrf and bladeRF)" via GIT
  809.     git clone --progress git://git.osmocom.org/rtl-sdr >>$LOGDEV 2>&1
  810.     git clone --progress git://git.osmocom.org/gr-osmosdr >>$LOGDEV 2>&1
  811.     git clone --progress git://git.osmocom.org/gr-iqbal.git >>$LOGDEV 2>&1
  812.     git clone https://github.com/Nuand/bladeRF.git >>$LOGDEV 2>&1
  813.     if [ -d gr-iqbal ]
  814.     then
  815.         cd gr-iqbal
  816.         if [ $OLD_MODE -eq 1 ]
  817.         then
  818.             git checkout gr3.6
  819.         fi
  820.         git submodule init  >>$LOGDEV 2>&1
  821.         git submodule update >>$LOGDEV 2>&1
  822.         cd ..
  823.     fi
  824.     git clone --progress https://github.com/mossmann/hackrf.git >>$LOGDEV 2>&1
  825.     my_echo Done
  826. }
  827.  
  828. function uhd_build {
  829.     #
  830.     # UHD build
  831.     #
  832.     sudocheck
  833.     if [ ! -d uhd ]
  834.     then
  835.         my_echo you do not appear to have the \'uhd\' directory
  836.         my_echo you should probably use $0 gitfetch to fetch the appropriate
  837.         my_echo files using GIT
  838.         doexit BUILD-UHD-NOT-THERE
  839.     fi
  840.     if [ $UTAG != None ]
  841.     then
  842.         cd uhd
  843.         git checkout $UTAG >/dev/null 2>&1
  844.         cd ..
  845.     fi
  846.     my_echo Building UHD...
  847.     my_echo "=============> THIS WILL TAKE SOME TIME <============="
  848.     my_echo
  849.     cd uhd/host
  850.     if [ ! -d build ]
  851.     then
  852.         mkdir build
  853.     fi
  854.     cd build
  855.     make clean >/dev/null 2>&1
  856.     cmake "$TEST" "$TEST2" $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 ../ >>$LOGDEV 2>&1
  857.     make clean >>$LOGDEV 2>&1
  858.     make $JFLAG >>$LOGDEV 2>&1
  859.     if [ $? -ne 0  ]
  860.     then
  861.         my_echo UHD build apparently failed
  862.         my_echo Exiting UHD build
  863.         doexit UHD-BUILD-FAIL1
  864.     fi
  865.     sudo make $JFLAG install >>$LOGDEV 2>&1
  866.     which uhd_find_devices >/dev/null 2>&1
  867.     x=$?
  868.     if [ $x -ne 0 -a ! -f /usr/local/bin/uhd_find_devices -a ! -f /opt/local/bin/uhd_find_devices ]
  869.     then
  870.         my_echo UHD build/install apparently failed since I cannot find /usr/local/bin/uhd_find_devices
  871.         my_echo after doing make and make install
  872.         my_echo Exiting UHD build
  873.         doexit UHD-BUILD-FAIL2
  874.     fi
  875.     sudo ldconfig >>$LOGDEV 2>&1
  876.     my_echo Done building/installing UHD
  877. }
  878.  
  879. function rtl_build {
  880.     #
  881.     # RTL build
  882.     #
  883.     sudocheck
  884.     cd $CWD
  885.     if [ ! -d rtl-sdr ]
  886.     then
  887.         my_echo you do not appear to have the \'rtl-sdr\' directory
  888.         my_echo you should probably use $0 gitfetch to fetch the appropriate
  889.         my_echo files using GIT
  890.         doexit BUILD-RTL-NOT-THERE
  891.     fi
  892.    
  893.     my_echo -n Building rtl-sdr...
  894.     cd rtl-sdr
  895.     cmake "$TEST" "$TEST2" $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 . >>$LOGDEV 2>&1
  896.     make clean >>$LOGDEV 2>&1
  897.     make $JFLAG >>$LOGDEV 2>&1
  898.  
  899.     if [ $? -ne 0  ]
  900.     then
  901.         my_echo rtl-sdr build apparently failed
  902.         my_echo Exiting rtl-sdr build
  903.         doexit RTL-BUILD-FAIL1
  904.     fi
  905.     sudo make $JFLAG install >>$LOGDEV 2>&1
  906.     my_echo Done building rtl-sdr
  907.    
  908.     cd $CWD
  909.     if [ -d hackrf ]
  910.     then
  911.         my_echo -n Building hackrf...
  912.         cd hackrf
  913.         cmake "$TEST" "$TEST2" $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 -DINSTALL_UDEV_RULES=ON host/ >>$LOGDEV 2>&1
  914.         make clean >>$LOGDEV 2>&1
  915.         make >>$LOGDEV 2>&1
  916.         if [ $? -ne 0 ]
  917.         then
  918.             my_echo hackrf build failed
  919.             my_echo Exiting hackrf build
  920.         else
  921.             sudo make install >>$LOGDEV 2>&1
  922.         fi
  923.         my_echo Done building hackrf
  924.         cd $CWD
  925.     fi
  926.     cd $CWD
  927.     if [ -d gr-iqbal ]
  928.     then
  929.         my_echo -n Building gr-iqbal...
  930.         cd gr-iqbal
  931.         mkdir -p build
  932.         cd build
  933.         cmake .. "$TEST" "$TEST2" $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  934.         make clean >>$LOGDEV 2>&1
  935.         make >>$LOGDEV 2>&1
  936.         if [ $? -ne 0 ]
  937.         then
  938.             my_echo gr-iqbal build apparently failed
  939.             my_echo Exiting gr-iqbal build
  940.         else
  941.             sudo make install  >>$LOGDEV 2>&1
  942.             cd $CWD
  943.             my_echo Done building gr-iqbal
  944.         fi
  945.     fi
  946.     if [ -d bladeRF  ]
  947.     then
  948.         my_echo -n Building bladeRF...
  949.         cd bladeRF
  950.         cd host
  951.         cmake . "$TEST" "$TEST2" $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  952.         make clean >>$LOGDEV 2>&1
  953.         make >>$LOGDEV 2>&1
  954.         if [ $? -ne 0 ]
  955.         then
  956.             my_echo bladeRF build apparently failed
  957.             my_echo Exiting bladeRF build
  958.         else
  959.             sudo make install >>$LOGDEV 2>&1
  960.             cd $CWD
  961.             my_echo Done building bladeRF
  962.         fi
  963.     fi
  964.    
  965.    
  966.    
  967.  
  968.     cd $CWD
  969.     if [ ! -d gr-osmosdr ]
  970.     then
  971.         my_echo you do not appear to have the \'gr-osmosdr\' directory
  972.         my_echo you should probably use $0 gitfetch to fetch the appropriate
  973.         my_echo files using GIT
  974.         doexit RTL-BUILD-FAIL2
  975.     fi
  976.     cd gr-osmosdr
  977.     if [ $OLD_MODE -eq 1 ]
  978.     then
  979.         git checkout gr3.6 >/dev/null 2>&1
  980.     fi
  981.     my_echo -n Building gr-osmosdr...
  982.     cmake . "$TEST" "$TEST2" $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 >>$LOGDEV  2>&1
  983.     make clean >>$LOGDEV 2>&1
  984.     make $JFLAG >>$LOGDEV 2>&1
  985.    
  986.     if [ $? -ne 0 ]
  987.     then
  988.         my_echo gr-osmosdr build apparently failed
  989.         my_echo Exit rtl-sdr/gr-osmosdr build
  990.         doexit OSMOSDR-BUILD-FAIL
  991.     fi
  992.     sudo make $JFLAG install >>$LOGDEV 2>&1
  993.     my_echo Done building gr-osmosdr
  994.     sudo ldconfig >>$LOGDEV 2>&1
  995.    
  996.     cd $CWD
  997.     my_echo Done building/installing rtl-sdr/gr-osmosdr
  998. }
  999.  
  1000. function firmware {
  1001.     sudocheck
  1002.     FOUND_DOWNLOADER=False
  1003.     dirlist="/usr/local/share /usr/local/lib /usr/local/lib64"
  1004.     prog=uhd_images_downloader.py
  1005.    
  1006.     for dir in $dirlist
  1007.     do
  1008.         if [ -f $dir/uhd/utils/$prog ]
  1009.         then
  1010.             FOUND_DOWNLOADER=True
  1011.             DOWNLOADER=$dir/uhd/utils/$prog
  1012.         fi
  1013.     done
  1014.  
  1015.     if [ $FOUND_DOWNLOADER = True ]
  1016.     then
  1017.         sudo $DOWNLOADER
  1018.     else
  1019.         my_echo Could not find images downloader: $prog in any of $dirlist
  1020.         doexit UHD-FIRMWARE-FAIL
  1021.     fi
  1022.     my_echo Done downloading firmware to /usr/local/share/uhd/images
  1023. }
  1024.  
  1025. function gnuradio_build {
  1026.     sudocheck
  1027.    
  1028.     if [ $JOSHMODE = False ]
  1029.     then
  1030.         if [ ! -d gnuradio ]
  1031.         then
  1032.             my_echo you do not appear to have the \'gnuradio\' directory
  1033.             my_echo you should probably use $0 gitfetch to fetch the appropriate
  1034.             my_echo files using GIT
  1035.             doexit GNURADIO-BUILD-NOT-THERE
  1036.         fi
  1037.         if [ $GTAG != None ]
  1038.         then
  1039.             cd gnuradio
  1040.             git checkout $GTAG >/dev/null 2>&1
  1041.             cd ..
  1042.         fi
  1043.     else
  1044.         if [ ! -d jblum ]
  1045.         then
  1046.             my_echo you do not appear to have the \'jblum\' directory
  1047.             my_echo you should probably use $0 gitfetch to fetch the appropriate
  1048.             my_echo files using GIT
  1049.             doexit GNURADIO-BUILD-NO-JOSH
  1050.         fi
  1051.     fi
  1052.        
  1053.     #
  1054.     # LD stuff
  1055.     #
  1056.     my_echo /usr/local/lib >tmp$$
  1057.     my_echo /usr/local/lib64 >>tmp$$
  1058.  
  1059.     if grep -q /usr/local/lib /etc/ld.so.conf.d/*
  1060.     then
  1061.         my_echo /usr/local/lib already in ld.so.conf.d
  1062.     else
  1063.         sudo cp tmp$$ /etc/ld.so.conf.d/local.conf
  1064.     fi
  1065.     rm -f tmp$$
  1066.     my_echo Doing ldconfig...
  1067.     sudo ldconfig >/dev/null 2>&1
  1068.  
  1069.     PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  1070.    
  1071.     if [ -d /usr/local/lib64/pkgconfig ]
  1072.     then
  1073.         PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
  1074.     fi
  1075.    
  1076.     export PKG_CONFIG_PATH
  1077.    
  1078.     #
  1079.     # Build Gnuradio
  1080.     #
  1081.     if [ $JOSHMODE = False ]
  1082.     then
  1083.         cd gnuradio
  1084.     else
  1085.         cd jblum
  1086.         git checkout gr_basic >>$LOGDEV 2>&1
  1087.     fi
  1088.  
  1089.     my_echo Building Gnu Radio...
  1090.     my_echo "=========> THIS WILL TAKE QUITE A WHILE <============="
  1091.     my_echo " "
  1092.     my_echo ...Doing cmake
  1093.     if [ -d build ]
  1094.     then
  1095.         my_echo ...build directory already here
  1096.     else
  1097.         mkdir build
  1098.     fi
  1099.     cd build
  1100.     make clean >/dev/null 2>&1
  1101.     my_echo ...Cmaking
  1102.     cmake -DENABLE_BAD_BOOST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo "$TEST" "$TEST2" $CMAKE_FLAG1 $CMAKE_FLAG2 $CMF1 $CMF2 ../ >>$LOGDEV 2>&1
  1103.     my_echo ...Building
  1104.     make $JFLAG clean >>$LOGDEV 2>&1
  1105.     make $JFLAG >>$LOGDEV 2>&1
  1106.     if [ $? -ne 0 ]
  1107.     then
  1108.         my_echo make failed
  1109.         my_echo Exiting Gnu Radio build/install
  1110.         doexit GNURADIO-BUILD-FAIL
  1111.     fi
  1112.     my_echo ...Installing
  1113.     sudo rm -rf /usr/local/include/gnuradio/
  1114.     sudo rm -f /usr/local/lib*/libgnuradio*
  1115.     sudo make $JFLAG install >>$LOGDEV 2>&1
  1116.     sudo ldconfig >>$LOGDEV 2>&1
  1117.     my_echo Done building and installing Gnu Radio
  1118.     my_echo -n GRC freedesktop icons install ...
  1119.     if [ -f /usr/local/libexec/gnuradio/grc_setup_freedesktop ]
  1120.     then
  1121.         sudo chmod 755 /usr/local/libexec/gnuradio/grc_setup_freedesktop
  1122.         sudo /usr/local/libexec/gnuradio/grc_setup_freedesktop install >>$LOGDEV 2>&1
  1123.     fi
  1124.     my_echo Done
  1125. }
  1126.  
  1127. function do_an_extra {
  1128.     if [ -e $1 ]
  1129.     then
  1130.         my_echo Building extra module $1
  1131.         cd $1
  1132.         if [  -f CMakeLists.txt ]
  1133.         then
  1134.             mkdir -p build >>$LOGDEV 2>&1
  1135.             cd build
  1136.             cmake .. "$TEST" "$TEST2" $CMAKE_FLAGS1 $CMAKE_FLAGS2 $CMF1 $CMF2 >>$LOGDEV 2>&1
  1137.             make >>$LOGDEV 2>&1
  1138.             sudo make install >>$LOGDEV 2>&1
  1139.             sudo ldconfig
  1140.         elif [ - bootstrap ]
  1141.         then
  1142.             chmod 755 bootstrap
  1143.             ./bootstrap  >>$LOGDEV 2>&1
  1144.             PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
  1145.             ./configure >>$LOGDEV 2>&1
  1146.             make >>$LOGDEV 2>&1
  1147.             sudo make install >>$LOGDEV 2>&1
  1148.             sudo ldconfig
  1149.         else
  1150.             my_echo Couldnt determine how to make module $1 neither bootstrap nor CmakeLists.txt present
  1151.         fi
  1152.     else
  1153.         my_echo Couldnt build module $1 directory not there
  1154.     fi
  1155. }
  1156.  
  1157. function extras {
  1158.     sudocheck
  1159.     date=`date +%Y%m%d%H%M%S`
  1160.     if [ ! "@$EXTRAS@" = "@@" ]
  1161.     then
  1162.         for module in $EXTRAS
  1163.         do
  1164.             cd $CWD
  1165.             base=`basename $module .git`
  1166.             case $module in
  1167.             git:*|*.git)
  1168.                 mv $base $base.$date.bgmoved >>$LOGDEV 2>&1
  1169.                 my_echo Doing GIT checkout for extra module $base
  1170.                 git clone $module  >>$LOGDEV 2>&1
  1171.                 do_an_extra $base
  1172.                 ;;
  1173.             htt*:*svn*)
  1174.                 mv $base $base.$date >>$LOGDEV 2>&1
  1175.                 my_echo Doing SVN checkout for extra module $base
  1176.                 svn co $module >>$LOGDEV 2>&1
  1177.                 if [ -e $base/trunk ]
  1178.                 then
  1179.                     do_an_extra $base/trunk
  1180.                 else
  1181.                     do_an_extra $base
  1182.                 fi
  1183.                 ;;
  1184.             *)
  1185.                 my_echo Ignoring malformed extra module $module
  1186.                 ;;
  1187.             esac
  1188.            
  1189.         done
  1190.     fi
  1191.     cd $CWD
  1192. }
  1193.  
  1194. function mod_groups {
  1195.     sudocheck
  1196.     #
  1197.     # Post install stuff
  1198.     #
  1199.     # USRP rules for UDEV and USRP group
  1200.     #
  1201.     #
  1202.     # Check for USRP group, and update if necessary
  1203.     if grep -q usrp /etc/group
  1204.     then
  1205.         my_echo Group \'usrp\' already in /etc/group
  1206.     else
  1207.         sudo /usr/sbin/groupadd usrp
  1208.     fi
  1209.  
  1210.     #
  1211.     # Check that our calling user is in the USRP group, update if necessary
  1212.     #
  1213.     if grep -q usrp.*${USER} /etc/group
  1214.     then
  1215.         my_echo User $USER already in group \'usrp\'
  1216.     else
  1217.         sudo /usr/sbin/usermod -a -G usrp $USER
  1218. cat <<"!EOF!"
  1219. ********************************************************************************
  1220. This script has just modified /etc/group to place your userid '('$USER')' into group 'usrp'
  1221. In order for this change to take effect, you will need to log-out and log back
  1222. in again.  You will not be able to access your USRP1 device until you do this.
  1223.  
  1224. If you wish to allow others on your system to use the USRP1 device, you will need to use:
  1225.  
  1226.   sudo usermod -a -G usrp userid
  1227.  
  1228. For each userid you wish to allow access to the usrp
  1229.  
  1230. ********************************************************************************
  1231.  
  1232. Further
  1233. !EOF!
  1234.     fi
  1235.     if [ "$USERSLIST" = None ]
  1236.     then
  1237.         foo=bar
  1238.     else
  1239.         ul=`echo $USERSLIST|sed -e 's/,/ /g'`
  1240.         for u in $ul
  1241.         do
  1242.             sudo /usr/sbin/usermod -a -G usrp $u
  1243.             my_echo Added $u to group usrp
  1244.         done
  1245.     fi
  1246. }
  1247.  
  1248. function mod_udev {
  1249.     sudocheck
  1250.     #
  1251.     # Check for UHD UDEV rules file, update if exists
  1252.     #
  1253.     if [ -f $CWD/uhd/host/utils/uhd-usrp.rules ]
  1254.     then
  1255.         sudo cp $CWD/uhd/host/utils/uhd-usrp.rules /etc/udev/rules.d/10-usrp.rules
  1256.         sudo chown root /etc/udev/rules.d/10-usrp.rules
  1257.         sudo chgrp root /etc/udev/rules.d/10-usrp.rules
  1258.     fi
  1259.  
  1260.     #
  1261.     # Check for rtl-sdr UDEV rules file, update if exists
  1262.     #
  1263.     rm -f tmp$$
  1264.     if [ -f $CWD/rtl-sdr/rtl-sdr.rules ]
  1265.     then
  1266.         sudo cp $CWD/rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/15-rtl-sdr.rules
  1267.         sudo chown root /etc/udev/rules.d/15-rtl-sdr.rules
  1268.         sudo chgrp root /etc/udev/rules.d/15-rtl-sdr.rules
  1269.     fi
  1270.     sudo killall -HUP udevd
  1271.     sudo udevadm control --reload-rules
  1272. }
  1273.  
  1274. function mod_sysctl {
  1275.     sudocheck
  1276.     #
  1277.     # Modify sysctl.conf as necessary
  1278.     #
  1279.     cat >tmp$$ <<!EOF!
  1280. # Updates for Gnu Radio
  1281. net.core.rmem_max = 1000000
  1282. net.core.wmem_max = 1000000
  1283. kernel.shmmax = 2147483648
  1284. !EOF!
  1285.  
  1286.  
  1287.     if grep -q 'Updates for Gnu Radio' /etc/sysctl.conf
  1288.     then
  1289.         my_echo Required updates to /etc/sysctl.conf already in place
  1290.     else
  1291.         my_echo Applying updates to /etc/sysctl.conf
  1292.         cat /etc/sysctl.conf tmp$$ >tmp2$$
  1293.         chmod 644 tmp2$$
  1294.         sudo mv tmp2$$ /etc/sysctl.conf
  1295.     fi
  1296.  
  1297.     sudo sysctl -w net.core.rmem_max=1000000 >/dev/null 2>&1
  1298.     sudo sysctl -w net.core.wmem_max=1000000 >/dev/null 2>&1
  1299.     sudo sysctl -w kernel.shmmax=2147483648  >/dev/null 2>&1
  1300.      
  1301.     rm -f tmp$$
  1302.     rm -f tmp2$$
  1303.    
  1304.     if grep -q usrp /etc/security/limits.conf
  1305.     then
  1306.         my_echo usrp group already has real-time scheduling privilege
  1307.     else
  1308.         cat >tmp$$ <<!EOF!
  1309. @usrp  - rtprio 50
  1310. !EOF!
  1311.         cat /etc/security/limits.conf tmp$$ >tmp2$$
  1312.         sudo cp tmp2$$ /etc/security/limits.conf
  1313.         sudo chmod 644 /etc/security/limits.conf
  1314.         rm -f tmp$$ tmp2$$
  1315.         my_echo Group \'usrp\' now has real-time scheduling privileges
  1316.         my_echo You will need to log-out and back in again for this to
  1317.         my_echo take effect
  1318.     fi
  1319. }
  1320.  
  1321. function all {
  1322.     my_echo Starting all functions at: `date`
  1323.     cd $CWD
  1324.     prereqs
  1325.     touch -d "15 minutes ago" touch$$
  1326.     if [ -d uhd -a -d gnuradio ]
  1327.     then
  1328.         if [ uhd -ot touch$$ -o gnuradio -ot touch$$ ]
  1329.         then
  1330.             gitfetch
  1331.         else
  1332.             my_echo Skipping git fetch, since \'uhd\' and \'gnuradio\' are new enough
  1333.         fi
  1334.     else
  1335.         gitfetch
  1336.     fi
  1337.     rm -f touch$$
  1338.     EXTRAS=$EXTRAS" https://github.com/balint256/gr-baz.git"
  1339.     EXTRAS=$EXTRAS" https://github.com/guruofquality/grextras.git"
  1340.     for fcn in uhd_build firmware gnuradio_build rtl_build extras mod_groups mod_udev mod_sysctl pythonpath
  1341.     do
  1342.         my_echo Starting function $fcn at: `date`
  1343.         cd $CWD
  1344.         $fcn
  1345.         my_echo Done function $fcn at: `date`
  1346.     done
  1347.     my_echo Done all functions at: `date`
  1348. }
  1349.  
  1350. function pythonpath {
  1351.     for PYVER in 2.6 2.7
  1352.     do
  1353.         for type in "" 64
  1354.         do
  1355.             if [ -d /usr/local/lib${type}/python${PYVER}/site-packages/gnuradio ]
  1356.             then
  1357.                 PYTHONPATH=/usr/local/lib${type}/python${PYVER}/site-packages
  1358.             fi
  1359.             if [ -d /usr/local/lib${type}/python${PYVER}/dist-packages/gnuradio ]
  1360.             then
  1361.                 PYTHONPATH=/usr/local/lib${type}/python${PYVER}/dist-packages
  1362.             fi
  1363.         done
  1364.     done
  1365.     echo
  1366.     echo
  1367.     echo "************************************************************"
  1368.     echo You should probably set your PYTHONPATH to:
  1369.     echo " "
  1370.     echo "    " $PYTHONPATH
  1371.     echo " "
  1372.     echo Using:
  1373.     echo " "
  1374.     echo export PYTHONPATH=$PYTHONPATH
  1375.     echo " "
  1376.     echo in your .bashrc or equivalent file prior to attempting to run
  1377.     echo any Gnu Radio applications or Gnu Radio Companion.
  1378.     echo "*************************************************************"
  1379. }
  1380.  
  1381. function sudocheck {
  1382.     #
  1383.     # Check SUDO privileges
  1384.     #
  1385.     if [ $SUDOASKED = n ]
  1386.     then
  1387.         echo SUDO privileges are required
  1388.         echo -n Do you have SUDO privileges'?'
  1389.         read ans
  1390.         case $ans in
  1391.             y|Y|YES|yes|Yes)
  1392.                 echo Continuing with script
  1393.                 SUDOASKED=y
  1394.                 sudo grep timestamp_timeout /etc/sudoers >tmp$$
  1395.                 timeout=`cat tmp$$|awk '/./ {print $4}'`
  1396.                 rm -f tmp$$
  1397.                 if [ "@@" = "@$timeout@" ]
  1398.                 then
  1399.                     sudo cp /etc/sudoers tmp$$
  1400.                     sudo chown $USER tmp$$
  1401.                     sudo chmod 644 tmp$$
  1402.                     echo "Defaults  timestamp_timeout = 90" >>tmp$$
  1403.                     sudo cp tmp$$ /etc/sudoers
  1404.                     sudo chown root /etc/sudoers
  1405.                     sudo chmod 440 /etc/sudoers
  1406.                 elif [ "$timeout" -lt 90 ]
  1407.                 then
  1408.                     echo You need to have a timestamp_timout in /etc/sudoers of 90 or more
  1409.                     echo Please ensure that your timestamp_timeout is 90 or more
  1410.                     exit
  1411.                 fi
  1412.                 ;;
  1413.             *)
  1414.                 echo Exiting.  Please ensure that you have SUDO privileges on this system!
  1415.                 exit
  1416.                 ;;
  1417.         esac
  1418.     fi
  1419. }
  1420.  
  1421. PATH=$PATH
  1422. export PATH
  1423. case $# in
  1424.     0)
  1425.         all
  1426.         my_echo All Done
  1427.         doexit SUCCESS
  1428. esac
  1429.  
  1430. for arg in $*
  1431. do
  1432.     cd $CWD
  1433.     $arg
  1434. done
  1435. my_echo All Done
  1436. doexit SUCCESS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement