Script to build and install GNU Radio one component at a time. Read
[debian/gnuradio] / README.components
1 #!/bin/sh
2  
3 # $Id:$
4
5 # Copyright 2008 Free Software Foundation.
6 #
7 # This script provides a way to build GNU Radio modules individually,
8 # and both serves as an example of using the component build system
9 # and provides a way to test that build system.  This script is
10 # intended to be broadly portable; be careful when modifying not to
11 # cause problems on systems that place dependencies in other than /usr
12 #
13 # Besides GNU Radio dependencies, this program requires sudo, with a
14 # timer long enough to build each module (or no password requirement).
15 #
16 # Read the script thoroughly before running it; it will *remove*
17 # /usr/gnuradio and repopulate it.
18
19 set -x
20
21 PREFIX=/usr/gnuradio
22
23 echo -n "README.components START "; date
24
25 # This file provides an example of how to build GNU Radio under pkgsrc.
26
27 # Avoid using rm -rf with $PREFIX, which could be /.  Make a backup of
28 # the old prefix.
29 sudo rm -rf $PREFIX.old
30 sudo mv $PREFIX $PREFIX.old
31 rm -rf BUILD.*
32
33 # Bootstrap just once, rather than once per module.
34 ./bootstrap
35
36 # Determine where prereqs come from.
37 export LDFLAGS=
38 export CPPFLAGS=
39 export PKG_CONFIG_PATH=
40 if [ -d /usr/pkg ]; then
41     # pkgsrc
42     LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
43     CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
44
45     # pkg-config is from pkgsrc, so already knows about /usr/pkg/lib/pkgconfig
46     PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX/lib/pkgconfig"
47 fi
48
49 echo LDFLAGS ,$LDFLAGS,
50 echo CPPFLAGS ,$CPPFLAGS,
51 echo PKG_CONFIG_PATH ,$PKG_CONFIG_PATH,
52
53 # Determine number of cpus and thus how many jobs to run.
54 ncpus=1
55 case x`uname` in
56     xNetBSD)
57         ncpus=`sysctl hw.ncpu|awk '{print $3}'`
58         ;;
59 esac
60 jflag=-j`expr $ncpus \* 2`
61
62 # These are currently ignored.
63 CONF_DOC_ARGS="
64 --enable-doxygen
65 --enable-dot
66 --enable-latex-docs
67 "
68 CONF_DISABLE_ALL="--disable-all-components"
69
70 # We use % instead of ' ' to be able to iterate with /bin/sh's for.
71 CONF_ENABLE_ARGS="
72 --enable-omnithread
73 --with-omnithread%--enable-pmt
74 --with-omnithread%--with-pmt%--enable-mblock
75 --with-omnithread%--enable-gnuradio-core
76 --with-omnithread%--enable-usrp
77 --with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--with-usrp%--enable-gr-usrp
78 --with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-audio-oss
79 --with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-atsc
80 --with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-wxgui
81 --with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-utils
82 --with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gnuradio-examples
83 "
84
85 # These are not used, but a list of what the script does not build.
86 CONF_DISABLE_ARGS="
87 --enable-gr-comedi
88 --enable-gr-cvsd-vocoder
89 --enable-gr-gpio
90 --enable-gr-gsm-fr-vocoder
91 --enable-gr-pager
92 --enable-gr-radar-mono
93 --enable-gr-radio-astronomy
94 --enable-gr-trellis
95 --enable-gr-video-sdl
96 --enable-gr-sounder
97 "
98
99 # start at 1 to reserve 0 for "./README.components > BUILD.000 2>&1 &" 
100 seq=1
101 for arg in $CONF_ENABLE_ARGS; do
102
103     # Convert sequence numbers and arguments to usable values.
104     seqprint=`printf "%03d" $seq`
105     argspace=`echo $arg | sed -e 's/%/ /g'`
106
107     echo "BUILDING WITH $argspace"
108
109     (
110     # configure with just one module
111     ./configure --prefix=$PREFIX $CONF_DISABLE_ALL $argspace &&
112
113     # build
114     make $jflag &&
115
116     # install
117     sudo make install &&
118
119     echo "SUCCEEDED $argspace"
120
121     ) > BUILD.$seqprint.$arg 2>&1
122
123     seq=`expr $seq + 1`
124 done
125
126 echo -n "README.components FINISH "; date