Skip to content

Instantly share code, notes, and snippets.

@sprout42
Last active December 16, 2023 15:20
Show Gist options
  • Save sprout42/9f543c5e75c18f30f39b513113cd7ac5 to your computer and use it in GitHub Desktop.
Save sprout42/9f543c5e75c18f30f39b513113cd7ac5 to your computer and use it in GitHub Desktop.
Installing gnuradio w/ companion on MacOS
# This compiles and installs gnuradio including gnuradio-companion for MacOS.
# It uses homebrew (https://brew.sh/) for all non-python libraries and pyenv
# (https://github.com/pyenv/pyenv) for managing python. I'm sure some of this
# would be easier if I used homebrew for python as well but I've found pyenv
# and standard pip to be less buggy in general. However it does mean that for
# python packages that don't install with pip you need to download and compile
# the packages.
#
# Note that this script is not very robust yet, it's not made to run more than
# once (sorry). ~If~ When you find bugs please let me know and we'll update
# it. This is just a gist with embedded patches because I don't want to try
# and maintain a ton of repos for just a few minor bugs here and there.
#########################
# HOMEBREW requirements
#########################
# 1. Install homebrew
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 2. Install dependencies for all of the crap we'll be installing shortly
brew install boost cppunit cmake fftw doxygen gsl zmq portaudio jack uhd sdl libffi libglade wxwidgets
brew cask install xquartz
brew install imagemagick --with-x11
brew install libffi
brew link --force libffi
# QT4 requires a non-standard tap
brew tap cartr/qt4
brew install qt@4 qwt-qt4
# I don't know why I can't get the standard homebrew libzmqpp package to work
# like this one does
brew tap dholm/homebrew-sdr
brew install cppzmq
# GQRX requires QT5
brew install qt
#########################
# PYTHON requirements
#########################
# 3. Install pyenv (https://github.com/pyenv/pyenv#installation)
# git clone https://github.com/pyenv/pyenv ~/.pyenv
# echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
# echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
# echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
# 4. Install required pip packages
pip install numpy scipy Cheetah wxPython lxml zmq pycairo
#########################
# MANUALLY installed gnuradio dependencies
#########################
# 5. Make a directory somewhere to keep all of these in one place
mkdir -p ~/sdr
cd ~/sdr
# 6. Install pygobject
wget http://ftp.gnome.org/pub/GNOME/sources/pygobject/2.28/pygobject-2.28.7.tar.xz
tar -xf pygobject-2.28.7.tar.xz
cd pygobject-2.28.7
./configure CFLAGS=-ObjC --prefix=$(python-config --prefix) --disable-dependency-tracking
make
make install
echo "gtk-2.0" > $(python-config)/lib/python2.7/pygtk.pth
cd ~/sdr
# 7. Install pygtk
wget http://ftp.gnome.org/pub/GNOME/sources/pygtk/2.24/pygtk-2.24.0.tar.gz
tar -xf pygtk-2.24.0.tar.gz
cd pygtk-2.24.0
PKG_CONFIG_PATH=$(python-config --prefix)/lib/pkgconfig ./configure CFLAGS=-ObjC --prefix=$(python-config --prefix) --disable-dependency-tracking
make
make install
cd ~/sdr
# 8. Install rtl-sdr (everyone's got one). This could be installed through
# homebrew as well, I had inconsistent results using the homebrew install
# for some unknown reason so I'm going to do it here.
git clone git://git.osmocom.org/rtl-sdr
cd rtl-sdr
# Minor patch required, not sure why
patch -p1 <<'HERE'
diff --git a/src/rtl_test.c b/src/rtl_test.c
index 42d2c94..8009c6e 100644
--- a/src/rtl_test.c
+++ b/src/rtl_test.c
@@ -162,8 +162,8 @@ static int ppm_gettime(struct time_generic *tg)
struct timeval tv;
rv = gettimeofday(&tv, NULL);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec * 1000;
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec * 1000;
#endif
return rv;
}
HERE
mkdir build
cd build
cmake ..
make
make install
cd ~/sdr
# 9. Install SoapySDR
git clone https://github.com/pothosware/SoapySDR
cd SoapySDR
patch -p1 <<'HERE'
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index b1ae6d9..e7e28f6 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -30,12 +30,12 @@ endif()
########################################################################
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
- "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True, prefix=''))"
+ "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE PYTHON_INSTALL_DIR_SYSCONF
)
set(PYTHON_INSTALL_DIR "${PYTHON_INSTALL_DIR_SYSCONF}" CACHE STRING "python install prefix")
-message(STATUS "PYTHON_INSTALL_DIR: \${prefix}/${PYTHON_INSTALL_DIR}")
+message(STATUS "PYTHON_INSTALL_DIR: /${PYTHON_INSTALL_DIR}")
########################################################################
# Find Python libs
@@ -137,7 +137,10 @@ include_directories(${PYTHON_INCLUDE_DIRS})
message(STATUS "CMAKE_SWIG_FLAGS=${CMAKE_SWIG_FLAGS}")
set_source_files_properties(SoapySDR.i PROPERTIES CPLUSPLUS ON)
-SWIG_ADD_MODULE(SoapySDR python SoapySDR.i)
+#SWIG_ADD_MODULE(SoapySDR python SoapySDR.i)
+SWIG_ADD_LIBRARY(SoapySDR
+ LANGUAGE python
+ SOURCES SoapySDR.i)
SWIG_LINK_LIBRARIES(SoapySDR ${SoapySDR_LIBRARIES} ${PYTHON_LIBRARIES})
########################################################################
diff --git a/python3/CMakeLists.txt b/python3/CMakeLists.txt
index f38001b..e47c006 100644
--- a/python3/CMakeLists.txt
+++ b/python3/CMakeLists.txt
@@ -26,12 +26,12 @@ message(STATUS "PYTHON3_EXECUTABLE: ${PYTHON3_EXECUTABLE}")
########################################################################
execute_process(
COMMAND ${PYTHON3_EXECUTABLE} -c
- "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True, prefix=''))"
+ "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE PYTHON3_INSTALL_DIR_SYSCONF
)
set(PYTHON3_INSTALL_DIR "${PYTHON3_INSTALL_DIR_SYSCONF}" CACHE STRING "python3 install prefix")
-message(STATUS "PYTHON3_INSTALL_DIR: \${prefix}/${PYTHON3_INSTALL_DIR}")
+message(STATUS "PYTHON3_INSTALL_DIR: ${PYTHON3_INSTALL_DIR}")
########################################################################
# Find Python libs
@@ -76,7 +76,10 @@ configure_file(
message(STATUS "CMAKE_SWIG_FLAGS=${CMAKE_SWIG_FLAGS}")
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/SoapySDR.i PROPERTIES CPLUSPLUS ON)
-SWIG_ADD_MODULE(SoapySDR3 python ${CMAKE_CURRENT_BINARY_DIR}/SoapySDR.i)
+#SWIG_ADD_MODULE(SoapySDR3 python ${CMAKE_CURRENT_BINARY_DIR}/SoapySDR.i)
+SWIG_ADD_LIBRARY(SoapySDR3
+ LANGUAGE python
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/SoapySDR.i)
SWIG_LINK_LIBRARIES(SoapySDR3 ${SoapySDR_LIBRARIES} ${PYTHON3_LIBRARIES})
set_target_properties(${SWIG_MODULE_SoapySDR3_REAL_NAME} PROPERTIES OUTPUT_NAME _SoapySDR)
HERE
mkdir build
cd build
cmake -DENABLE_PYTHON=ON -DPYTHON_LIBRARY=$(python-config --prefix)/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python2.7 -DPYTHON_INSTALL_DIR=$(python-config --prefix)/lib/python2.7/site-packages -DENABLE_PYTHON3=OFF ..
make
make install
cd ~/sdr
# swig
git clone https://github.com/swig/swig
./configure --prefix=/usr/local
make
make install
cd ~/sdr
# sip
https://newcontinuum.dl.sourceforge.net/project/pyqt/sip/sip-4.19.8/sip-4.19.8.tar.gz
tar -xf sip-4.19.8.tar.gz
cd sip-4.19.8
python configure.py
make
make install
cd ~/sdr
# PyQt4
wget https://versaweb.dl.sourceforge.net/project/pyqt/PyQt4/PyQt-4.12.1/PyQt4_gpl_mac-4.12.1.tar.gz
tar -xf PyQt4_gpl_mac-4.12.1.tar.gz
cd PyQt4_gpl_mac-4.12.1
python configure-ng.py
make
make install
cd ~/sdr
#########################
# I don't need any other drivers for different SDRs, but if you have something
# special here is the place to install them.
#########################
# gnuradio
git clone --recurse-submodules https://github.com/gnuradio/gnuradio
cd gnuradio
patch -p1 <<'HERE'
diff --git a/cmake/Modules/FindZeroMQ.cmake b/cmake/Modules/FindZeroMQ.cmake
index 62a1c6b96..371c9103c 100644
--- a/cmake/Modules/FindZeroMQ.cmake
+++ b/cmake/Modules/FindZeroMQ.cmake
@@ -1,5 +1,5 @@
INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(PC_ZEROMQ "libzmq")
+PKG_CHECK_MODULES(PC_ZEROMQ "libzmqpp")
FIND_PATH(ZEROMQ_INCLUDE_DIRS
NAMES zmq.hpp
diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake
index 06e061e21..ea58db8dd 100644
--- a/cmake/Modules/GrPython.cmake
+++ b/cmake/Modules/GrPython.cmake
@@ -106,7 +106,7 @@ endmacro(GR_PYTHON_CHECK_MODULE)
if(NOT DEFINED GR_PYTHON_DIR)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
from distutils import sysconfig
-print sysconfig.get_python_lib(plat_specific=True, prefix='')
+print sysconfig.get_python_lib(plat_specific=True)
" OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
index c7b402797..108d524aa 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
@@ -107,7 +107,7 @@ endmacro(GR_PYTHON_CHECK_MODULE)
if(NOT DEFINED GR_PYTHON_DIR)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
from distutils import sysconfig
-print sysconfig.get_python_lib(plat_specific=True, prefix='')
+print sysconfig.get_python_lib(plat_specific=True)
" OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt
index 4c782a7f7..c352f6d2a 100644
--- a/grc/CMakeLists.txt
+++ b/grc/CMakeLists.txt
@@ -25,7 +25,7 @@ include(GrPython)
GR_PYTHON_CHECK_MODULE("python >= 2.5" sys "sys.version.split()[0] >= '2.5'" PYTHON_MIN_VER_FOUND)
GR_PYTHON_CHECK_MODULE("Cheetah >= 2.0.0" Cheetah "Cheetah.Version >= '2.0.0'" CHEETAH_FOUND)
GR_PYTHON_CHECK_MODULE("lxml >= 1.3.6" lxml.etree "lxml.etree.LXML_VERSION >= (1, 3, 6, 0)" LXML_FOUND)
-GR_PYTHON_CHECK_MODULE("pygtk >= 2.10.0" gtk "gtk.pygtk_version >= (2, 10, 0)" PYGTK_FOUND)
+GR_PYTHON_CHECK_MODULE("pygtk >= 2.10.0" pygtk True PYGTK_FOUND)
GR_PYTHON_CHECK_MODULE("numpy" numpy True NUMPY_FOUND)
########################################################################
HERE
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_LIBRARY=$(python-config --prefix)/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python2.7 ..
make
make install
# Make sure that gnuradio built and installed properly, this could take
# a little while
make test
cd ~/sdr
# gr-osmosdr
git clone git://git.osmocom.org/gr-osmosdr
cd gr-osmosdr
mkdir build
cd build
cmake ..
make
make install
cd ~/sdr
# gqrx
git clone https://github.com/csete/gqrx
cd gqrx
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix qt)
make
make install
cd ~/sdr
# limesuite
git clone https://github.com/myriadrf/LimeSuite
cd LimeSuite
mkdir builddir
cd builddir
cmake -DDOWNLOAD_IMAGES=TRUE -DENABLE_STREAM=ON -DENABLE_GUI=ON -DENABLE_SOAPY_LMS7=ON ..
make
make install
cd ~/sdr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment