Check for SWIG's features, not only version.

This commit is contained in:
Alexey Sokolov
2012-08-08 23:16:57 +07:00
parent 9ede566cd2
commit 3d152b160f
2 changed files with 105 additions and 87 deletions
+14 -26
View File
@@ -116,10 +116,10 @@ AC_ARG_ENABLE( [python],
[PYTHON="$enableval"],
[PYTHON="no"])
AC_ARG_ENABLE( [swig],
AS_HELP_STRING([--disable-swig], [Disable automatic generation of source files needed for modperl/modpython.
This value is ignored if perl and python are disabled. If you disable swig,
but still want to use these modules, please download the necessary files to modules/modperl and/or to modules/modpython.
Check http://en.znc.in/wiki/Modperl and http://en.znc.in/wiki/Modpython for details.]),
AS_HELP_STRING([--enable-swig], [Enable automatic generation of source files needed for modperl/modpython.
This value is ignored if perl and python are disabled.
Usually no need to enable it.
]),
[USESWIG="$enableval"],
[USESWIG="auto"])
AC_ARG_ENABLE( [cyrus],
@@ -323,29 +323,27 @@ fi
if test "x$PERL" != xno -o "x$PYTHON" != xno; then
old_USESWIG="$USESWIG"
if test "x$USESWIG" != "xno"; then
AC_MSG_ERROR([As of 2012-07-27 upstream SWIG crashes ZNC. Please check http://en.znc.in/wiki/Modperl or http://en.znc.in/wiki/Modpython for the second way of installing modperl/modpython.])
AC_PROG_SWIG([1.3.40])
AC_PROG_SWIG([2.0.8])
test -z "$SWIG" && USESWIG=no
if test "x$USESWIG" = xno -a "x$old_USESWIG" = yes; then
AC_MSG_ERROR([Could not found appropriate SWIG installation])
fi
fi
if test "x$USESWIG" = xno; then
SWIG=""
AC_MSG_WARN([$SWIG_ERROR])
if test "x$old_USESWIG" = xno; then
USESWIG="no, need manual download for perl/python bindings"
AC_MSG_WARN([swig was disabled, so you should put needed sources to modules/
Please check http://en.znc.in/wiki/Modperl or http://en.znc.in/wiki/Modpython for details.])
if test -r "$srcdir/modules/modperl/modperl.tar.bz2" -a -r "$srcdir/modules/modpython/modpython.tar.bz2"; then
AC_MSG_NOTICE([modperl and modpython files are found, no SWIG needed])
else
AC_MSG_ERROR([swig was not found. Try --disable-perl --disable-python, or download the necessary sources and use --disable-swig.
Please check http://en.znc.in/wiki/Modperl or http://en.znc.in/wiki/Modpython for details.])
AC_MSG_ERROR([Can not build modperl/modpython. Either install SWIG, or build ZNC from a tarball, or disable modperl/modpython.])
fi
SWIG=""
else
USESWIG=yes
fi
else
if test "x$USESWIG" = "xyes"; then
AC_MSG_WARN([swig is needed only for perl and python, but both are disabled. Disabling swig.])
AC_MSG_WARN([swig is used only for perl and python, but both are disabled. Disabling swig.])
fi
USESWIG=no
USESWIG=not needed
fi
if test "x$PERL" != "xno"; then
@@ -381,16 +379,6 @@ if test "x$PYTHON" != "xno"; then
AC_MSG_ERROR([pkg-config is required for modpython.])
fi
PKG_CHECK_MODULES([python], [$PYTHON >= 3.0],, AC_MSG_ERROR([$PYTHON.pc not found or is wrong. Try --disable-python or install python3.]))
if test "x$USESWIG" = xyes; then :
PKG_CHECK_MODULES([python32], [$PYTHON >= 3.2], [PYTHON_32=yes], [PYTHON_32=no])
if test "x$PYTHON_32" = xyes; then
AC_MSG_NOTICE([python 3.2+ found, requiring swig 2.0.4+])
AC_PROG_SWIG([2.0.4])
if test -z "$SWIG"; then
AC_MSG_ERROR([$SWIG_ERROR])
fi
fi
fi
my_saved_LIBS="$LIBS"
my_saved_CXXFLAGS="$CXXFLAGS"
appendLib $python_LIBS
+91 -61
View File
@@ -26,76 +26,106 @@ dnl @author Rafael Laboissiere <rafael@laboissiere.net>
dnl @author Andrew Collier <abcollier@yahoo.com>
dnl @version 2004-09-20
dnl
dnl Modified by Alexey Sokolov <alexey@alexeysokolov.co.cc> on 2011-05-06
dnl Modified by Alexey Sokolov <alexey@asokolov.org> on 2012-08-08
dnl @license GPLWithACException
dnl
dnl NOTICE: for new code, use http://www.gnu.org/s/autoconf-archive/ax_pkg_swig.html instead.
AC_DEFUN([AC_PROG_SWIG],[
SWIG_ERROR=""
AC_PATH_PROGS([SWIG],[swig swig2.0])
if test -z "$SWIG" ; then
dnl AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
SWIG_ERROR='SWIG is not installed. You should look at http://www.swig.org'
elif test -n "$1" ; then
AC_MSG_CHECKING([for SWIG version])
[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'`]
AC_MSG_RESULT([$swig_version])
if test -n "$swig_version" ; then
# Calculate the required version number components
[required=$1]
[required_major=`echo $required | sed 's/[^0-9].*//'`]
if test -z "$required_major" ; then
[required_major=0]
fi
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
[required_minor=`echo $required | sed 's/[^0-9].*//'`]
if test -z "$required_minor" ; then
[required_minor=0]
fi
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
[required_patch=`echo $required | sed 's/[^0-9].*//'`]
if test -z "$required_patch" ; then
[required_patch=0]
fi
# Calculate the available version number components
[available=$swig_version]
[available_major=`echo $available | sed 's/[^0-9].*//'`]
if test -z "$available_major" ; then
[available_major=0]
fi
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
[available_minor=`echo $available | sed 's/[^0-9].*//'`]
if test -z "$available_minor" ; then
[available_minor=0]
fi
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
[available_patch=`echo $available | sed 's/[^0-9].*//'`]
if test -z "$available_patch" ; then
[available_patch=0]
fi
if test $available_major -lt $required_major; then
SWIG_ERROR='SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org'
elif test $available_major -eq $required_major; then
if test $available_minor -lt $required_minor; then
SWIG_ERROR='SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org'
elif test $available_minor -eq $required_minor; then
if test $available_patch -lt $required_patch; then
SWIG_ERROR='SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org'
if test -n "$1"; then
# Calculate the required version number components
[required=$1]
[required_major=`echo $required | sed 's/[^0-9].*//'`]
if test -z "$required_major" ; then
[required_major=0]
fi
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
[required_minor=`echo $required | sed 's/[^0-9].*//'`]
if test -z "$required_minor" ; then
[required_minor=0]
fi
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
[required_patch=`echo $required | sed 's/[^0-9].*//'`]
if test -z "$required_patch" ; then
[required_patch=0]
fi
fi
# for "python 3 abc set" and "PyInt_FromSize_t in python3" checks
cat <<-END > conftest.i
%module conftest;
%include <pyabc.i>
%include <std_set.i>
%template(SInt) std::set<int>;
END
AC_CACHE_CHECK([for SWIG which produces working output], [znc_cv_path_SWIG], [
AC_PATH_PROGS_FEATURE_CHECK([SWIG], [swig swig2.0], [
echo trying $ac_path_SWIG >&AS_MESSAGE_LOG_FD
$ac_path_SWIG -version >&AS_MESSAGE_LOG_FD
[swig_version=`$ac_path_SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
if test -n "$swig_version"; then
swig_right_version=1
if test -n "$required"; then
# Calculate the available version number components
[available=$swig_version]
[available_major=`echo $available | sed 's/[^0-9].*//'`]
if test -z "$available_major" ; then
[available_major=0]
fi
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
[available_minor=`echo $available | sed 's/[^0-9].*//'`]
if test -z "$available_minor" ; then
[available_minor=0]
fi
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
[available_patch=`echo $available | sed 's/[^0-9].*//'`]
if test -z "$available_patch" ; then
[available_patch=0]
fi
if test $available_major -lt $required_major; then
swig_right_version=0
elif test $available_major -eq $required_major; then
if test $available_minor -lt $required_minor; then
swig_right_version=0
elif test $available_minor -eq $required_minor; then
if test $available_patch -lt $required_patch; then
swig_right_version=0
fi
fi
fi
fi
if test $swig_right_version -eq 1; then
# "python 3 abc set" and "PyInt_FromSize_t in python3" checks
echo "checking behavior of SWIG" >&AS_MESSAGE_LOG_FD
$ac_path_SWIG -python -py3 -c++ -shadow conftest.i >&AS_MESSAGE_LOG_FD && \
echo "wrapper created" >&AS_MESSAGE_LOG_FD && \
grep SInt_discard conftest.py >& /dev/null && \
echo "std::set works" >&AS_MESSAGE_LOG_FD && \
grep '#define PyInt_FromSize_t' conftest_wrap.cxx >& /dev/null && \
echo "PyInt_FromSize_t is defined" >&AS_MESSAGE_LOG_FD && \
znc_cv_path_SWIG=$ac_path_SWIG \
ac_path_SWIG_found=:
rm -f conftest_wrap.cxx conftest.py
else
echo "SWIG version >= $1 is required. You have '$swig_version'" >&AS_MESSAGE_LOG_FD
fi
fi
if test -z "$SWIG_ERROR"; then
AC_MSG_NOTICE([SWIG executable is '$SWIG'])
SWIG_LIB=`$SWIG -swiglib`
AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB'])
else
SWIG=""
fi
else
SWIG_ERROR='Cannot determine SWIG version. You should look at http://www.swig.org'
SWIG=""
fi
echo end trying $ac_path_SWIG >&AS_MESSAGE_LOG_FD
])
])
rm -f conftest.i
AC_SUBST([SWIG], [$znc_cv_path_SWIG])
if test -n "$SWIG"; then
SWIG_LIB=`$SWIG -swiglib`
fi
AC_SUBST([SWIG_LIB])
])