1 AC_DEFUN([AC_PROG_SWIG],[
2 AC_PATH_PROG([SWIG],[swig])
3 if test -z "$SWIG" ; then
4 AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
5 SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
6 elif test -n "$1" ; then
7 AC_MSG_CHECKING([for SWIG version])
8 [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'`]
9 AC_MSG_RESULT([$swig_version])
10 if test -n "$swig_version" ; then
11 # Calculate the required version number components
13 [required_major=`echo $required | sed 's/[^0-9].*//'`]
14 if test -z "$required_major" ; then
17 [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
18 [required_minor=`echo $required | sed 's/[^0-9].*//'`]
19 if test -z "$required_minor" ; then
22 [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
23 [required_patch=`echo $required | sed 's/[^0-9].*//'`]
24 if test -z "$required_patch" ; then
27 # Calculate the available version number components
28 [available=$swig_version]
29 [available_major=`echo $available | sed 's/[^0-9].*//'`]
30 if test -z "$available_major" ; then
33 [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
34 [available_minor=`echo $available | sed 's/[^0-9].*//'`]
35 if test -z "$available_minor" ; then
38 [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
39 [available_patch=`echo $available | sed 's/[^0-9].*//'`]
40 if test -z "$available_patch" ; then
43 if test $available_major -ne $required_major \
44 -o $available_minor -ne $required_minor \
45 -o $available_patch -lt $required_patch ; then
46 AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org])
47 SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false'
49 AC_MSG_NOTICE([SWIG executable is '$SWIG'])
50 SWIG_LIB=`$SWIG -swiglib`
51 AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB'])
54 AC_MSG_WARN([cannot determine SWIG version])
55 SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false'
61 dnl a macro to check for ability to create python extensions
62 dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
63 dnl function also defines PYTHON_INCLUDES
64 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
65 [AC_REQUIRE([AM_PATH_PYTHON])
66 AC_MSG_CHECKING(for headers required to compile python extensions)
67 dnl deduce PYTHON_INCLUDES
68 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
69 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
70 PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
71 if test "$py_prefix" != "$py_exec_prefix"; then
72 PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
74 AC_SUBST(PYTHON_INCLUDES)
75 dnl check if the headers exist:
76 save_CPPFLAGS="$CPPFLAGS"
77 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
78 AC_TRY_CPP([#include <Python.h>],dnl
81 [AC_MSG_RESULT(not found)
83 CPPFLAGS="$save_CPPFLAGS"
86 dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
88 dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
89 dnl will set SYSCONFDIR to /usr/local/etc
91 dnl written by thomas vander stichele
93 AC_DEFUN([AS_AC_EXPAND],
98 dnl first expand prefix and exec_prefix if necessary
100 if test "x$prefix" = "xNONE"; then
103 exec_prefix_save=$exec_prefix
104 if test "x$exec_prefix" = "xNONE"; then
105 if test "x$prefix_save" = "xNONE"; then
106 exec_prefix=/usr/local
113 dnl loop until it doesn't change anymore
115 new_full_var="`eval echo $full_var`"
116 if test "x$new_full_var" = "x$full_var"; then break; fi
117 full_var=$new_full_var
121 full_var=$new_full_var
124 exec_prefix=$exec_prefix_save