Merged r10554:10595 from michaelld/am_swig_4 into trunk. Major overhaul of SWIG...
[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   AC_CANONICAL_BUILD
35   AC_CANONICAL_HOST
36   AC_CANONICAL_TARGET
37
38   AM_INIT_AUTOMAKE
39
40   dnl Remember if the user explicity set CXXFLAGS
41   if test -n "${CXXFLAGS}"; then
42     user_set_cxxflags=yes
43   fi
44
45   LF_CONFIGURE_CC
46   LF_CONFIGURE_CXX
47   GR_LIB64              dnl check for lib64 suffix after choosing compilers
48
49   dnl The three macros above are known to override CXXFLAGS if the user
50   dnl didn't specify them.  Though I'm sure somebody thought this was
51   dnl a good idea, it makes it hard to use other than -g -O2 when compiling
52   dnl selected files.  Thus we "undo" the damage here...
53   dnl 
54   dnl If the user specified CXXFLAGS, we use them.  Otherwise when compiling
55   dnl the output of swig use use -O1 if we're using g++.
56   dnl See Makefile.common for the rest of the magic.
57   if test "$user_set_cxxflags" != yes; then
58     autoconf_default_CXXFLAGS="$CXXFLAGS"
59     if test "$GXX" = yes; then
60       case "$host_cpu" in
61         powerpc*)
62            dnl "-O1" is broken on the PPC for some reason
63            dnl (at least as of g++ 4.1.1)
64            swig_CXXFLAGS="-g1 -O2 -Wno-strict-aliasing -Wno-parentheses"
65         ;;
66         *) 
67         swig_CXXFLAGS="-g -O1 -Wno-strict-aliasing -Wno-parentheses"
68         ;;
69       esac
70     fi
71   fi
72   AC_SUBST(autoconf_default_CXXFLAGS)
73   AC_SUBST(swig_CXXFLAGS)
74
75   dnl add ${prefix}/lib${gr_libdir_suffix}/pkgconfig to the head of the PKG_CONFIG_PATH
76   if test x${PKG_CONFIG_PATH} = x; then
77       PKG_CONFIG_PATH=${prefix}/lib${gr_libdir_suffix}/pkgconfig
78   else
79       PKG_CONFIG_PATH=${prefix}/lib${gr_libdir_suffix}/pkgconfig:${PKG_CONFIG_PATH}
80   fi
81   export PKG_CONFIG_PATH
82
83   LF_SET_WARNINGS
84   GR_SET_GPROF
85   GR_SET_PROF
86   AM_PROG_AS
87   AC_PROG_LN_S
88   AC_PROG_MAKE_SET
89   AC_PROG_INSTALL
90   AC_PATH_PROG([RM_PROG], [rm])
91
92   AC_LIBTOOL_WIN32_DLL
93   AC_ENABLE_SHARED      dnl do build shared libraries
94   AC_DISABLE_STATIC     dnl don't build static libraries
95   m4_ifdef([LT_INIT],[LT_INIT],[AC_PROG_LIBTOOL])
96   dnl GR_FORTRAN
97
98   GR_NO_UNDEFINED       dnl do we need the -no-undefined linker flag
99   GR_SCRIPTING          dnl Locate python, SWIG, etc
100
101   dnl Checks for header files.
102   AC_HEADER_STDC
103
104   dnl Checks for typedefs, structures, and compiler characteristics.
105   AC_C_CONST
106   AC_C_INLINE
107   AC_TYPE_SIZE_T
108   AC_HEADER_TIME
109   AC_C_BIGENDIAN
110
111   dnl Check for Mingw support
112   GR_PWIN32
113
114   AC_CHECK_PROG([XMLTO],[xmlto],[yes],[])
115   AM_CONDITIONAL([HAS_XMLTO], [test x$XMLTO = xyes])
116
117   PKG_CHECK_MODULES(GNURADIO_CORE, gnuradio-core >= 3)
118   LIBS="$LIBS $GNURADIO_CORE_LIBS"
119 ])