20520b2392e7c884cb795b8beb5bf232c10def63
[debian/amanda] / config / macro-archive / ac_prog_swig.m4
1 # Modified by Dustin J. Mitchell, Zmanda, Inc. as follows:
2 #  - remove warnings -- Amanda tarballs ship pre-swigged, so users
3 #    need not be alarmed if they don't have SWIG.
4 #
5 ##### http://autoconf-archive.cryp.to/ac_pkg_swig.html
6 #
7 # SYNOPSIS
8 #
9 #   AC_PROG_SWIG([major.minor.micro])
10 #
11 # DESCRIPTION
12 #
13 #   This macro searches for a SWIG installation on your system. If
14 #   found you should call SWIG via $(SWIG). You can use the optional
15 #   first argument to check if the version of the available SWIG is
16 #   greater than or equal to the value of the argument. It should have
17 #   the format: N[.N[.N]] (N is a number between 0 and 999. Only the
18 #   first N is mandatory.)
19 #
20 #   If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks
21 #   that the swig package is this version number or higher.
22 #
23 #   In configure.in, use as:
24 #
25 #     AC_PROG_SWIG(1.3.17)
26 #     SWIG_ENABLE_CXX
27 #     SWIG_MULTI_MODULE_SUPPORT
28 #     SWIG_PYTHON
29 #
30 # LAST MODIFICATION
31 #
32 #   2006-10-22
33 #
34 # COPYLEFT
35 #
36 #   Copyright (c) 2006 Sebastian Huber <sebastian-huber@web.de>
37 #   Copyright (c) 2006 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
38 #   Copyright (c) 2006 Rafael Laboissiere <rafael@laboissiere.net>
39 #   Copyright (c) 2006 Andrew Collier <colliera@ukzn.ac.za>
40 #
41 #   This program is free software; you can redistribute it and/or
42 #   modify it under the terms of the GNU General Public License as
43 #   published by the Free Software Foundation; either version 2 of the
44 #   License, or (at your option) any later version.
45 #
46 #   This program is distributed in the hope that it will be useful, but
47 #   WITHOUT ANY WARRANTY; without even the implied warranty of
48 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
49 #   General Public License for more details.
50 #
51 #   You should have received a copy of the GNU General Public License
52 #   along with this program; if not, write to the Free Software
53 #   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
54 #   02111-1307, USA.
55 #
56 #   As a special exception, the respective Autoconf Macro's copyright
57 #   owner gives unlimited permission to copy, distribute and modify the
58 #   configure scripts that are the output of Autoconf when processing
59 #   the Macro. You need not follow the terms of the GNU General Public
60 #   License when using or distributing such scripts, even though
61 #   portions of the text of the Macro appear in them. The GNU General
62 #   Public License (GPL) does govern all other use of the material that
63 #   constitutes the Autoconf Macro.
64 #
65 #   This special exception to the GPL applies to versions of the
66 #   Autoconf Macro released by the Autoconf Macro Archive. When you
67 #   make and distribute a modified version of the Autoconf Macro, you
68 #   may extend this special exception to the GPL to apply to your
69 #   modified version as well.
70
71 AC_DEFUN([AC_PROG_SWIG],[
72         AC_PATH_PROG([SWIG],[swig])
73         if test -z "$SWIG" ; then
74                 SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
75         elif test -n "$1" ; then
76                 AC_MSG_CHECKING([for SWIG version])
77                 [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'`]
78                 AC_MSG_RESULT([$swig_version])
79                 if test -n "$swig_version" ; then
80                         # Calculate the required version number components
81                         [required=$1]
82                         [required_major=`echo $required | sed 's/[^0-9].*//'`]
83                         if test -z "$required_major" ; then
84                                 [required_major=0]
85                         fi
86                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
87                         [required_minor=`echo $required | sed 's/[^0-9].*//'`]
88                         if test -z "$required_minor" ; then
89                                 [required_minor=0]
90                         fi
91                         [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
92                         [required_patch=`echo $required | sed 's/[^0-9].*//'`]
93                         if test -z "$required_patch" ; then
94                                 [required_patch=0]
95                         fi
96                         # Calculate the available version number components
97                         [available=$swig_version]
98                         [available_major=`echo $available | sed 's/[^0-9].*//'`]
99                         if test -z "$available_major" ; then
100                                 [available_major=0]
101                         fi
102                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
103                         [available_minor=`echo $available | sed 's/[^0-9].*//'`]
104                         if test -z "$available_minor" ; then
105                                 [available_minor=0]
106                         fi
107                         [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
108                         [available_patch=`echo $available | sed 's/[^0-9].*//'`]
109                         if test -z "$available_patch" ; then
110                                 [available_patch=0]
111                         fi
112                         if test $available_major -ne $required_major \
113                                 -o $available_minor -ne $required_minor \
114                                 -o $available_patch -lt $required_patch ; then
115                                 SWIG='echo "Error: SWIG version >= $1 is required.  You have '"$swig_version"'.  You should look at http://www.swig.org" ; false'
116                         else
117                                 SWIG_LIB=`$SWIG -swiglib`
118                         fi
119                 else
120                         SWIG='echo "Error: Cannot determine SWIG version.  You should look at http://www.swig.org" ; false'
121                 fi
122         fi
123         AC_SUBST([SWIG_LIB])
124 ])