Blame m4/ax_pkg_swig.m4

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