jamie@126: # =========================================================================== jamie@126: # http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html jamie@126: # =========================================================================== jamie@126: # jamie@126: # SYNOPSIS jamie@126: # jamie@126: # AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found]) jamie@126: # jamie@126: # DESCRIPTION jamie@126: # jamie@126: # This macro searches for a SWIG installation on your system. If found, jamie@126: # then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is jamie@126: # found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd. jamie@126: # jamie@126: # You can use the optional first argument to check if the version of the jamie@126: # available SWIG is greater than or equal to the value of the argument. It jamie@126: # should have the format: N[.N[.N]] (N is a number between 0 and 999. Only jamie@126: # the first N is mandatory.) If the version argument is given (e.g. jamie@126: # 1.3.17), AX_PKG_SWIG checks that the swig package is this version number jamie@126: # or higher. jamie@126: # jamie@126: # As usual, action-if-found is executed if SWIG is found, otherwise jamie@126: # action-if-not-found is executed. jamie@126: # jamie@126: # In configure.in, use as: jamie@126: # jamie@126: # AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ]) jamie@126: # AX_SWIG_ENABLE_CXX jamie@126: # AX_SWIG_MULTI_MODULE_SUPPORT jamie@126: # AX_SWIG_PYTHON jamie@126: # jamie@126: # LICENSE jamie@126: # jamie@126: # Copyright (c) 2008 Sebastian Huber jamie@126: # Copyright (c) 2008 Alan W. Irwin jamie@126: # Copyright (c) 2008 Rafael Laboissiere jamie@126: # Copyright (c) 2008 Andrew Collier jamie@126: # Copyright (c) 2011 Murray Cumming jamie@126: # jamie@126: # This program is free software; you can redistribute it and/or modify it jamie@126: # under the terms of the GNU General Public License as published by the jamie@126: # Free Software Foundation; either version 2 of the License, or (at your jamie@126: # option) any later version. jamie@126: # jamie@126: # This program is distributed in the hope that it will be useful, but jamie@126: # WITHOUT ANY WARRANTY; without even the implied warranty of jamie@126: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General jamie@126: # Public License for more details. jamie@126: # jamie@126: # You should have received a copy of the GNU General Public License along jamie@126: # with this program. If not, see . jamie@126: # jamie@126: # As a special exception, the respective Autoconf Macro's copyright owner jamie@126: # gives unlimited permission to copy, distribute and modify the configure jamie@126: # scripts that are the output of Autoconf when processing the Macro. You jamie@126: # need not follow the terms of the GNU General Public License when using jamie@126: # or distributing such scripts, even though portions of the text of the jamie@126: # Macro appear in them. The GNU General Public License (GPL) does govern jamie@126: # all other use of the material that constitutes the Autoconf Macro. jamie@126: # jamie@126: # This special exception to the GPL applies to versions of the Autoconf jamie@126: # Macro released by the Autoconf Archive. When you make and distribute a jamie@126: # modified version of the Autoconf Macro, you may extend this special jamie@126: # exception to the GPL to apply to your modified version as well. jamie@126: jamie@126: #serial 8 jamie@126: jamie@126: AC_DEFUN([AX_PKG_SWIG],[ jamie@126: # Ubuntu has swig 2.0 as /usr/bin/swig2.0 jamie@126: AC_PATH_PROGS([SWIG],[swig swig2.0]) jamie@126: if test -z "$SWIG" ; then jamie@126: m4_ifval([$3],[$3],[:]) jamie@126: elif test -n "$1" ; then jamie@126: AC_MSG_CHECKING([SWIG version]) jamie@126: [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'`] jamie@126: AC_MSG_RESULT([$swig_version]) jamie@126: if test -n "$swig_version" ; then jamie@126: # Calculate the required version number components jamie@126: [required=$1] jamie@126: [required_major=`echo $required | sed 's/[^0-9].*//'`] jamie@126: if test -z "$required_major" ; then jamie@126: [required_major=0] jamie@126: fi jamie@126: [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] jamie@126: [required_minor=`echo $required | sed 's/[^0-9].*//'`] jamie@126: if test -z "$required_minor" ; then jamie@126: [required_minor=0] jamie@126: fi jamie@126: [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] jamie@126: [required_patch=`echo $required | sed 's/[^0-9].*//'`] jamie@126: if test -z "$required_patch" ; then jamie@126: [required_patch=0] jamie@126: fi jamie@126: # Calculate the available version number components jamie@126: [available=$swig_version] jamie@126: [available_major=`echo $available | sed 's/[^0-9].*//'`] jamie@126: if test -z "$available_major" ; then jamie@126: [available_major=0] jamie@126: fi jamie@126: [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] jamie@126: [available_minor=`echo $available | sed 's/[^0-9].*//'`] jamie@126: if test -z "$available_minor" ; then jamie@126: [available_minor=0] jamie@126: fi jamie@126: [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] jamie@126: [available_patch=`echo $available | sed 's/[^0-9].*//'`] jamie@126: if test -z "$available_patch" ; then jamie@126: [available_patch=0] jamie@126: fi jamie@126: # Convert the version tuple into a single number for easier comparison. jamie@126: # Using base 100 should be safe since SWIG internally uses BCD values jamie@126: # to encode its version number. jamie@126: required_swig_vernum=`expr $required_major \* 10000 \ jamie@126: \+ $required_minor \* 100 \+ $required_patch` jamie@126: available_swig_vernum=`expr $available_major \* 10000 \ jamie@126: \+ $available_minor \* 100 \+ $available_patch` jamie@126: jamie@126: if test $available_swig_vernum -lt $required_swig_vernum; then jamie@126: AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.]) jamie@126: SWIG='' jamie@126: m4_ifval([$3],[$3],[]) jamie@126: else jamie@126: AC_MSG_CHECKING([for SWIG library]) jamie@126: SWIG_LIB=`$SWIG -swiglib` jamie@126: AC_MSG_RESULT([$SWIG_LIB]) jamie@126: m4_ifval([$2],[$2],[]) jamie@126: fi jamie@126: else jamie@126: AC_MSG_WARN([cannot determine SWIG version]) jamie@126: SWIG='' jamie@126: m4_ifval([$3],[$3],[]) jamie@126: fi jamie@126: fi jamie@126: AC_SUBST([SWIG_LIB]) jamie@126: ])