17b5038d7SDag-Erling Smørgrav# =========================================================================== 2*5afab0e5SDag-Erling Smørgrav# https://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html 37b5038d7SDag-Erling Smørgrav# =========================================================================== 47b5038d7SDag-Erling Smørgrav# 57b5038d7SDag-Erling Smørgrav# SYNOPSIS 67b5038d7SDag-Erling Smørgrav# 77b5038d7SDag-Erling Smørgrav# AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found]) 87b5038d7SDag-Erling Smørgrav# 97b5038d7SDag-Erling Smørgrav# DESCRIPTION 107b5038d7SDag-Erling Smørgrav# 117b5038d7SDag-Erling Smørgrav# This macro searches for a SWIG installation on your system. If found, 127b5038d7SDag-Erling Smørgrav# then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is 137b5038d7SDag-Erling Smørgrav# found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd. 147b5038d7SDag-Erling Smørgrav# 157b5038d7SDag-Erling Smørgrav# You can use the optional first argument to check if the version of the 167b5038d7SDag-Erling Smørgrav# available SWIG is greater than or equal to the value of the argument. It 177b5038d7SDag-Erling Smørgrav# should have the format: N[.N[.N]] (N is a number between 0 and 999. Only 187b5038d7SDag-Erling Smørgrav# the first N is mandatory.) If the version argument is given (e.g. 197b5038d7SDag-Erling Smørgrav# 1.3.17), AX_PKG_SWIG checks that the swig package is this version number 207b5038d7SDag-Erling Smørgrav# or higher. 217b5038d7SDag-Erling Smørgrav# 227b5038d7SDag-Erling Smørgrav# As usual, action-if-found is executed if SWIG is found, otherwise 237b5038d7SDag-Erling Smørgrav# action-if-not-found is executed. 247b5038d7SDag-Erling Smørgrav# 257b5038d7SDag-Erling Smørgrav# In configure.in, use as: 267b5038d7SDag-Erling Smørgrav# 277b5038d7SDag-Erling Smørgrav# AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ]) 287b5038d7SDag-Erling Smørgrav# AX_SWIG_ENABLE_CXX 297b5038d7SDag-Erling Smørgrav# AX_SWIG_MULTI_MODULE_SUPPORT 307b5038d7SDag-Erling Smørgrav# AX_SWIG_PYTHON 317b5038d7SDag-Erling Smørgrav# 327b5038d7SDag-Erling Smørgrav# LICENSE 337b5038d7SDag-Erling Smørgrav# 347b5038d7SDag-Erling Smørgrav# Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> 35*5afab0e5SDag-Erling Smørgrav# Copyright (c) 2008 Alan W. Irwin 367b5038d7SDag-Erling Smørgrav# Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> 37*5afab0e5SDag-Erling Smørgrav# Copyright (c) 2008 Andrew Collier 387b5038d7SDag-Erling Smørgrav# Copyright (c) 2011 Murray Cumming <murrayc@openismus.com> 397b5038d7SDag-Erling Smørgrav# 407b5038d7SDag-Erling Smørgrav# This program is free software; you can redistribute it and/or modify it 417b5038d7SDag-Erling Smørgrav# under the terms of the GNU General Public License as published by the 427b5038d7SDag-Erling Smørgrav# Free Software Foundation; either version 2 of the License, or (at your 437b5038d7SDag-Erling Smørgrav# option) any later version. 447b5038d7SDag-Erling Smørgrav# 457b5038d7SDag-Erling Smørgrav# This program is distributed in the hope that it will be useful, but 467b5038d7SDag-Erling Smørgrav# WITHOUT ANY WARRANTY; without even the implied warranty of 477b5038d7SDag-Erling Smørgrav# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 487b5038d7SDag-Erling Smørgrav# Public License for more details. 497b5038d7SDag-Erling Smørgrav# 507b5038d7SDag-Erling Smørgrav# You should have received a copy of the GNU General Public License along 51*5afab0e5SDag-Erling Smørgrav# with this program. If not, see <https://www.gnu.org/licenses/>. 527b5038d7SDag-Erling Smørgrav# 537b5038d7SDag-Erling Smørgrav# As a special exception, the respective Autoconf Macro's copyright owner 547b5038d7SDag-Erling Smørgrav# gives unlimited permission to copy, distribute and modify the configure 557b5038d7SDag-Erling Smørgrav# scripts that are the output of Autoconf when processing the Macro. You 567b5038d7SDag-Erling Smørgrav# need not follow the terms of the GNU General Public License when using 577b5038d7SDag-Erling Smørgrav# or distributing such scripts, even though portions of the text of the 587b5038d7SDag-Erling Smørgrav# Macro appear in them. The GNU General Public License (GPL) does govern 597b5038d7SDag-Erling Smørgrav# all other use of the material that constitutes the Autoconf Macro. 607b5038d7SDag-Erling Smørgrav# 617b5038d7SDag-Erling Smørgrav# This special exception to the GPL applies to versions of the Autoconf 627b5038d7SDag-Erling Smørgrav# Macro released by the Autoconf Archive. When you make and distribute a 637b5038d7SDag-Erling Smørgrav# modified version of the Autoconf Macro, you may extend this special 647b5038d7SDag-Erling Smørgrav# exception to the GPL to apply to your modified version as well. 657b5038d7SDag-Erling Smørgrav 66*5afab0e5SDag-Erling Smørgrav#serial 13 677b5038d7SDag-Erling Smørgrav 687b5038d7SDag-Erling SmørgravAC_DEFUN([AX_PKG_SWIG],[ 69*5afab0e5SDag-Erling Smørgrav # Find path to the "swig" executable. 70*5afab0e5SDag-Erling Smørgrav AC_PATH_PROGS([SWIG],[swig swig3.0 swig2.0]) 717b5038d7SDag-Erling Smørgrav if test -z "$SWIG" ; then 727b5038d7SDag-Erling Smørgrav m4_ifval([$3],[$3],[:]) 737b5038d7SDag-Erling Smørgrav elif test -n "$1" ; then 747b5038d7SDag-Erling Smørgrav AC_MSG_CHECKING([SWIG version]) 757b5038d7SDag-Erling Smørgrav [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'`] 767b5038d7SDag-Erling Smørgrav AC_MSG_RESULT([$swig_version]) 777b5038d7SDag-Erling Smørgrav if test -n "$swig_version" ; then 787b5038d7SDag-Erling Smørgrav # Calculate the required version number components 797b5038d7SDag-Erling Smørgrav [required=$1] 807b5038d7SDag-Erling Smørgrav [required_major=`echo $required | sed 's/[^0-9].*//'`] 817b5038d7SDag-Erling Smørgrav if test -z "$required_major" ; then 827b5038d7SDag-Erling Smørgrav [required_major=0] 837b5038d7SDag-Erling Smørgrav fi 847b5038d7SDag-Erling Smørgrav [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] 857b5038d7SDag-Erling Smørgrav [required_minor=`echo $required | sed 's/[^0-9].*//'`] 867b5038d7SDag-Erling Smørgrav if test -z "$required_minor" ; then 877b5038d7SDag-Erling Smørgrav [required_minor=0] 887b5038d7SDag-Erling Smørgrav fi 897b5038d7SDag-Erling Smørgrav [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] 907b5038d7SDag-Erling Smørgrav [required_patch=`echo $required | sed 's/[^0-9].*//'`] 917b5038d7SDag-Erling Smørgrav if test -z "$required_patch" ; then 927b5038d7SDag-Erling Smørgrav [required_patch=0] 937b5038d7SDag-Erling Smørgrav fi 947b5038d7SDag-Erling Smørgrav # Calculate the available version number components 957b5038d7SDag-Erling Smørgrav [available=$swig_version] 967b5038d7SDag-Erling Smørgrav [available_major=`echo $available | sed 's/[^0-9].*//'`] 977b5038d7SDag-Erling Smørgrav if test -z "$available_major" ; then 987b5038d7SDag-Erling Smørgrav [available_major=0] 997b5038d7SDag-Erling Smørgrav fi 1007b5038d7SDag-Erling Smørgrav [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] 1017b5038d7SDag-Erling Smørgrav [available_minor=`echo $available | sed 's/[^0-9].*//'`] 1027b5038d7SDag-Erling Smørgrav if test -z "$available_minor" ; then 1037b5038d7SDag-Erling Smørgrav [available_minor=0] 1047b5038d7SDag-Erling Smørgrav fi 1057b5038d7SDag-Erling Smørgrav [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] 1067b5038d7SDag-Erling Smørgrav [available_patch=`echo $available | sed 's/[^0-9].*//'`] 1077b5038d7SDag-Erling Smørgrav if test -z "$available_patch" ; then 1087b5038d7SDag-Erling Smørgrav [available_patch=0] 1097b5038d7SDag-Erling Smørgrav fi 1107b5038d7SDag-Erling Smørgrav # Convert the version tuple into a single number for easier comparison. 1117b5038d7SDag-Erling Smørgrav # Using base 100 should be safe since SWIG internally uses BCD values 1127b5038d7SDag-Erling Smørgrav # to encode its version number. 1137b5038d7SDag-Erling Smørgrav required_swig_vernum=`expr $required_major \* 10000 \ 1147b5038d7SDag-Erling Smørgrav \+ $required_minor \* 100 \+ $required_patch` 1157b5038d7SDag-Erling Smørgrav available_swig_vernum=`expr $available_major \* 10000 \ 1167b5038d7SDag-Erling Smørgrav \+ $available_minor \* 100 \+ $available_patch` 1177b5038d7SDag-Erling Smørgrav 1187b5038d7SDag-Erling Smørgrav if test $available_swig_vernum -lt $required_swig_vernum; then 1197b5038d7SDag-Erling Smørgrav AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.]) 1207b5038d7SDag-Erling Smørgrav SWIG='' 1217b5038d7SDag-Erling Smørgrav m4_ifval([$3],[$3],[]) 1227b5038d7SDag-Erling Smørgrav else 1237b5038d7SDag-Erling Smørgrav AC_MSG_CHECKING([for SWIG library]) 1247b5038d7SDag-Erling Smørgrav SWIG_LIB=`$SWIG -swiglib` 1257b5038d7SDag-Erling Smørgrav AC_MSG_RESULT([$SWIG_LIB]) 1267b5038d7SDag-Erling Smørgrav m4_ifval([$2],[$2],[]) 1277b5038d7SDag-Erling Smørgrav fi 1287b5038d7SDag-Erling Smørgrav else 1297b5038d7SDag-Erling Smørgrav AC_MSG_WARN([cannot determine SWIG version]) 1307b5038d7SDag-Erling Smørgrav SWIG='' 1317b5038d7SDag-Erling Smørgrav m4_ifval([$3],[$3],[]) 1327b5038d7SDag-Erling Smørgrav fi 1337b5038d7SDag-Erling Smørgrav fi 1347b5038d7SDag-Erling Smørgrav AC_SUBST([SWIG_LIB]) 1357b5038d7SDag-Erling Smørgrav]) 136