diff --git a/Makefile.in b/Makefile.in index 34f1922f7..febd28122 100644 --- a/Makefile.in +++ b/Makefile.in @@ -275,7 +275,7 @@ INSTALL_DATA = ${INSTALL} -m 644 INSTALL_PROGRAM = ${INSTALL} -m 755 MKINSTDIRS = @abs_srcdir@/Tools/config/mkinstalldirs -install: install-main install-lib install-runtime +install: install-main install-lib install-runtime install-m4 @echo "Installation complete" install-main: @@ -321,11 +321,20 @@ install-runtime: @cd $(RUNTIME); $(MAKE) install +M4_DIR = @datadir@/aclocal + +install-m4: + @echo "Installing M4 macros" + @$(MKINSTDIRS) $(M4_DIR) + @echo "Installing $(M4_DIR)/swig.m4" + @$(INSTALL_DATA) swig.m4 $(M4_DIR)/swig.m4 + + ##################################################################### # TARGETS: uninstall & friends ##################################################################### -uninstall: uninstall-main uninstall-lib uninstall-runtime +uninstall: uninstall-main uninstall-lib uninstall-runtime uninstall-m4 @echo "Uninstall complete" uninstall-main: @@ -339,6 +348,9 @@ uninstall-lib: uninstall-runtime: @cd $(RUNTIME); $(MAKE) uninstall +uninstall-m4: + @echo "Uninstalling $(M4_DIR)/swig.m4" + rm -f $(M4_DIR)/swig.m4; ############################################################################ # DIST and other maintenance diff --git a/swig.m4 b/swig.m4 new file mode 100644 index 000000000..70e3df812 --- /dev/null +++ b/swig.m4 @@ -0,0 +1,106 @@ +# Contributed by Sebastian Huber + +# SWIG_PROG([required-version = N[.N[.N]]]) +# +# Checks for the SWIG program. If found you can (and should) call +# SWIG via $(SWIG). You can use the optional first argument to check +# if the version of the available SWIG is greater than or equal to the +# value of the argument. It should have the format: N[.N[.N]] (N is a +# number between 0 and 999. Only the first N is mandatory.) +AC_DEFUN([SWIG_PROG],[ + AC_PATH_PROG([SWIG],[swig]) + if test -z "$SWIG" ; then + AC_MSG_WARN([cannot find 'swig' program, you may have a look at http://www.swig.org]) + SWIG='echo "error: SWIG is not installed, you may have a look at http://www.swig.org" ; false' + elif test -n "$1" ; then + AC_MSG_CHECKING([for SWIG version]) + [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/g'`] + AC_MSG_RESULT([$swig_version]) + if test -n "$swig_version" ; then + # Calculate the required version number + [swig_tmp=( `echo $1 | sed 's/[^0-9]\+/ /g'` )] + [swig_required_version=$(( 1000000 * ${swig_tmp[0]:-0} + 1000 * ${swig_tmp[1]:-0} + ${swig_tmp[2]:-0} ))] + + # Calculate the available version number + [swig_tmp=( `echo $swig_version | sed 's/[^0-9]\+/ /g'` )] + [swig_tmp=$(( 1000000 * ${swig_tmp[0]:-0} + 1000 * ${swig_tmp[1]:-0} + ${swig_tmp[2]:-0} ))] + + if test $swig_required_version -gt $swig_tmp ; then + AC_MSG_WARN([SWIG version $1 is required, you have $swig_version]) + fi + else + AC_MSG_WARN([cannot determine SWIG version]) + fi + SWIG_RUNTIME_LIBS_DIR="${SWIG%/bin*}/lib" + AC_MSG_NOTICE([SWIG runtime library directory is '$SWIG_RUNTIME_LIBS_DIR']) + fi + AC_SUBST([SWIG_RUNTIME_LIBS_DIR]) +]) + +# SWIG_ENABLE_CXX() +# +# Enable SWIG C++ support. This effects all invocations of $(SWIG). +AC_DEFUN([SWIG_ENABLE_CXX],[ + AC_REQUIRE([SWIG_PROG]) + AC_REQUIRE([AC_PROG_CXX]) + SWIG="$SWIG -c++" +]) + +# SWIG_MULTI_MODULE_SUPPORT() +# +# Enable support for multiple modules. This effects all invocations +# of $(SWIG). You have to link all generated modules against the +# appropriate SWIG runtime library. If you want to build Python +# modules for example, use the SWIG_PYTHON() macro and link the +# modules against $(SWIG_PYTHON_LIBS). +AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[ + AC_REQUIRE([SWIG_PROG]) + SWIG="$SWIG -c" +]) + +# SWIG_PYTHON([use-shadow-classes = {no, yes}]) +# +# Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS), +# $(SWIG_PYTHON_LIBS) and $(SWIG_PYTHON_OPT) output variables. +# $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate +# code for Python. Shadow classes are enabled unless the value of the +# optional first argument is exactly 'no'. If you need multi module +# support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use +# $(SWIG_PYTHON_LIBS) to link against the appropriate library. It +# contains the SWIG Python runtime library that is needed by the type +# check system for example. +AC_DEFUN([SWIG_PYTHON],[ + AC_REQUIRE([SWIG_PROG]) + AC_REQUIRE([PYTHON_DEVEL]) + test "x$1" != "xno" || swig_shadow=" -noproxy" + AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow]) + AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS]) + AC_SUBST([SWIG_PYTHON_LIBS],["$SWIG_RUNTIME_LIBS_DIR -lswigpy"]) +]) + +# PYTHON_DEVEL() +# +# Checks for Python and tries to get the include path to 'Python.h'. +# It provides the $(PYTHON_CPPFLAGS) output variable. +AC_DEFUN([PYTHON_DEVEL],[ + AC_REQUIRE([AM_PATH_PYTHON]) + + # Check for Python include path + AC_MSG_CHECKING([for Python include path]) + python_path=${PYTHON%/bin*} + for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do + python_path=`find $i -type f -name Python.h -print` + if test -n "$python_path" ; then + break + fi + done + for i in $python_path ; do + python_path=${python_path%/Python.h} + break + done + AC_MSG_RESULT([$python_path]) + if test -z "$python_path" ; then + AC_MSG_ERROR([cannot find Python include path]) + fi + AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path]) +])