1
dnl This macro checks for the existance of swig and defines the
2
dnl corresponding SWIG variable.
5
dnl MLX_PROG_SWIG(maj.min.patch, eq|lt)
6
dnl The second parameter defines the required relation of the found version
7
dnl to the requested version:
8
dnl lt - the found version required to be newer or equal to the maj.min.patch
9
dnl eq - the found version required to be equal to the maj.min.patch
12
dnl HAS_SWIG conditional - set to 1 if swig was found or 0 if not
13
dnl SWIG - the executable name
15
AC_DEFUN([MLX_PROG_SWIG],[
16
AC_PATH_PROG([SWIG],[swig])
17
# we use this to track the existance of swig
19
if test -z "$SWIG" ; then
20
AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
21
SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
22
elif test -n "$1" ; then
23
AC_MSG_CHECKING([for SWIG version])
24
[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'`]
25
AC_MSG_RESULT([$swig_version])
26
if test -n "$swig_version" ; then
27
# Calculate the required version number components
29
[required_major=`echo $required | sed 's/[^0-9].*//'`]
30
if test -z "$required_major" ; then
33
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
34
[required_minor=`echo $required | sed 's/[^0-9].*//'`]
35
if test -z "$required_minor" ; then
38
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
39
[required_patch=`echo $required | sed 's/[^0-9].*//'`]
40
if test -z "$required_patch" ; then
43
# Calculate the available version number components
44
[available=`echo $swig_version | sed 's/[^0-9]*//'`]
45
[available_major=`echo $available | sed 's/[^0-9].*//'`]
46
if test -z "$available_major" ; then
49
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
50
[available_minor=`echo $available | sed 's/[^0-9].*//'`]
51
if test -z "$available_minor" ; then
54
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
55
[available_patch=`echo $available | sed -e 's/.*Patch[^0-9]*//' -e 's/[^0-9]*//g' `]
56
if test -z "$available_patch" ; then
59
# we have two modes of comparison...
60
if test x"$2" == xeq; then
61
if test $available_major -ne $required_major \
62
-o $available_minor -ne $required_minor \
63
-o $available_patch -ne $required_patch ; then
64
AC_MSG_WARN([SWIG version == $1 is required. You have $available_major.$available_minor.$available_patch. You should look at http://www.swig.org ])
65
SWIG='echo "Error: SWIG version == $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false'
70
if test $available_major -ne $required_major \
71
-o $available_minor -ne $required_minor \
72
-o $available_patch -lt $required_patch ; then
73
AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org])
74
SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false'
80
AC_MSG_WARN([cannot determine SWIG version])
81
SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false'
84
if test ! -z "$has_swig"; then
85
dnl AC_MSG_INFO([SWIG executable is '$SWIG'])
86
SWIG_LIB=`$SWIG -swiglib`
87
dnl AC_MSG_INFO([SWIG runtime library directory is '$SWIG_LIB'])
88
AM_CONDITIONAL(HAS_SWIG,[test 1])
90
AM_CONDITIONAL(HAS_SWIG,[test 0])