Quotes around otherwise ambiguous (underline containing) name
[geos.git] / macros / ac_pkg_swig.m4
blobcda81665bd007f72dd715af3a29db123253ef5b2
1 dnl @synopsis AC_PROG_SWIG([major.minor.micro])
2 dnl
3 dnl This macro searches for a SWIG installation on your system. If
4 dnl found you should call SWIG via $(SWIG). You can use the optional
5 dnl first argument to check if the version of the available SWIG is
6 dnl greater than or equal to the value of the argument. It should have
7 dnl the format: N[.N[.N]] (N is a number between 0 and 999. Only the
8 dnl first N is mandatory.)
9 dnl
10 dnl If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks
11 dnl that the swig package is this version number or higher.
12 dnl
13 dnl In configure.in, use as:
14 dnl
15 dnl             AC_PROG_SWIG(1.3.17)
16 dnl             SWIG_ENABLE_CXX
17 dnl             SWIG_MULTI_MODULE_SUPPORT
18 dnl             SWIG_PYTHON
19 dnl
20 dnl @category InstalledPackages
21 dnl @author Sebastian Huber <sebastian-huber@web.de>
22 dnl @author Alan W. Irwin <irwin@beluga.phys.uvic.ca>
23 dnl @author Rafael Laboissiere <rafael@laboissiere.net>
24 dnl @author Andrew Collier <abcollier@yahoo.com>
25 dnl @version 2004-09-20
26 dnl @license GPLWithACException
27 dnl
28 dnl Fixed by Sandro Santilli to consider 2.0.0 > 1.3.37 (2010-06-15)
29 dnl
31 AC_DEFUN([AC_PROG_SWIG],[
32         AC_PATH_PROG([SWIG],[swig])
33         if test -z "$SWIG" ; then
34                 AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
35                 SWIG=''
36         elif test -n "$1" ; then
37                 AC_MSG_CHECKING([for SWIG version])
38                 [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
39                 AC_MSG_RESULT([$swig_version])
40                 if test -n "$swig_version" ; then
41                         # Calculate the required version number components
42                         [required=$1]
43                         [required_major=`echo $required | sed 's/[^0-9].*//'`]
44                         if test -z "$required_major" ; then
45                                 [required_major=0]
46                         fi
47                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
48                         [required_minor=`echo $required | sed 's/[^0-9].*//'`]
49                         if test -z "$required_minor" ; then
50                                 [required_minor=0]
51                         fi
52                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
53                         [required_patch=`echo $required | sed 's/[^0-9].*//'`]
54                         if test -z "$required_patch" ; then
55                                 [required_patch=0]
56                         fi
57                         # Calculate the available version number components
58                         [available=$swig_version]
59                         [available_major=`echo $available | sed 's/[^0-9].*//'`]
60                         if test -z "$available_major" ; then
61                                 [available_major=0]
62                         fi
63                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
64                         [available_minor=`echo $available | sed 's/[^0-9].*//'`]
65                         if test -z "$available_minor" ; then
66                                 [available_minor=0]
67                         fi
68                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
69                         [available_patch=`echo $available | sed 's/[^0-9].*//'`]
70                         if test -z "$available_patch" ; then
71                                 [available_patch=0]
72                         fi
73                         [required_full=`printf %2.2d%2.2d%2.2d%2.2d $required_major $required_minor $required_patch]`
74                         [available_full=`printf %2.2d%2.2d%2.2d%2.2d $available_major $available_minor $available_patch]`
75                         if test $available_full -lt $required_full; then
76                                 AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version.  You should look at http://www.swig.org])
77                                 SWIG=''
78                         else
79                                 AC_MSG_NOTICE([SWIG executable is '$SWIG'])
80                                 SWIG_LIB=`$SWIG -swiglib | sed -e :a -e N -e 's/\n/ /' -e ta`
81                                 AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB'])
82                         fi
83                 else
84                         AC_MSG_WARN([cannot determine SWIG version])
85                         SWIG=''
86                 fi
87         fi
88         AC_SUBST([SWIG_LIB])
91 # SWIG_ENABLE_CXX()
93 # Enable SWIG C++ support.  This affects all invocations of $(SWIG).
94 AC_DEFUN([SWIG_ENABLE_CXX],[
95         AC_REQUIRE([AC_PROG_SWIG])
96         AC_REQUIRE([AC_PROG_CXX])
97         SWIG="$SWIG -c++"
100 # SWIG_MULTI_MODULE_SUPPORT()
102 # Enable support for multiple modules.  This effects all invocations
103 # of $(SWIG).  You have to link all generated modules against the
104 # appropriate SWIG runtime library.  If you want to build Python
105 # modules for example, use the SWIG_PYTHON() macro and link the
106 # modules against $(SWIG_PYTHON_LIBS).
108 AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[
109         AC_REQUIRE([AC_PROG_SWIG])
110         SWIG="$SWIG -noruntime"
113 # SWIG_PYTHON([use-shadow-classes = {no, yes}])
115 # Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS),
116 # and $(SWIG_PYTHON_OPT) output variables.
118 # $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate
119 # code for Python.  Shadow classes are enabled unless the value of the
120 # optional first argument is exactly 'no'.  If you need multi module
121 # support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use
122 # $(SWIG_PYTHON_LIBS) to link against the appropriate library.  It
123 # contains the SWIG Python runtime library that is needed by the type
124 # check system for example.
125 AC_DEFUN([SWIG_PYTHON],[
126         AC_REQUIRE([AC_PROG_SWIG])
127         AC_REQUIRE([AC_PYTHON_DEVEL])
128         test "x$1" != "xno" || swig_shadow=" -noproxy"
129         AC_SUBST([SWIG_PYTHON_OPT],["-python -modern$swig_shadow"])
130         AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS])
134 dnl @synopsis AC_LIB_WAD
136 dnl This macro searches for installed WAD library.
138 AC_DEFUN([AC_LIB_WAD],
140         AC_REQUIRE([AC_PYTHON_DEVEL])
141         AC_ARG_ENABLE(wad,
142         AC_HELP_STRING([--enable-wad], [enable wad module]),
143         [
144                 case "${enableval}" in
145                         no)     ;;
146                         *)      if test "x${enableval}" = xyes;
147                                 then
148                                         check_wad="yes"
149                                 fi ;;
150                 esac
151         ], [])
153         if test -n "$check_wad";
154         then
155                 AC_CHECK_LIB(wadpy, _init, [WADPY=-lwadpy], [], $PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS)
156                 AC_SUBST(WADPY)
157         fi