1*335c7cdaSCy Schubert# =========================================================================== 2*335c7cdaSCy Schubert# https://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html 3*335c7cdaSCy Schubert# =========================================================================== 4*335c7cdaSCy Schubert# 5*335c7cdaSCy Schubert# SYNOPSIS 6*335c7cdaSCy Schubert# 7*335c7cdaSCy Schubert# AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found]) 8*335c7cdaSCy Schubert# 9*335c7cdaSCy Schubert# DESCRIPTION 10*335c7cdaSCy Schubert# 11*335c7cdaSCy Schubert# This macro searches for a SWIG installation on your system. If found, 12*335c7cdaSCy Schubert# then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is 13*335c7cdaSCy Schubert# found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd. 14*335c7cdaSCy Schubert# 15*335c7cdaSCy Schubert# You can use the optional first argument to check if the version of the 16*335c7cdaSCy Schubert# available SWIG is greater than or equal to the value of the argument. It 17*335c7cdaSCy Schubert# should have the format: N[.N[.N]] (N is a number between 0 and 999. Only 18*335c7cdaSCy Schubert# the first N is mandatory.) If the version argument is given (e.g. 19*335c7cdaSCy Schubert# 1.3.17), AX_PKG_SWIG checks that the swig package is this version number 20*335c7cdaSCy Schubert# or higher. 21*335c7cdaSCy Schubert# 22*335c7cdaSCy Schubert# As usual, action-if-found is executed if SWIG is found, otherwise 23*335c7cdaSCy Schubert# action-if-not-found is executed. 24*335c7cdaSCy Schubert# 25*335c7cdaSCy Schubert# In configure.in, use as: 26*335c7cdaSCy Schubert# 27*335c7cdaSCy Schubert# AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ]) 28*335c7cdaSCy Schubert# AX_SWIG_ENABLE_CXX 29*335c7cdaSCy Schubert# AX_SWIG_MULTI_MODULE_SUPPORT 30*335c7cdaSCy Schubert# AX_SWIG_PYTHON 31*335c7cdaSCy Schubert# 32*335c7cdaSCy Schubert# LICENSE 33*335c7cdaSCy Schubert# 34*335c7cdaSCy Schubert# Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> 35*335c7cdaSCy Schubert# Copyright (c) 2008 Alan W. Irwin 36*335c7cdaSCy Schubert# Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> 37*335c7cdaSCy Schubert# Copyright (c) 2008 Andrew Collier 38*335c7cdaSCy Schubert# Copyright (c) 2011 Murray Cumming <murrayc@openismus.com> 39*335c7cdaSCy Schubert# Copyright (c) 2018 Reini Urban <rurban@cpan.org> 40*335c7cdaSCy Schubert# Copyright (c) 2021 Vincent Danjean <Vincent.Danjean@ens-lyon.org> 41*335c7cdaSCy Schubert# 42*335c7cdaSCy Schubert# This program is free software; you can redistribute it and/or modify it 43*335c7cdaSCy Schubert# under the terms of the GNU General Public License as published by the 44*335c7cdaSCy Schubert# Free Software Foundation; either version 2 of the License, or (at your 45*335c7cdaSCy Schubert# option) any later version. 46*335c7cdaSCy Schubert# 47*335c7cdaSCy Schubert# This program is distributed in the hope that it will be useful, but 48*335c7cdaSCy Schubert# WITHOUT ANY WARRANTY; without even the implied warranty of 49*335c7cdaSCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 50*335c7cdaSCy Schubert# Public License for more details. 51*335c7cdaSCy Schubert# 52*335c7cdaSCy Schubert# You should have received a copy of the GNU General Public License along 53*335c7cdaSCy Schubert# with this program. If not, see <https://www.gnu.org/licenses/>. 54*335c7cdaSCy Schubert# 55*335c7cdaSCy Schubert# As a special exception, the respective Autoconf Macro's copyright owner 56*335c7cdaSCy Schubert# gives unlimited permission to copy, distribute and modify the configure 57*335c7cdaSCy Schubert# scripts that are the output of Autoconf when processing the Macro. You 58*335c7cdaSCy Schubert# need not follow the terms of the GNU General Public License when using 59*335c7cdaSCy Schubert# or distributing such scripts, even though portions of the text of the 60*335c7cdaSCy Schubert# Macro appear in them. The GNU General Public License (GPL) does govern 61*335c7cdaSCy Schubert# all other use of the material that constitutes the Autoconf Macro. 62*335c7cdaSCy Schubert# 63*335c7cdaSCy Schubert# This special exception to the GPL applies to versions of the Autoconf 64*335c7cdaSCy Schubert# Macro released by the Autoconf Archive. When you make and distribute a 65*335c7cdaSCy Schubert# modified version of the Autoconf Macro, you may extend this special 66*335c7cdaSCy Schubert# exception to the GPL to apply to your modified version as well. 67*335c7cdaSCy Schubert 68*335c7cdaSCy Schubert#serial 15 69*335c7cdaSCy Schubert 70*335c7cdaSCy SchubertAC_DEFUN([AX_PKG_SWIG],[ 71*335c7cdaSCy Schubert # Find path to the "swig" executable. 72*335c7cdaSCy Schubert AC_PATH_PROGS([SWIG],[swig swig3.0 swig2.0]) 73*335c7cdaSCy Schubert if test -z "$SWIG" ; then 74*335c7cdaSCy Schubert m4_ifval([$3],[$3],[:]) 75*335c7cdaSCy Schubert elif test -z "$1" ; then 76*335c7cdaSCy Schubert m4_ifval([$2],[$2],[:]) 77*335c7cdaSCy Schubert else 78*335c7cdaSCy Schubert AC_MSG_CHECKING([SWIG version]) 79*335c7cdaSCy Schubert [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'`] 80*335c7cdaSCy Schubert AC_MSG_RESULT([$swig_version]) 81*335c7cdaSCy Schubert if test -n "$swig_version" ; then 82*335c7cdaSCy Schubert # Calculate the required version number components 83*335c7cdaSCy Schubert [required=$1] 84*335c7cdaSCy Schubert [required_major=`echo $required | sed 's/[^0-9].*//'`] 85*335c7cdaSCy Schubert if test -z "$required_major" ; then 86*335c7cdaSCy Schubert [required_major=0] 87*335c7cdaSCy Schubert fi 88*335c7cdaSCy Schubert [required=`echo $required. | sed 's/[0-9]*[^0-9]//'`] 89*335c7cdaSCy Schubert [required_minor=`echo $required | sed 's/[^0-9].*//'`] 90*335c7cdaSCy Schubert if test -z "$required_minor" ; then 91*335c7cdaSCy Schubert [required_minor=0] 92*335c7cdaSCy Schubert fi 93*335c7cdaSCy Schubert [required=`echo $required. | sed 's/[0-9]*[^0-9]//'`] 94*335c7cdaSCy Schubert [required_patch=`echo $required | sed 's/[^0-9].*//'`] 95*335c7cdaSCy Schubert if test -z "$required_patch" ; then 96*335c7cdaSCy Schubert [required_patch=0] 97*335c7cdaSCy Schubert fi 98*335c7cdaSCy Schubert # Calculate the available version number components 99*335c7cdaSCy Schubert [available=$swig_version] 100*335c7cdaSCy Schubert [available_major=`echo $available | sed 's/[^0-9].*//'`] 101*335c7cdaSCy Schubert if test -z "$available_major" ; then 102*335c7cdaSCy Schubert [available_major=0] 103*335c7cdaSCy Schubert fi 104*335c7cdaSCy Schubert [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] 105*335c7cdaSCy Schubert [available_minor=`echo $available | sed 's/[^0-9].*//'`] 106*335c7cdaSCy Schubert if test -z "$available_minor" ; then 107*335c7cdaSCy Schubert [available_minor=0] 108*335c7cdaSCy Schubert fi 109*335c7cdaSCy Schubert [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] 110*335c7cdaSCy Schubert [available_patch=`echo $available | sed 's/[^0-9].*//'`] 111*335c7cdaSCy Schubert if test -z "$available_patch" ; then 112*335c7cdaSCy Schubert [available_patch=0] 113*335c7cdaSCy Schubert fi 114*335c7cdaSCy Schubert # Convert the version tuple into a single number for easier comparison. 115*335c7cdaSCy Schubert # Using base 100 should be safe since SWIG internally uses BCD values 116*335c7cdaSCy Schubert # to encode its version number. 117*335c7cdaSCy Schubert required_swig_vernum=`expr $required_major \* 10000 \ 118*335c7cdaSCy Schubert \+ $required_minor \* 100 \+ $required_patch` 119*335c7cdaSCy Schubert available_swig_vernum=`expr $available_major \* 10000 \ 120*335c7cdaSCy Schubert \+ $available_minor \* 100 \+ $available_patch` 121*335c7cdaSCy Schubert 122*335c7cdaSCy Schubert if test $available_swig_vernum -lt $required_swig_vernum; then 123*335c7cdaSCy Schubert AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.]) 124*335c7cdaSCy Schubert SWIG='' 125*335c7cdaSCy Schubert m4_ifval([$3],[$3],[]) 126*335c7cdaSCy Schubert else 127*335c7cdaSCy Schubert AC_MSG_CHECKING([for SWIG library]) 128*335c7cdaSCy Schubert SWIG_LIB=`$SWIG -swiglib | tr '\r\n' ' '` 129*335c7cdaSCy Schubert AC_MSG_RESULT([$SWIG_LIB]) 130*335c7cdaSCy Schubert m4_ifval([$2],[$2],[]) 131*335c7cdaSCy Schubert fi 132*335c7cdaSCy Schubert else 133*335c7cdaSCy Schubert AC_MSG_WARN([cannot determine SWIG version]) 134*335c7cdaSCy Schubert SWIG='' 135*335c7cdaSCy Schubert m4_ifval([$3],[$3],[]) 136*335c7cdaSCy Schubert fi 137*335c7cdaSCy Schubert fi 138*335c7cdaSCy Schubert AC_SUBST([SWIG_LIB]) 139*335c7cdaSCy Schubert]) 140