Backport automake 2.60's AC_PROG_MKDIR_P so we can continue to support automake 2...
[debian/gnuradio] / configure.ac
1 dnl Copyright 2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
2 dnl 
3 dnl This file is part of GNU Radio
4 dnl 
5 dnl GNU Radio is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3, or (at your option)
8 dnl any later version.
9 dnl 
10 dnl GNU Radio is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl 
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with GNU Radio; see the file COPYING.  If not, write to
17 dnl the Free Software Foundation, Inc., 51 Franklin Street,
18 dnl Boston, MA 02110-1301, USA.
19
20 AC_INIT
21 AC_PREREQ(2.57)
22 AM_CONFIG_HEADER(config.h)
23 AC_CONFIG_SRCDIR([gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc])
24
25 AC_CANONICAL_BUILD
26 AC_CANONICAL_HOST
27 AC_CANONICAL_TARGET
28
29 AM_INIT_AUTOMAKE(gnuradio,3.2svn)
30
31 DEFINES=""
32 AC_SUBST(DEFINES)
33
34 dnl Remember if the user explicity set CXXFLAGS
35 if test -n "${CXXFLAGS}"; then
36   user_set_cxxflags=yes
37 fi
38
39 LF_CONFIGURE_CC
40 LF_CONFIGURE_CXX
41 GR_LIB64                dnl check for lib64 suffix after choosing compilers
42
43 dnl The three macros above are known to override CXXFLAGS if the user
44 dnl didn't specify them.  Though I'm sure somebody thought this was
45 dnl a good idea, it makes it hard to use other than -g -O2 when compiling
46 dnl selected files.  Thus we "undo" the damage here...
47 dnl 
48 dnl If the user specified CXXFLAGS, we use them.  Otherwise when compiling
49 dnl the output of swig use use -O1 if we're using g++.
50 dnl See Makefile.common for the rest of the magic.
51 if test "$user_set_cxxflags" != yes; then
52   autoconf_default_CXXFLAGS="$CXXFLAGS"
53   if test "$GXX" = yes; then
54     case "$host_cpu" in
55         powerpc*)
56            dnl "-O1" is broken on the PPC for some reason
57            dnl (at least as of g++ 4.1.1)
58            swig_CXXFLAGS="-g1 -O2 -Wno-strict-aliasing -Wno-parentheses"
59         ;;
60         *) 
61         swig_CXXFLAGS="-g -O1 -Wno-strict-aliasing -Wno-parentheses"
62         ;;
63     esac
64   fi
65 fi
66 AC_SUBST(autoconf_default_CXXFLAGS)
67 AC_SUBST(swig_CXXFLAGS)
68
69
70 dnl add ${prefix}/lib${gr_libdir_suffix}/pkgconfig to the head of the PKG_CONFIG_PATH
71 if test x${PKG_CONFIG_PATH} = x; then
72     PKG_CONFIG_PATH=${prefix}/lib${gr_libdir_suffix}/pkgconfig
73 else
74     PKG_CONFIG_PATH=${prefix}/lib${gr_libdir_suffix}/pkgconfig:${PKG_CONFIG_PATH}
75 fi
76 export PKG_CONFIG_PATH
77
78
79 GR_SET_GPROF
80 GR_SET_PROF
81 AM_PROG_AS
82 AC_PROG_LN_S
83 AC_PROG_MAKE_SET
84 AC_PROG_INSTALL
85
86 # AC_PROG_MKDIR_P
87 # is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
88 # Remove this macro when we can assume autoconf >= 2.60.
89 m4_ifdef([AC_PROG_MKDIR_P], [], [
90   AC_DEFUN([AC_PROG_MKDIR_P],
91     [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
92      MKDIR_P='$(mkdir_p)'
93      AC_SUBST([MKDIR_P])])
94 ])
95 AC_PROG_MKDIR_P
96
97 AC_PATH_PROG([RM_PROG], [rm])
98
99 AC_LIBTOOL_WIN32_DLL
100 dnl AC_DISABLE_SHARED   dnl don't build shared libraries
101 AC_ENABLE_SHARED        dnl do build shared libraries
102 AC_DISABLE_STATIC       dnl don't build static libraries
103 m4_ifdef([LT_INIT],[LT_INIT],[AC_PROG_LIBTOOL])
104 GR_FORTRAN
105
106 GR_NO_UNDEFINED         dnl do we need the -no-undefined linker flag
107 GR_SCRIPTING
108
109 AC_CHECK_PROG([XMLTO],[xmlto],[yes],[])
110 AM_CONDITIONAL([HAS_XMLTO], [test x$XMLTO = xyes])
111
112 dnl Checks for libraries.
113 AC_CHECK_LIB(socket,socket)
114
115 dnl check for omnithreads (will soon be removed)
116 GR_OMNITHREAD
117 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
118 CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
119
120 dnl Set the c++ compiler that we use for the build system when cross compiling
121 if test x$CXX_FOR_BUILD = x
122 then
123   if test x$cross_compiling = xno; then
124     CXX_FOR_BUILD=${CXX}
125   else
126     CXX_FOR_BUILD=g++
127   fi
128 fi
129 AC_SUBST(CXX_FOR_BUILD)
130
131 dnl Check for SysV shm (mandatory)
132 dnl FIXME this is no longer mandatory.  Check the macro.
133 GR_SYSV_SHM
134
135 dnl Checks for header files.
136 AC_HEADER_STDC
137 AC_HEADER_SYS_WAIT
138 AC_CHECK_HEADERS(fcntl.h limits.h strings.h time.h sys/ioctl.h sys/time.h unistd.h)
139 AC_CHECK_HEADERS(linux/ppdev.h dev/ppbus/ppi.h sys/mman.h sys/select.h sys/types.h)
140 AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/syscall.h malloc.h)
141 AC_CHECK_HEADERS(netinet/in.h)
142 AC_CHECK_HEADERS(windows.h)
143 AC_CHECK_HEADERS(vec_types.h)
144
145 dnl Checks for typedefs, structures, and compiler characteristics.
146 AC_C_CONST
147 AC_C_INLINE
148 AC_TYPE_SIZE_T
149 AC_HEADER_TIME
150 AC_C_BIGENDIAN([GR_ARCH_BIGENDIAN=1],[GR_ARCH_BIGENDIAN=0])
151 AC_SUBST(GR_ARCH_BIGENDIAN)
152 AC_STRUCT_TM
153
154 dnl Checks for library functions.
155 AC_FUNC_ALLOCA
156 GR_CHECK_MEMALIGN
157 AC_FUNC_SETVBUF_REVERSED
158 AC_FUNC_VPRINTF
159 AC_CHECK_FUNCS([mmap select socket strcspn strerror strspn getpagesize sysconf])
160 AC_CHECK_FUNCS([snprintf gettimeofday nanosleep sched_setscheduler])
161 AC_CHECK_FUNCS([modf sqrt sigaction sigprocmask pthread_sigmask])
162 AC_CHECK_FUNCS([sched_setaffinity])
163
164 AC_CHECK_LIB(m, sincos, [AC_DEFINE([HAVE_SINCOS],[1],[Define to 1 if your system has `sincos'.])])
165 AC_CHECK_LIB(m, sincosf,[AC_DEFINE([HAVE_SINCOSF],[1],[Define to 1 if your system has `sincosf'.])])
166 AC_CHECK_LIB(m, sinf, [AC_DEFINE([HAVE_SINF],[1],[Define to 1 if your system has `sinf'.])])
167 AC_CHECK_LIB(m, cosf, [AC_DEFINE([HAVE_COSF],[1],[Define to 1 if your system has `cosf'.])])
168 AC_CHECK_LIB(m, trunc, [AC_DEFINE([HAVE_TRUNC],[1],[Define to 1 if your system has `trunc'.])])
169 AC_CHECK_LIB(m, exp10, [AC_DEFINE([HAVE_EXP10],[1],[Define to 1 if your system has 'exp10'.])])
170 AC_CHECK_LIB(m, log2, [AC_DEFINE([HAVE_LOG2],[1],[Define to 1 if your system has 'log2'.])])
171 #AC_FUNC_MKTIME
172
173 AH_BOTTOM([
174 #ifndef HAVE_TRUNC
175 #include <math.h>
176 inline static double trunc(double x)
177 {
178   return x >= 0 ? floor(x) : ceil(x);
179 }
180 #endif
181
182 #ifndef HAVE_EXP10
183 #include <math.h>
184 inline static double exp10(double x)
185 {
186   return pow(10.0, x);
187 }
188 #endif
189
190 #ifdef HAVE_WINDOWS_H
191 #define NOMINMAX
192 #endif
193 ])
194
195 GR_CHECK_SHM_OPEN
196 GR_LIBGNURADIO_CORE_EXTRA_LDFLAGS
197 GR_CHECK_CREATEFILEMAPPING
198
199 dnl Check for Mingw support
200 GR_PWIN32
201
202 dnl Do we have "dot", part of the graphviz package from AT&T?
203 dnl Doxgen will use it to draw pretty diagrams ;-)
204 AC_CHECK_PROG(HAVE_DOT, [dot],[YES],[NO])
205
206 PKG_CHECK_MODULES(FFTW3F, fftw3f >= 3.0)
207 AC_SUBST(FFTW3F_LIBS)
208
209 dnl conditional build stuff
210 GR_CHECK_DOXYGEN
211 GR_SET_MD_CPU
212
213 dnl Define where to look for cppunit includes and libs
214 dnl sets CPPUNIT_CFLAGS and CPPUNIT_LIBS
215 dnl Try using pkg-config first, then fall back to cppunit-config.
216 PKG_CHECK_EXISTS(cppunit,
217   [PKG_CHECK_MODULES(CPPUNIT, cppunit >= 1.9.14)],
218   [AM_PATH_CPPUNIT([1.9.14],[],
219                 [AC_MSG_ERROR([GNU Radio requires cppunit.  Stop])])])
220
221 CPPUNIT_INCLUDES=$CPPUNIT_CFLAGS
222 AC_SUBST(CPPUNIT_INCLUDES)
223
224 dnl see if GUILE is installed
225 AC_PATH_PROG(GUILE,guile)
226
227 dnl
228 dnl We require the boost headers, thread lib and date_time lib.
229 dnl AX_BOOST_BASE finds the headers and the lib dir (-L<foo>)
230 dnl
231 dnl calls AC_SUBST(BOOST_CPPFLAGS), AC_SUBST(BOOST_LDFLAGS) and defines HAVE_BOOST
232 AX_BOOST_BASE([1.35])
233
234 dnl calls AC_SUBST(BOOST_THREAD_LIB), AC_SUBST(BOOST_CXXFLAGS) and defines HAVE_BOOST_THREAD
235 AX_BOOST_THREAD
236 CXXFLAGS="$CXXFLAGS $BOOST_CXXFLAGS"       dnl often picks up a -pthread or something similar
237 CFLAGS="$CFLAGS $BOOST_CXXFLAGS"           dnl often picks up a -pthread or something similar
238
239 dnl
240 dnl all the rest of these call AC_SUBST(BOOST_<foo>_LIB) and define HAVE_BOOST_<foo>
241 dnl
242 AX_BOOST_DATE_TIME
243 dnl AX_BOOST_FILESYSTEM
244 dnl AX_BOOST_IOSTREAMS
245 AX_BOOST_PROGRAM_OPTIONS
246 dnl AX_BOOST_REGEX
247 dnl AX_BOOST_SERIALIZATION
248 dnl AX_BOOST_SIGNALS
249 dnl AX_BOOST_SYSTEM
250 dnl AX_BOOST_TEST_EXEC_MONITOR
251 dnl AX_BOOST_UNIT_TEST_FRAMEWORK
252 dnl AX_BOOST_WSERIALIZATION
253
254
255 dnl If this is being done from a subversion tree, create variables
256 GR_SUBVERSION
257
258 dnl Component specific configuration
259 dnl The order of the GR_ macros determines the order of compilation
260 dnl For -any- checks on $enable_all_components
261 dnl use the following guidelines:
262 dnl   yes : --enable-all-components was specified, so error out if any
263 dnl         components do not pass configuration checks.
264 dnl   no  : --disable-all-components was specified, so try to build the
265 dnl         --enable'd components, and error out if any do not pass
266 dnl         configuration checks.
267 dnl   ""  : this option was not specified on the command line; try to
268 dnl         build all components that are not --with'd, but don't
269 dnl         error out if any component does not pass configuration checks.
270 dnl
271 dnl For each --enable-foo component, if that flag is not specified on
272 dnl the command line, the related variable $enable_foo will be set to
273 dnl $enable_all_components .
274
275 AC_ARG_ENABLE(
276     [all-components],
277     [  --enable-all-components Build all configurable components (default), or stop on failed dependencies]
278 )
279
280 build_dirs="config"
281 GRC_GRUEL                       dnl must come first
282 GRC_OMNITHREAD                  dnl must come before gnuradio-core and mblock
283 GRC_GCELL
284 GRC_GNURADIO_CORE
285 GRC_PMT
286 GRC_MBLOCK                      dnl this must come after GRC_PMT
287 GRC_USRP
288 GRC_USRP2
289 GRC_GR_USRP                     dnl this must come after GRC_USRP
290 GRC_GR_USRP2
291 GRC_GR_GCELL                    dnl this must come after GRC_GCELL and GRC_GNURADIO_CORE
292 GRC_GR_MSDD6000 
293 GRC_GR_AUDIO_ALSA
294 GRC_GR_AUDIO_JACK
295 GRC_GR_AUDIO_OSS
296 GRC_GR_AUDIO_OSX
297 GRC_GR_AUDIO_PORTAUDIO
298 GRC_GR_AUDIO_WINDOWS
299 GRC_GR_ATSC
300 GRC_GR_COMEDI
301 GRC_GR_CVSD_VOCODER
302 GRC_GR_GPIO
303 GRC_GR_GSM_FR_VOCODER
304 GRC_GR_PAGER
305 GRC_GR_RADAR_MONO
306 GRC_GR_RADIO_ASTRONOMY
307 GRC_GR_TRELLIS
308 GRC_GR_VIDEO_SDL
309 GRC_GR_WXGUI
310 GRC_GR_QTGUI
311 GRC_GR_SOUNDER                  dnl this must come after GRC_USRP
312 GRC_GR_UTILS                    dnl this must come after GRC_GR_WXGUI
313 GRC_GNURADIO_EXAMPLES           dnl must come after all GRC_GR_*
314 GRC_GRC
315
316 # Each component is now either to be built, was skipped, will be
317 # included from pre-installed libraries and includes, or failed
318 # dependencies.
319 AC_SUBST([build_dirs], [$build_dirs])
320 AC_SUBST([skipped_dirs], [$skipped_dirs])
321 AC_SUBST([with_dirs], [$with_dirs])
322
323 # fix for older autotools that don't define these by default
324 AC_SUBST(abs_top_srcdir)
325 AC_SUBST(abs_top_builddir)
326 AC_SUBST(MKDIR_P)
327
328 # 'with' variables - the pre-installed libraries, includes, and paths
329 # - must always come last in the lists, so they require special
330 # treatment.
331 AC_SUBST(with_INCLUDES)
332 AC_SUBST(with_SWIG_INCLUDES)
333 AC_SUBST(with_PYDIRPATH)
334 AC_SUBST(with_SWIGDIRPATH)
335 AC_SUBST(with_LIBDIRPATH)
336
337 # Local files tweaked by AC
338 AC_CONFIG_FILES([\
339     Makefile \
340     run_tests.sh \
341     config/Makefile \
342 ])
343
344 dnl run_tests.sh is created from run_tests.sh.in .  Make it executable.
345 AC_CONFIG_COMMANDS([run_tests_build], [chmod +x run_tests.sh])
346
347 dnl Enable warnings as the last thing before generating output, since
348 dnl this may add -Werror to CFLAGS which can cause various configure
349 dnl checks to fail.
350 LF_SET_WARNINGS
351
352 AC_OUTPUT
353
354 echo
355 echo "*********************************************************************"
356 echo The following GNU Radio components have been successfully configured:
357 echo 
358 for dir in $build_dirs
359 do
360     echo $dir
361 done
362 echo
363 echo You my now run the 'make' command to build these components.
364 echo
365 if test "$skipped_dirs" != ""; then
366     echo "*********************************************************************"
367     echo The following components were skipped either because you asked not
368     echo to build them or they didn\'t pass configuration checks:
369     echo
370     for dir in $skipped_dirs
371     do
372         echo $dir
373     done
374     echo
375     echo These components will not be built.
376     echo
377 fi
378 if test "$with_dirs" != ""; then
379     echo "*********************************************************************"
380     echo The following components will be included from pre-installed
381     echo libraries and includes:
382     echo
383     for dir in $with_dirs
384     do
385         echo $dir
386     done
387     echo
388     echo These components will not be built.
389     echo
390 fi