Installing GNU Radio onto MacOS X 10.4.[2-10] using MacPorts Copyright (C) 2006-2007 Michael Dickens mdickens @at@ nd .dot. edu 2007-September-12 Introduction (from the MacInstall Wiki page on the GNU Radio website): --- There are 2 primary guides for installing GNU Radio (GR) on MacOS X "Tiger" 10.4: Jon Jacky's at < http://staff.washington.edu/~jon/gr-osx/gr-osx.html > and this guide. The former is more of a guide, while this one tends to provides scripts for most of the work. GR has been compiled and installed on MaxOS X 10.4 running any compatible version of XCode on all modern PPC-based Macs, and can be made to work with at least some Intel-based Macs. See the NOTE below. While it might be possible to use GNU Radio under MacOS X 10.3, getting the background libraries and applications installed would likely be difficult. The internal hardware on PPC-Macs was not designed for high throughput USB 2.0, and thus no PPC-Mac has been tested at 32 Mega-Bytes/second (MBps) using a USRP. The internal hardware on Intel-Macs is much better designed to handle USB 2.0, and hence even a 20" iMac can achieve 32 MBps. The backgound libraries and applications which need to be installed include: GNU's libtool, gawk, guile, pkgconfig, zlib, automake, swig, cppunit, fftw-3-single, sdcc (2.4.0 or 2.6.0, see NOTE below), python2.4 (or newer), py-numpy, py-wxpython, doxygen, boost, and libusb - as well as anything which they require. subversion is also required to access the GNU Radio repository. wget is convenient for downloading tarballs, though curl is already installed. These libraries and applications can be installed from source or binary, using Fink [ http://fink.sourceforge.net/ ] and/or MacPorts [ http://www.macports.org/ ]. The latter tends to be more up-to-date with respect to new releases, but also doesn't have a good GUI for dealing with modules - instead relying on a CLI. Both Fink and MacPorts offer thousands of ready-to-install libraries and applications. NOTE: For Intel-Macs, there is an issue involving some combination of XCode (2.3 or 2.4) and SDCC (2.4.0 or 2.6.0) which is currently unresolved, but results in the USRP hardware not being able to talk (via USB) with the USRP software. A work-around is to download a known working pre-compiled tarball of SDCC (2.4.0) and install that in place of the "usual" SDCC. This download is available from the same WWW area that this install guide is found: 1. download sdcc-2.4.0-i386.tar.bz2 2. as your admin account a. make sure SDCC is not already installed by MacPorts: sudo port uninstall sdcc b. from "/": sudo tar jxf ....../sdcc-2.4.0-i386.tar.bz2 will install the pre-compiled binary and related files in /opt/local . 3. make sure /opt/local/bin is in your shell environment's path: a. tcsh (add to ~/.tcshrc file): setenv PATH ${PATH}:/opt/local/bin b. bash (add to ~/.bashrc file): export PATH=$PATH:/opt/local/bin 4. check to make sure the correct version of SDCC is being used (first "rehash" if in "tcsh"): which sdcc should return "/opt/local/bin/sdcc". If not, then there is another SDCC installed somewhere which needs to be removed (or move /opt/local/bin to the head of PATH). Also, the command sdcc -v should return exactly (watching line wrap) "SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.4.0 (Jul 12 2006) (UNIX)". Once this version of SDCC is installed on your Intel-Mac, the USRP module of GR should compile and execute properly. Preliminaries ------ i) These directions are for MacOS X 10.4.[2-10] ("OSX"), with the XCode 2.[1-4] developer tools installed. The default Apple GCC & related developer tools are used where needed. These instructions assume that neither Fink < http://fink.sourceforge.net/ > nor MacPorts < http://www.macports.org/ > is installed, but it is probably OK if either or both are. This install uses the latter exclusively, as MacPorts seems to provide up-to-date package installs for all packages required by GNU Radio. Please note that if Fink and/or MacPorts are already installed, the scripts may or not work properly; many efforts have been made to ensure that all the correct environment variables are configured properly to ensure success no matter the current install base. ii) The current version of these install instructions does require you to edit basic text files (currently "~/.tcshrc" or "~/.bashrc" only). While teaching how to edit files is beyond the scope of these instructions, here are some great tutorials for some popular file editors: * Emacs < http://vertigo.hsrl.rutgers.edu/ug/emacs_tutorial.html > < http://www.psych.upenn.edu/cattell/edit.html > < http://www.reallylinux.com/docs/editors/editor.shtml#Emacs%20Editor > * VI < http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html > < http://docs.freebsd.org/44doc/usd/12.vi/paper.html > < http://www.reallylinux.com/docs/editors/editor.shtml#Vi%20Editor > * PICO < http://www.usd.edu/trio/tut/pico/ > < http://www.reallylinux.com/docs/editors/editor.shtml#Pico%20Editor > iii) Download, then add to or merge into your ~/.tcshrc file the text in the file, then "source ~/.tcshrc" to get those changes. < http://www.nd.edu/~mdickens/GNURadio/tcshrc.txt > Here is the equivalent script in bash (assumes just MacPorts, not Fink) [Thanks to Thomas Schmid.] ++++++++++++++++++++ export LDFLAGS="-L/opt/local/lib ${LDFLAGS}" export PATH=/opt/local/bin:${PATH} export MANPATH=/opt/local/share/man:${MANPATH} export INFOPATH=/opt/local/share/info:${INFOPATH} export CPATH=/opt/local/include:${CPATH} export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} p_v_f=`python -V 2>&1 | sed -e 's@Python @@g' | sed -e 's@\.@ @2' | awk '{print $1}'` export PYTHON_VERSION=$p_v_f export PYTHON_ROOT=`which python | sed -e 's@/bin/python@@g'` export PYTHONPATH=${PYTHON_ROOT}/lib/python${PYTHON_VERSION}/site-packages if [ ${PYTHON_ROOT} != "/usr/include" ]; then export PYTHONPATH=${PYTHONPATH}:/usr/local/lib/python${PYTHON_VERSION}/site-packages fi ++++++++++++++++++++ iv) Make a new directory somewhere (I use "/opt/MacPorts/", but it really doesn't matter where it is so long as you have sudo privileges), and download the following script there. < http://www.nd.edu/~mdickens/GNURadio/mp_inst.csh > Then execute: ++++++++++++++++++++ chmod a+x mp_inst.csh sudo ./mp_inst.csh source ~/.tcshrc ++++++++++++++++++++ and enter the admin password to get things going. Executing this script will take a few hours to overnight depending on your computer. v) A note regarding PYTHON and related: You can use Apple's default install (2.3.5), or install from MacPorts, Fink, or direct compile. GNU Radio by default puts it's python code into /usr/local/lib/python${PYTHON_VERSION}, but this can be changed in GR's 'configure' by changing the ${prefix}; this install won't mess up Apple's distro. Make sure to set PYTHONPATH correctly to point to this 'site-packages' directory if you change GR's ${prefix}. vi) A note regarding LIBTOOL: Both Apple and GNU have a program called "libtool". Some programs compile using one, and some with the other. The inputs are not generally cross-compatible. In order to avoid conflict, MacPorts renames this and its related program to "glibtool" and "glibtoolize". While the latter could be kept around without the "g", it's more consistent to leave it this way, and takes very little effort to change programs to use this new name. vii) A Note regarding "make": make has an option "-j" or "-j#" which allows for multiple parallel 'make's to be executed. At least on OSX 10.4.8 and XCode 2.4.1, "-j" by itself doesn't work properly, while "-j#" does. On multi-CPU systems, this can reduce make times substantially - when it works. A guideline for "#" is 1 more than the number of CPU's available (e.g. "3" if a dual CPU system - either dual-core or dual-processor). While using this option might speed up make times, it also sometimes creates compile errors due to unresolved dependencies. When this happens, just run "make" again (with or without the "-j#" option); if errors persist, then remove the "-j#" option to debug. If "make" works without "-j#" it will eventually work after enough iterations with the "-j#" option. viii) Notes regarding MacPorts: 0) Upgrading ([1 and/or 2] and [4 and/or 5] below) should be checked about once per month, to keep everything reasonably up to date. When upgrading Python, it is probably wisest to uninstall it first, since that port installs files outside of /opt. If uninstalling isn't an option, then the extra files can be removed via: sudo rm -rf /Applications/DarwinPorts/MacPython sudo rm -rf /Applications/MacPorts/MacPython 1) To upgrade MacPorts itself, use the following command: ++++++++++++++++++++ sudo port selfupdate ++++++++++++++++++++ This command also updates the 'dports tree', which is the list of available ports and info about them. 2) To update just the dports tree, use the following command: ++++++++++++++++++++ sudo port sync ++++++++++++++++++++ 3) After executing (1) or (2), to list outdated ports - ports for which a newer version is now available -, use the following command: ++++++++++++++++++++ port outdated ++++++++++++++++++++ 4) To try to upgrade all installed ports, use the following command: ++++++++++++++++++++ sudo port upgrade installed ++++++++++++++++++++ While executing this command, 'port' tries to deactivate old programs before installing and activating newer ones, but doesn't remove the older tarballs from an internal database. 5) Once can also explicitely tell 'port' what port(s) to upgrade. For example, to upgrade just "swig", use the following command: ++++++++++++++++++++ sudo port upgrade swig ++++++++++++++++++++ 6) To list all installed ports, whether active or not, use: ++++++++++++++++++++ port installed ++++++++++++++++++++ An easy way to find just those ports that are non-active is via: ++++++++++++++++++++ port installed | grep -v active ++++++++++++++++++++ 7) To remove older non-active ports, use the following script: ++++++++++++++++++++ tcsh set foo=`port installed | grep -v active | sed -e 1d` sudo port -f uninstall ${foo} sudo port clean --all ${foo} exit ++++++++++++++++++++ 8) To remove a specific port, e.g. "swig 1.3.28", after upgrading, e.g. to "swig 1.3.31": ++++++++++++++++++++ sudo port -f uninstall swig @1.3.28 sudo port clean --all swig @1.3.28 ++++++++++++++++++++ ===================== Getting GNU Radio ===================== Checkout the latest from SVN (1), or download the latest release (2). "SVN Checkout" is more likely to work with / compile under OSX, and thus the latter (downloading a release) is not recommended. 1) For SVN Checkout, execute the following script: ++++++++++++++++++++ svn co http://gnuradio.org/svn/gnuradio/trunk gnuradio ++++++++++++++++++++ NOTES ====== a) GNU Radio uses a single compile point to control the inclusion and exclusion of all modules. The use of this single compile point makes compiling and installing GNU Radio quite simple, but also requires knowledge on the user's part on how to select or deselect modules for / from compiling. Modules of interest to OSX currently include: gnuradio-core the 3.x core library gnuradio-examples examples for the 3.x tree usrp USRP frameworks gr-usrp glue that connects usrp into GNU Radio framework gr-wxgui wxPython based GUI tools including FFT and o'scope docs DocBook? source for articles, etc. gr-howto-write-a-block examples, Makefiles and article source gr-gsm-fr-vocoder GSM 06.10 13kbit/sec vocoder gr-audio-jack audio sink/source using JACK (see < http://jackit.sf.net/ >) gr-atsc ATSC television reception gr-audio-portaudio portaudio audio sink and source (in debugging; beta release) gr-audio-osx OSX-native audio, basic implementation (nothing fancy) b) To update any of the above modules with the latest version of those checked in, use the command: ++++++++++++++++++++ svn up ++++++++++++++++++++ If is omitted, then svn will try to update the files (and folders, and sub-folders) in the current directory. If you issue this command (omitting ) in the "gnuradio" directory, svn will try to updates all the modules which are currently installed. 2) Download latest release: Go to < ftp://ftp.gnu.org/gnu/gnuradio/ > and download "gnuradio-core" and, if optionally: "gr-howto-write-a-block". Move all of these downloaded files into a common directory (e.g. GNU Radio/3.X/ ) and untar (e.g. "tar zxf gnuradio-core-3.0.3.tar.gz") into a directory (henceforth called "gnuradio"). ===================== Compiling GNU Radio ===================== A.0) The "gnuradio" directory contains a number of directories, one for each module, possibly not all of which are used by OSX. Those which are required by OSX currently include the following, which would be installed in the following order: 1) "gnuradio-core" depends on glibtool, python, cppunit, swig, pkgconfig, fftw, and boost If using a USRP (hardware), 2 modules must be installed in in the following order: 2) "usrp" depends on SDCC and libusb, and requires automake 1.8.6 or newer 3) "gr-usrp" depends on USRP If using the wxWidgets GUI, install: 4) "gr-wxgui" depends on wxPython (et.al.) To use the GSM vocoder, install: 5) "gr-gsm-fr-vocoder" (for GMSK2 "voice" example) To get audio on OSX, install either: 6) "gr-audio-osx" requires GNU's LIBTOOL 1.20 or newer -or- 7) "gr-audio-portaudio", which requires the latest PORTAUDIO from their svn repository, e.g. using the following script: ++++++++++++++++++++ svn co https://www.portaudio.com/repos/portaudio/branches/v19-devel cd v19-devel ./configure make sudo make install +++++++++++++++++++ Note that (6) has precedence over (7) if both are installed. A) To compile and install the whole set of GNU Radio modules, use the following script from inside the "gnuradio" directory. Please note that it is not necessary to compile and install modules separately, but rather to instead use the single compile point for everything. ++++++++++++++++++++ sed -e 's@libtool@glibtool@g' bootstrap > bootstrap_mp sh bootstrap_mp ./configure make make check sudo make install rehash ++++++++++++++++++++ ====== NOTES: i) When running "bootstrap" (in this case, via "sh bootstrap_mp" to get the correct name for GNU's libtool ["glibtool"] as installed by MacPorts), it is not unusual to get warnings such as follows. These can safely be ignored. The warnings below are for example only; these are corrected by the "mp_inst.csh" script. ------- /opt/local/share/aclocal/smpeg.m4:13: warning: underquoted definition of AM_PATH_SMPEG run info '(automake)Extending aclocal' or see http://sources.redhat.com/automake/automake.html#Extending-aclocal ------- ii) An optional "make check" can also be executed before the "make install" command, as a sanity check on the functionality of GNU Radio. While this check usually works, just because it fails does not mean that GNU Radio will not function correctly (or at least well enough) once it is properly installed. iii) An optional "LIBTOOL=/opt/local/bin/glibtool" can be added as part of any "make", in order to use the MacPorts-provided version of GNU's libtool instead of the one created by the bootstrap / configure processing. In general, either should work OK; but sometimes one or the other works better. Start without this addition (as shown above), and if that doesn't work then try adding it. iv) One can now let "configure" install all compilable modules (the default), or one can select which modules to compile via "--disable-..." and "--enable-..." arguments for "configure". See < http://gnuradio.org/trac/wiki/BuildConfiguration > for more information. ====== B) Now go into '.../gr-build/gnuradio-examples/python/usrp' and try out some of those scripts, using the "pythonw" command to execute them (e.g. "pythonw usrp_oscope.py") if using the GUI, and "python" (or just executing the script directly, i.e. "./benchmark_usb.py") if not using the GUI.