build script - tomyummmm/Gen2-UHF-RFID-Reader GitHub Wiki

Breakdown of build-script and modifications

Global variables

VERBOSE=No
JFLAG=""
DRYRUN=""
PULLED_LIST="gnuradio uhd rtl-sdr gr-osmosdr gr-iqbal hackrf bladeRF airspyone_host SoapySDR SoapyUHD LimeSuite gr-limesdr"
CWD="`pwd`"

Flags

Flags Description
-v/--verbose Turn on verbose logging to stdout
-jN Have make use N concurrent jobs
-ja Have make use Max - 1 concurrent jobs with auto setting of N (based on number of cpu cores on build system)
-u/--users ul Add comma-separated users to 'usrp' group in addition to calling user ( $USER )
-n Dry-run for uninstallation only
-l/--logfile lf Log messages to 'lf'
-ut Set tag for UHD checkout to
-ucf Set UHD CMake flags to
-gt Set tag for Gnu Radio checkout to
-gcf Set Gnu Radio CMake flags to
-e/--extras Add an item to "extras" to be built after Gnu Radio/UHD/gs-osmosdr

Functions

Available funcs Description
all Do all functions (default)
prereqs Install prerequisites
gitfetch Use GIT to fetch all packages
uhd_build Build only UHD
firmware Fetch firmware/FPGA
gnuradio_build Build only GNU Radio
rtl_build Build rtl-sdr + gr-osmosdr + gr-iqbal + hackrf + bladeRF + airspyone_host
SoapySDR Build only SoapySDR
LimeSuite Build only LimeSuite
gr-limesdr Build only gr-limesdr
G2RFID Build Gen2 UHF RFID Reader
mod_groups Modify the /etc/groups and add user to group 'usrp'
mod_udev Add UDEV rule for USRP1
mod_sysctl Modify SYSCTL for larger net buffers
pythonpath Print out PYTHONPATH
python_packages Install Python3 required packages
setenv Set environment variables for terminal and graphical GNU Radio Companion
uninstall Uninstall all packages, remove all downloaded packages and build files

function all (DEFAULT function)

Runs function installcheck.

Runs function prereqs.

Checks if uhd and gnuradio were created more than 15 minutes ago. If less than 15 minutes ago, skips gitfetch. IMPORTANT if you want to run all functions, delete uhd and gnuradio directories if re-run within 15 minutes.

Add any new functions to the following line 1526 for default installation. A FOR loop sequentially runs the entire list of functions.

for fcn in uhd_build firmware gnuradio_build rtl_build SoapySDR SoapyUHD LimeSuite gr-limesdr G2RFID python_packages mod_groups mod_udev mod_sysctl setenv extras

function installcheck

Checks with user that the relevant flags have been set, and informs the user of how long a typical installation will take.

Checks that there is at least 16GB of free disk space.

Checks whether packages listed in global variable PULLED_LIST are already downloaded.

for file in $PULLED_LIST

Checks if existing old (renamed from gitfetch) (greater than 100 MB I think) packages directories exist and how much space used. Offer to remove old packages, to redownload from GitHub.

Linux Distro Support

Line 211, modified to check if distro is Ubuntu. Add checks for relevant Linux Distro in first line.

for file in /etc/lsb-release
do
	if [ -f $file ]
	then
		good_to_go=yes
	fi
done
if [ $good_to_go = no ]
then
	echo Supported systems: Ubuntu 18.04 / 20.04 LTS
	echo You appear to be running none of the above, exiting
	exit
fi

Edit prereqs function with the relevant package list for each Linux Distro. Package list for Ubuntu and Fedora versions can be found in UHD Documentation and combined with dependencies of GNU Radio Documentation (Click on the distro of choice for specific dependencies).

function prereqs {
	sudocheck
	my_echo Installing prerequisites.
	my_echo "====>" THIS MAY TAKE QUITE SOME TIME "<====="

	#
	# It's a Ubuntu system
	# 
	if [ -f /etc/lsb-release ]
	then
		SYSTYPE=Ubuntu
		sudo apt-get -y purge 'gnuradio-*' >>$LOGDEV 2>&1
		sudo apt-get -y purge 'libgruel-*' >>$LOGDEV 2>&1
		sudo apt-get -y purge 'libgruel*' >>$LOGDEV 2>&1
		sudo apt-get -y purge 'libgruel0*' >>$LOGDEV 2>&1
		sudo apt-get -y purge 'libgnuradio*' >>$LOGDEV 2>&1
		sudo apt-get -y purge 'python-gnuradio*' >>$LOGDEV 2>&1
		case `grep DISTRIB_RELEASE /etc/lsb-release` in
		*20.*)
			PKGLIST="autoconf automake build-essential ccache cmake cpufrequtils doxygen ethtool 
			fort77 g++ gir1.2-gtk-3.0 git gobject-introspection gpsd gpsd-clients 
			inetutils-tools libasound2-dev libboost-all-dev libcomedi-dev libcppunit-dev 
			libfftw3-bin libfftw3-dev libfftw3-doc libfontconfig1-dev libgmp-dev libgps-dev 
			libgsl-dev liblog4cpp5-dev libncurses5 libncurses5-dev libpulse-dev 
			libqt5opengl5-dev libqwt-qt5-dev libsdl1.2-dev libtool libudev-dev libusb-1.0-0 
			libusb-1.0-0-dev libusb-dev libxi-dev libxrender-dev libzmq3-dev libzmq5 
			ncurses-bin python3-cheetah python3-click python3-click-plugins 
			python3-click-threading python3-dev python3-docutils python3-gi python3-gi-cairo 
			python3-gps python3-lxml python3-mako python3-numpy python3-numpy-dbg 
			python3-opengl python3-pyqt5 python3-requests python3-scipy python3-setuptools 
			python3-six python3-sphinx python3-yaml python3-zmq swig wget libcodec2-dev 
			libgsm1-dev libi2c-dev libsqlite3-dev libwxgtk3.0-gtk3-dev freeglut3-dev python3-pip"

			CMAKE_FLAG1=""
			CMAKE_FLAG2=""
			CMAKE_FLAG3=""
			;;

		*18.*)
			PKGLIST="git swig cmake doxygen build-essential libboost-all-dev libtool libusb-1.0-0 
			libusb-1.0-0-dev libudev-dev libncurses5-dev libfftw3-bin libfftw3-dev 
			libfftw3-doc libcppunit-1.14-0 libcppunit-dev libcppunit-doc ncurses-bin 
			cpufrequtils python-numpy python-numpy-doc python-numpy-dbg python-scipy 
			python-docutils qt4-bin-dbg qt4-default qt4-doc libqt4-dev libqt4-dev-bin 
			python-qt4 python-qt4-dbg python-qt4-dev python-qt4-doc libqwt6abi1 libncurses5 
			libncurses5-dbg libfontconfig1-dev libxrender-dev libpulse-dev g++ automake 
			autoconf python-dev libusb-dev fort77 libsdl1.2-dev python-wxgtk3.0 ccache 
			python-opengl libgsl-dev python-cheetah python-mako python-lxml qt4-dev-tools 
			libqwtplot3d-qt5-dev pyqt4-dev-tools python-qwt5-qt4 wget libxi-dev 
			gtk2-engines-pixbuf r-base-dev python-tk liborc-0.4-0 liborc-0.4-dev 
			libasound2-dev python-gtk2 libzmq3-dev libzmq5 python-requests python-sphinx 
			libcomedi-dev python-zmq libqwt-dev python-six libgps-dev libgps23 gpsd 
			gpsd-clients python-gps python-setuptools libgmp-dev python3-numpy python3-mako 
			python3-sphinx python3-lxml libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 
			liblog4cpp5-dev python3-yaml python3-click python3-click-plugins python3-zmq python3-scipy
			libi2c-dev libsqlite3-dev libwxgtk3.0-dev freeglut3-dev python3-pip"

			CMAKE_FLAG1=""
			CMAKE_FLAG2=""
			CMAKE_FLAG3=""
			;;

		*)
			my_echo Your Ubuntu release not supported--cannot proceed
			doexit WRONGRELEASE
			;;
		esac
		for pkg in $PKGLIST; do checkpkg $pkg; done
		my_echo Done checking packages
		for pkg in $PKGLIST
		do
			my_echo Installing $pkg
			sudo apt-get -y --ignore-missing install $pkg >>$LOGDEV 2>&1
		done
		
	else
		my_echo This script supports only Ubuntu 18.04 / 20.04 LTS
		doexit WRONGSYSTEM
	fi
	PATH=$PATH
	export PATH

	checkcmd git
	checkcmd cmake
	
	checklib libusb 2
	
	checklib libboost 5
	checklib libcppunit 0
	checklib libfftw 5
	checklib libgsl 0
	
	my_echo Done
}

function gitfetch

Fetches all packages and clones / checks out specific branches or master for GNU Radio 3.8. Some packages require submodules.

Renames any existing downloaded directory and downloads new from GitHub.

Edit to add new packages, ensure branch compatibility for GNU Radio 3.8.x.

Individual build functions

uhd_build / firmware

Build and install only UHD / Fetch firmware/FPGA.

Checks if 'uhd' directory exists, shows error message and exits otherwise.

gnuradio_build

Build and install only GNU Radio. Checks if 'gnuradio' directory exists, shows error message and exits otherwise.

rtl_build

Build and install rtl-sdr + gr-osmosdr + gr-iqbal + hackrf + bladeRF + airspyone_host. Checks if each directory exists, shows error message and exits otherwise.

SoapySDR

Checks if 'SoapySDR' directory exists, fetch from GitHub otherwise and continue. Build and install SoapySDR.

SoapyUHD

Checks if 'SoapyUHD' directory exists, fetch from GitHub otherwise and continue. Build and install SoapyUHD.

LimeSuite

Checks if 'LimeSuite' directory exists, fetch from GitHub otherwise and continue. Build and install LimeSuite.

G2RFID

Build and install G2RFID. Make sure to run after making changes to files within gr-rfid.

./build-script -ja G2RFID

gr-limesdr

Checks if 'gr-limesdr' directory exists, fetch from GitHub otherwise and continue. Build and install gr-limesdr.

Environment functions

pythonpath

Checks and prints PYTHONPATH in the terminal, does NOT add to .bashrc.

python_packages

Installs Python3 Packages from requirements.txt for the project.

Packages
matplotlib==3.5.1
numpy==1.17.4
PySide2==5.15.2
pyzmq==18.1.1

setenv

Attempt to set environment variables for terminal and graphical GNU Radio Companion export to ~/.bashrc, ~/.profile and /etc/profile.d/.

PYTHONPATH varies based on Linux Distro and Version (i.e Ubuntu 18.04 vs 20.04), edit accordingly.

Uninstallation

function uninstall

This script will uninstall all packages, remove all downloaded packages and build files.

Can be run with JFLAG, DRYRUN and VERBOSE flags.

./build-script -ja -n uninstall
./build-script -ja -v uninstall

Unmodified functions

Unmodified funcs Description
my_echo
checkcmd
checklib
firmware Fetch firmware/FPGA
mod_groups Modify the /etc/groups and add user to group 'usrp'
mod_udev Add UDEV rule for USRP1
mod_sysctl Modify SYSCTL for larger net buffers
do_an_extra
extras
sudocheck Check SUDO privileges
⚠️ **GitHub.com Fallback** ⚠️