]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Update of python3 support from Karel Slany
authorWillem Toorop <willem@NLnetLabs.nl>
Mon, 12 Sep 2011 09:42:24 +0000 (09:42 +0000)
committerWillem Toorop <willem@NLnetLabs.nl>
Mon, 12 Sep 2011 09:42:24 +0000 (09:42 +0000)
ax_pkg_swig.m4 [moved from ac_pkg_swig.m4 with 63% similarity]
configure.ac

similarity index 63%
rename from ac_pkg_swig.m4
rename to ax_pkg_swig.m4
index 738f69d45eac7f6fc25bc8fecb263e52a6fb92fd..e112f3d3fa5d1a2c34315249270863a9fdd0c7f9 100644 (file)
@@ -1,39 +1,41 @@
 # ===========================================================================
-#              http://autoconf-archive.cryp.to/ac_pkg_swig.html
+#        http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html
 # ===========================================================================
 #
 # SYNOPSIS
 #
-#   AC_PROG_SWIG([major.minor.micro])
+#   AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found])
 #
 # DESCRIPTION
 #
-#   This macro searches for a SWIG installation on your system. If found you
-#   should call SWIG via $(SWIG). You can use the optional first argument to
-#   check if the version of the available SWIG is greater than or equal to
-#   the value of the argument. It should have the format: N[.N[.N]] (N is a
-#   number between 0 and 999. Only the first N is mandatory.)
+#   This macro searches for a SWIG installation on your system. If found,
+#   then SWIG is AC_SUBST'd; if not found, then $SWIG is empty.  If SWIG is
+#   found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd.
 #
-#   If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that
-#   the swig package is this version number or higher.
+#   You can use the optional first argument to check if the version of the
+#   available SWIG is greater than or equal to the value of the argument. It
+#   should have the format: N[.N[.N]] (N is a number between 0 and 999. Only
+#   the first N is mandatory.) If the version argument is given (e.g.
+#   1.3.17), AX_PKG_SWIG checks that the swig package is this version number
+#   or higher.
 #
-#   In configure.in, use as:
-#
-#     AC_PROG_SWIG(1.3.17)
-#     SWIG_ENABLE_CXX
-#     SWIG_MULTI_MODULE_SUPPORT
-#     SWIG_PYTHON
+#   As usual, action-if-found is executed if SWIG is found, otherwise
+#   action-if-not-found is executed.
 #
-# LAST MODIFICATION
+#   In configure.in, use as:
 #
-#   2008-04-12
+#     AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ])
+#     AX_SWIG_ENABLE_CXX
+#     AX_SWIG_MULTI_MODULE_SUPPORT
+#     AX_SWIG_PYTHON
 #
-# COPYLEFT
+# LICENSE
 #
 #   Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
 #   Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
 #   Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
 #   Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
+#   Copyright (c) 2011 Murray Cumming <murrayc@openismus.com>
 #
 #   This program is free software; you can redistribute it and/or modify it
 #   under the terms of the GNU General Public License as published by the
 #   all other use of the material that constitutes the Autoconf Macro.
 #
 #   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Macro Archive. When you make and
-#   distribute a modified version of the Autoconf Macro, you may extend this
-#   special exception to the GPL to apply to your modified version as well.
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
 
-AC_DEFUN([AC_PROG_SWIG],[
-        AC_PATH_PROG([SWIG],[swig])
+#serial 8
+
+AC_DEFUN([AX_PKG_SWIG],[
+        # Ubuntu has swig 2.0 as /usr/bin/swig2.0
+        AC_PATH_PROGS([SWIG],[swig swig2.0])
         if test -z "$SWIG" ; then
-                AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
-                SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
+                m4_ifval([$3],[$3],[:])
         elif test -n "$1" ; then
-                AC_MSG_CHECKING([for SWIG version])
+                AC_MSG_CHECKING([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
@@ -103,19 +107,28 @@ AC_DEFUN([AC_PROG_SWIG],[
                         if test -z "$available_patch" ; then
                                 [available_patch=0]
                         fi
-                        if test $available_major -ne $required_major \
-                                -o $available_minor -ne $required_minor \
-                                -o $available_patch -lt $required_patch ; then
-                                AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version.  You should look at http://www.swig.org])
-                                SWIG='echo "Error: SWIG version >= $1 is required.  You have '"$swig_version"'.  You should look at http://www.swig.org" ; false'
+                        # Convert the version tuple into a single number for easier comparison.
+                        # Using base 100 should be safe since SWIG internally uses BCD values
+                        # to encode its version number.
+                        required_swig_vernum=`expr $required_major \* 10000 \
+                            \+ $required_minor \* 100 \+ $required_patch`
+                        available_swig_vernum=`expr $available_major \* 10000 \
+                            \+ $available_minor \* 100 \+ $available_patch`
+
+                        if test $available_swig_vernum -lt $required_swig_vernum; then
+                                AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version.])
+                                SWIG=''
+                                m4_ifval([$3],[$3],[])
                         else
-                                AC_MSG_NOTICE([SWIG executable is '$SWIG'])
+                                AC_MSG_CHECKING([for SWIG library])
                                 SWIG_LIB=`$SWIG -swiglib`
-                                AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB'])
+                                AC_MSG_RESULT([$SWIG_LIB])
+                                m4_ifval([$2],[$2],[])
                         fi
                 else
                         AC_MSG_WARN([cannot determine SWIG version])
-                        SWIG='echo "Error: Cannot determine SWIG version.  You should look at http://www.swig.org" ; false'
+                        SWIG=''
+                        m4_ifval([$3],[$3],[])
                 fi
         fi
         AC_SUBST([SWIG_LIB])
index 9a2d4a6c166bd8652708a1e7832375a7a4f21bed..5162d0a7acb7e873d0261277c4e5c0e37f96e889 100644 (file)
@@ -97,33 +97,42 @@ if test x_$withval != x_no; then
         if test `$PYTHON -c "import sys; \
             ver = sys.version.split()[[0]]; \
             print(ver >= '2.4.0')"` = "False"; then
-                AC_ERROR([Python version >= 2.4.0 is required])
+                AC_MSG_ERROR([Python version >= 2.4.0 is required])
         fi
        # Have Python
        AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
        ldns_have_python=yes
    fi
 
-   # pass additional Python 3 option to swig
+   # pass additional Python 3 option to SWIG
    if test `$PYTHON -c "import sys; \
        ver = sys.version.split()[[0]]; \
-       print(ver >= '3.0.0')"` = "True"; then
+       print(ver >= '3')"` = "True"; then
        AC_SUBST(SWIGPY3, ["-py3 -DPY3"])
    fi
 
-   # check for swig
+   # check for SWIG
    if test x_$ldns_have_python != x_no; then
-       sinclude(ac_pkg_swig.m4)
-       AC_PROG_SWIG
+        sinclude(ax_pkg_swig.m4)
+
+        # check for >=SWIG-2.0.4 if Python 3.2 used
+        if test `$PYTHON -c "import sys; \
+            ver = sys.version.split()[[0]]; \
+            print(ver >= '3.2')"` = "True"; then
+            AX_PKG_SWIG(2.0.4, [], [AC_MSG_ERROR([SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater.])])
+        else
+            AX_PKG_SWIG
+        fi
+
        if test ! -x "$SWIG"; then
-               AC_ERROR([failed to find swig tool, install it, or do not build pyldns])
+               AC_MSG_ERROR([failed to find SWIG tool, install it, or do not build pyldns])
        else
-               AC_DEFINE(HAVE_SWIG,1,[Define if you have Swig libraries and header files.])
+               AC_DEFINE(HAVE_SWIG,1,[Define if you have SWIG libraries and header files.])
                AC_SUBST(PYLDNS, "pyldns")
                AC_SUBST(swig, "$SWIG")
        fi
    else
-       AC_MSG_RESULT([*** don't have Python, skipping Swig, no pyldns ***]) # '
+       AC_MSG_RESULT([*** don't have Python, skipping SWIG, no pyldns ***]) # '
    fi
 
    # xtra cflags for pyldns