1238104Sdes# =========================================================================== 2238104Sdes# http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html 3238104Sdes# =========================================================================== 4238104Sdes# 5238104Sdes# SYNOPSIS 6238104Sdes# 7238104Sdes# AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found]) 8238104Sdes# 9238104Sdes# DESCRIPTION 10238104Sdes# 11238104Sdes# This macro searches for a SWIG installation on your system. If found, 12238104Sdes# then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is 13238104Sdes# found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd. 14238104Sdes# 15238104Sdes# You can use the optional first argument to check if the version of the 16238104Sdes# available SWIG is greater than or equal to the value of the argument. It 17238104Sdes# should have the format: N[.N[.N]] (N is a number between 0 and 999. Only 18238104Sdes# the first N is mandatory.) If the version argument is given (e.g. 19238104Sdes# 1.3.17), AX_PKG_SWIG checks that the swig package is this version number 20238104Sdes# or higher. 21238104Sdes# 22238104Sdes# As usual, action-if-found is executed if SWIG is found, otherwise 23238104Sdes# action-if-not-found is executed. 24238104Sdes# 25238104Sdes# In configure.in, use as: 26238104Sdes# 27238104Sdes# AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ]) 28238104Sdes# AX_SWIG_ENABLE_CXX 29238104Sdes# AX_SWIG_MULTI_MODULE_SUPPORT 30238104Sdes# AX_SWIG_PYTHON 31238104Sdes# 32238104Sdes# LICENSE 33238104Sdes# 34238104Sdes# Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> 35238104Sdes# Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca> 36238104Sdes# Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> 37238104Sdes# Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za> 38238104Sdes# Copyright (c) 2011 Murray Cumming <murrayc@openismus.com> 39238104Sdes# 40238104Sdes# This program is free software; you can redistribute it and/or modify it 41238104Sdes# under the terms of the GNU General Public License as published by the 42238104Sdes# Free Software Foundation; either version 2 of the License, or (at your 43238104Sdes# option) any later version. 44238104Sdes# 45238104Sdes# This program is distributed in the hope that it will be useful, but 46238104Sdes# WITHOUT ANY WARRANTY; without even the implied warranty of 47238104Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 48238104Sdes# Public License for more details. 49238104Sdes# 50238104Sdes# You should have received a copy of the GNU General Public License along 51238104Sdes# with this program. If not, see <http://www.gnu.org/licenses/>. 52238104Sdes# 53238104Sdes# As a special exception, the respective Autoconf Macro's copyright owner 54238104Sdes# gives unlimited permission to copy, distribute and modify the configure 55238104Sdes# scripts that are the output of Autoconf when processing the Macro. You 56238104Sdes# need not follow the terms of the GNU General Public License when using 57238104Sdes# or distributing such scripts, even though portions of the text of the 58238104Sdes# Macro appear in them. The GNU General Public License (GPL) does govern 59238104Sdes# all other use of the material that constitutes the Autoconf Macro. 60238104Sdes# 61238104Sdes# This special exception to the GPL applies to versions of the Autoconf 62238104Sdes# Macro released by the Autoconf Archive. When you make and distribute a 63238104Sdes# modified version of the Autoconf Macro, you may extend this special 64238104Sdes# exception to the GPL to apply to your modified version as well. 65238104Sdes 66238104Sdes#serial 8 67238104Sdes 68238104SdesAC_DEFUN([AX_PKG_SWIG],[ 69238104Sdes # Ubuntu has swig 2.0 as /usr/bin/swig2.0 70238104Sdes AC_PATH_PROGS([SWIG],[swig2.0 swig]) 71238104Sdes if test -z "$SWIG" ; then 72238104Sdes m4_ifval([$3],[$3],[:]) 73238104Sdes elif test -n "$1" ; then 74238104Sdes AC_MSG_CHECKING([SWIG version]) 75238104Sdes [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'`] 76238104Sdes AC_MSG_RESULT([$swig_version]) 77238104Sdes if test -n "$swig_version" ; then 78238104Sdes # Calculate the required version number components 79238104Sdes [required=$1] 80238104Sdes [required_major=`echo $required | sed 's/[^0-9].*//'`] 81238104Sdes if test -z "$required_major" ; then 82238104Sdes [required_major=0] 83238104Sdes fi 84238104Sdes [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] 85238104Sdes [required_minor=`echo $required | sed 's/[^0-9].*//'`] 86238104Sdes if test -z "$required_minor" ; then 87238104Sdes [required_minor=0] 88238104Sdes fi 89238104Sdes [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] 90238104Sdes [required_patch=`echo $required | sed 's/[^0-9].*//'`] 91238104Sdes if test -z "$required_patch" ; then 92238104Sdes [required_patch=0] 93238104Sdes fi 94238104Sdes # Calculate the available version number components 95238104Sdes [available=$swig_version] 96238104Sdes [available_major=`echo $available | sed 's/[^0-9].*//'`] 97238104Sdes if test -z "$available_major" ; then 98238104Sdes [available_major=0] 99238104Sdes fi 100238104Sdes [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] 101238104Sdes [available_minor=`echo $available | sed 's/[^0-9].*//'`] 102238104Sdes if test -z "$available_minor" ; then 103238104Sdes [available_minor=0] 104238104Sdes fi 105238104Sdes [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] 106238104Sdes [available_patch=`echo $available | sed 's/[^0-9].*//'`] 107238104Sdes if test -z "$available_patch" ; then 108238104Sdes [available_patch=0] 109238104Sdes fi 110238104Sdes # Convert the version tuple into a single number for easier comparison. 111238104Sdes # Using base 100 should be safe since SWIG internally uses BCD values 112238104Sdes # to encode its version number. 113238104Sdes required_swig_vernum=`expr $required_major \* 10000 \ 114238104Sdes \+ $required_minor \* 100 \+ $required_patch` 115238104Sdes available_swig_vernum=`expr $available_major \* 10000 \ 116238104Sdes \+ $available_minor \* 100 \+ $available_patch` 117238104Sdes 118238104Sdes if test $available_swig_vernum -lt $required_swig_vernum; then 119238104Sdes AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.]) 120238104Sdes SWIG='' 121238104Sdes m4_ifval([$3],[$3],[]) 122238104Sdes else 123238104Sdes AC_MSG_CHECKING([for SWIG library]) 124238104Sdes SWIG_LIB=`$SWIG -swiglib` 125238104Sdes AC_MSG_RESULT([$SWIG_LIB]) 126238104Sdes m4_ifval([$2],[$2],[]) 127238104Sdes fi 128238104Sdes else 129238104Sdes AC_MSG_WARN([cannot determine SWIG version]) 130238104Sdes SWIG='' 131238104Sdes m4_ifval([$3],[$3],[]) 132238104Sdes fi 133238104Sdes fi 134238104Sdes AC_SUBST([SWIG_LIB]) 135238104Sdes]) 136