Blame m4/ax_pkg_swig.m4

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