1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html
3 # ===========================================================================
7 # AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found])
11 # This macro searches for a SWIG installation on your system. If found,
12 # then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is
13 # found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd.
15 # You can use the optional first argument to check if the version of the
16 # available SWIG is greater than or equal to the value of the argument. It
17 # should have the format: N[.N[.N]] (N is a number between 0 and 999. Only
18 # the first N is mandatory.) If the version argument is given (e.g.
19 # 1.3.17), AX_PKG_SWIG checks that the swig package is this version number
22 # As usual, action-if-found is executed if SWIG is found, otherwise
23 # action-if-not-found is executed.
25 # In configure.in, use as:
27 # AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ])
29 # AX_SWIG_MULTI_MODULE_SUPPORT
34 # Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
35 # Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
36 # Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
37 # Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
39 # This program is free software; you can redistribute it and/or modify it
40 # under the terms of the GNU General Public License as published by the
41 # Free Software Foundation; either version 2 of the License, or (at your
42 # option) any later version.
44 # This program is distributed in the hope that it will be useful, but
45 # WITHOUT ANY WARRANTY; without even the implied warranty of
46 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
47 # Public License for more details.
49 # You should have received a copy of the GNU General Public License along
50 # with this program. If not, see <http://www.gnu.org/licenses/>.
52 # As a special exception, the respective Autoconf Macro's copyright owner
53 # gives unlimited permission to copy, distribute and modify the configure
54 # scripts that are the output of Autoconf when processing the Macro. You
55 # need not follow the terms of the GNU General Public License when using
56 # or distributing such scripts, even though portions of the text of the
57 # Macro appear in them. The GNU General Public License (GPL) does govern
58 # all other use of the material that constitutes the Autoconf Macro.
60 # This special exception to the GPL applies to versions of the Autoconf
61 # Macro released by the Autoconf Archive. When you make and distribute a
62 # modified version of the Autoconf Macro, you may extend this special
63 # exception to the GPL to apply to your modified version as well.
67 AC_DEFUN([AX_PKG_SWIG],[
68 AC_PATH_PROG([SWIG],[swig])
69 if test -z "$SWIG" ; then
70 m4_ifval([$3],[$3],[:])
71 elif test -n "$1" ; then
72 AC_MSG_CHECKING([SWIG version])
73 [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'`]
74 AC_MSG_RESULT([$swig_version])
75 if test -n "$swig_version" ; then
76 # Calculate the required version number components
78 [required_major=`echo $required | sed 's/[^0-9].*//'`]
79 if test -z "$required_major" ; then
82 [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
83 [required_minor=`echo $required | sed 's/[^0-9].*//'`]
84 if test -z "$required_minor" ; then
87 [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
88 [required_patch=`echo $required | sed 's/[^0-9].*//'`]
89 if test -z "$required_patch" ; then
92 # Calculate the available version number components
93 [available=$swig_version]
94 [available_major=`echo $available | sed 's/[^0-9].*//'`]
95 if test -z "$available_major" ; then
98 [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
99 [available_minor=`echo $available | sed 's/[^0-9].*//'`]
100 if test -z "$available_minor" ; then
103 [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
104 [available_patch=`echo $available | sed 's/[^0-9].*//'`]
105 if test -z "$available_patch" ; then
108 # Convert the version tuple into a single number for easier comparison.
109 # Using base 100 should be safe since SWIG internally uses BCD values
110 # to encode its version number.
111 required_swig_vernum=`expr $required_major \* 10000 \
112 \+ $required_minor \* 100 \+ $required_patch`
113 available_swig_vernum=`expr $available_major \* 10000 \
114 \+ $available_minor \* 100 \+ $available_patch`
116 if test $available_swig_vernum -lt $required_swig_vernum; then
117 AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.])
119 m4_ifval([$3],[$3],[])
121 AC_MSG_CHECKING([for SWIG library])
122 SWIG_LIB=`$SWIG -swiglib`
123 AC_MSG_RESULT([$SWIG_LIB])
124 m4_ifval([$2],[$2],[])
127 AC_MSG_WARN([cannot determine SWIG version])
129 m4_ifval([$3],[$3],[])