switch source package format to 3.0 quilt
[debian/gnuradio] / gr-howto-write-a-block / config / gr_standalone.m4
1 dnl
2 dnl Copyright 2008,2009 Free Software Foundation, Inc.
3 dnl 
4 dnl This file is part of GNU Radio
5 dnl 
6 dnl GNU Radio is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3, or (at your option)
9 dnl any later version.
10 dnl 
11 dnl GNU Radio is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 dnl GNU General Public License for more details.
15 dnl 
16 dnl You should have received a copy of the GNU General Public License along
17 dnl with this program; if not, write to the Free Software Foundation, Inc.,
18 dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 dnl
20
21 dnl
22 dnl GR_STANDALONE([package],[version])
23 dnl
24 dnl Handles the bulk of the configure.ac work for an out-of-tree build
25 dnl
26 dnl N.B., this is an m4_define because if it were an AC_DEFUN it would
27 dnl get called too late to be useful.
28
29 m4_define([GR_STANDALONE],
30 [
31   AC_CONFIG_SRCDIR([config/gr_standalone.m4])
32   AM_CONFIG_HEADER(config.h)
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   dnl add ${prefix}/lib${gr_libdir_suffix}/pkgconfig to the head of the PKG_CONFIG_PATH
70   if test x${PKG_CONFIG_PATH} = x; then
71       PKG_CONFIG_PATH=${prefix}/lib${gr_libdir_suffix}/pkgconfig
72   else
73       PKG_CONFIG_PATH=${prefix}/lib${gr_libdir_suffix}/pkgconfig:${PKG_CONFIG_PATH}
74   fi
75   export PKG_CONFIG_PATH
76
77   LF_SET_WARNINGS
78   GR_SET_GPROF
79   GR_SET_PROF
80   AM_PROG_AS
81   AC_PROG_LN_S
82   AC_PROG_MAKE_SET
83   AC_PROG_INSTALL
84   AC_PATH_PROG([RM_PROG], [rm])
85
86   AC_LIBTOOL_WIN32_DLL
87   AC_ENABLE_SHARED      dnl do build shared libraries
88   AC_DISABLE_STATIC     dnl don't build static libraries
89   m4_ifdef([LT_INIT],[LT_INIT],[AC_PROG_LIBTOOL])
90   dnl GR_FORTRAN
91
92   GR_NO_UNDEFINED       dnl do we need the -no-undefined linker flag
93   GR_SCRIPTING          dnl Locate python, SWIG, etc
94
95   dnl Checks for header files.
96   AC_HEADER_STDC
97
98   dnl Checks for typedefs, structures, and compiler characteristics.
99   AC_C_CONST
100   AC_C_INLINE
101   AC_TYPE_SIZE_T
102   AC_HEADER_TIME
103   AC_C_BIGENDIAN
104
105   dnl Check for Mingw support
106   GR_PWIN32
107
108   AC_CHECK_PROG([XMLTO],[xmlto],[yes],[])
109   AM_CONDITIONAL([HAS_XMLTO], [test x$XMLTO = xyes])
110
111   PKG_CHECK_MODULES(GNURADIO_CORE, gnuradio-core >= 3)
112   LIBS="$LIBS $GNURADIO_CORE_LIBS"
113
114   dnl Allow user to choose whether to generate SWIG/Python 
115   dnl Default is enabled
116   AC_ARG_ENABLE([python],
117     [AS_HELP_STRING([--enable-python],
118       [generate SWIG/Python components (default is yes)])],
119     [case "${enableval}" in
120        yes) enable_python=yes ;;
121        no) enable_python=no ;;
122        *) AC_MSG_ERROR([bad value ${enableval} for --enable-python]) ;;
123      esac],
124     [enable_python=yes]  
125   )
126   AM_CONDITIONAL([PYTHON], [test x$enable_python = xyes])
127
128   dnl Define where to look for cppunit includes and libs
129   dnl sets CPPUNIT_CFLAGS and CPPUNIT_LIBS
130   dnl Try using pkg-config first, then fall back to cppunit-config.
131   PKG_CHECK_EXISTS(cppunit,
132     [PKG_CHECK_MODULES(CPPUNIT, cppunit >= 1.9.14)],
133     [AM_PATH_CPPUNIT([1.9.14],[],
134                      [AC_MSG_ERROR([GNU Radio requires cppunit.  Stop])])])
135 ])