From 1979a3f8a818c0b09dc4d83d147e41f1c97eacda Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Mon, 19 Nov 2012 21:04:42 -0600 Subject: [PATCH] Swig and Python macro files updates Use ax_pkg_swig.m4 from the GNU Autoconf Macro Archive as it is actively maintained and update configure.ac accordingly. Moved the Swig test to the bindings section of configure.ac. Refactored the logic of the Swig test. Updated ax_python_devel.m4 to latest version in the Autoconf Macro Archive (removes two email addresses, not other changes). Removed aclocal-include.m4 and lf_warnings.m4 as they were not being used any longer. Update macros definitions in macros/Makefile.am to recent additions and deletion of the local macro files. --- configure.ac | 50 +++++++------- macros/Makefile.am | 4 +- macros/aclocal-include.m4 | 16 ----- macros/ax_pkg_swig.m4 | 135 ++++++++++++++++++++++++++++++++++++++ macros/ax_python_devel.m4 | 6 +- macros/gr_swig.m4 | 87 ------------------------ macros/lf_warnings.m4 | 128 ------------------------------------ 7 files changed, 164 insertions(+), 262 deletions(-) delete mode 100644 macros/aclocal-include.m4 create mode 100644 macros/ax_pkg_swig.m4 delete mode 100644 macros/gr_swig.m4 delete mode 100644 macros/lf_warnings.m4 diff --git a/configure.ac b/configure.ac index fea78578f..3bf135ae9 100644 --- a/configure.ac +++ b/configure.ac @@ -487,6 +487,30 @@ AS_IF([test x"${cf_with_python_binding}" = "xyes"],[ AM_CONDITIONAL([ENABLE_PYTHON], [test x"${cf_with_python_binding}" = "xyes"]) +dnl Only search for Swig if one or more bindings are enabled. +AS_IF([test "x${BINDING_ALL}" != "x"], + [# macros/ax_pkg_swig.m4 + AX_PKG_SWIG([1.3.22], + [BINDINGS="${BINDINGS} bindings" + cf_with_bindings="yes"], + [AC_MSG_ERROR([SWIG is required to build bindings...]) + ])], + [cf_with_bindings="no"]) + +AC_MSG_CHECKING([whether to build bindings]) +AC_MSG_RESULT([$cf_with_bindings]) + +AC_SUBST([BINDINGS]) +AC_SUBST([BINDING_ALL]) +AC_SUBST([BINDING_CHECK]) +AC_SUBST([BINDING_CLEAN]) +AC_SUBST([BINDING_DISTCLEAN]) +AC_SUBST([BINDING_DISTCHECK]) +AC_SUBST([BINDING_INSTALL_EXEC]) +AC_SUBST([BINDING_UNINSTALL]) +AC_SUBST([BINDING_LIST]) +AC_SUBST([BINDING_LIB_TARGETS]) + ## ----------------- ## ## Optional backends ## @@ -582,33 +606,9 @@ done AC_SUBST([ROT_BACKEND_LIST]) AC_SUBST([ROT_BACKENDLNK]) AC_SUBST([ROT_BACKENDEPS]) - - -AC_CHECK_PROG([cf_with_bindings], [swig], [yes], [no], [$PATH]) -AS_IF([test x"${cf_with_bindings}" = "xyes"], [ - cf_with_bindings=no - - SWIG_PROG(1.3.22) - AS_IF([test "${SWIG}" != "false" -a "x${BINDING_ALL}" != "x"], [ - BINDINGS="${BINDINGS} bindings" - cf_with_bindings=yes]) - ]) - -AC_MSG_CHECKING([whether to build bindings]) -AC_MSG_RESULT([$cf_with_bindings]) -AC_SUBST([BINDINGS]) -AC_SUBST([BINDING_ALL]) -AC_SUBST([BINDING_CHECK]) -AC_SUBST([BINDING_CLEAN]) -AC_SUBST([BINDING_DISTCLEAN]) -AC_SUBST([BINDING_DISTCHECK]) -AC_SUBST([BINDING_INSTALL_EXEC]) -AC_SUBST([BINDING_UNINSTALL]) -AC_SUBST([BINDING_LIST]) -AC_SUBST([BINDING_LIB_TARGETS]) - AC_SUBST([AM_CPPFLAGS]) + AC_CONFIG_FILES([Makefile macros/Makefile include/Makefile diff --git a/macros/Makefile.am b/macros/Makefile.am index 20478059e..aaf33d30c 100644 --- a/macros/Makefile.am +++ b/macros/Makefile.am @@ -1,14 +1,13 @@ ## Please update this variable if any new macros are created MACROS = \ - aclocal-include.m4 \ ax_append_flag.m4 \ ax_cflags_warn_all.m4 \ + ax_pkg_swig \ ax_pthread.m4 \ ax_python_devel.m4 \ gr_doxygen.m4 \ gr_pwin32.m4 \ - gr_swig.m4 \ hl_getaddrinfo.m4 \ perl.m4 \ tcl.m4 @@ -19,4 +18,3 @@ MAINTAINERCLEANFILES=macros.dep @MAINT@macros.dep: Makefile.am @MAINT@ @echo '$$(top_srcdir)/aclocal.m4: $(MACROS:%=macros/%)' > $@ - diff --git a/macros/aclocal-include.m4 b/macros/aclocal-include.m4 deleted file mode 100644 index abf6533fe..000000000 --- a/macros/aclocal-include.m4 +++ /dev/null @@ -1,16 +0,0 @@ -# aclocal-include.m4 -# -# This macro adds the name macrodir to the set of directories -# that `aclocal' searches for macros. - -# serial 1 - -dnl AM_ACLOCAL_INCLUDE(macrodir) -AC_DEFUN([AM_ACLOCAL_INCLUDE], -[ - AM_CONDITIONAL(INSIDE_GNOME_COMMON, test x = y) - - test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" - - for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done -]) diff --git a/macros/ax_pkg_swig.m4 b/macros/ax_pkg_swig.m4 new file mode 100644 index 000000000..d836eec8f --- /dev/null +++ b/macros/ax_pkg_swig.m4 @@ -0,0 +1,135 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html +# =========================================================================== +# +# SYNOPSIS +# +# 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, +# 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. +# +# 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. +# +# As usual, action-if-found is executed if SWIG is found, otherwise +# action-if-not-found is executed. +# +# In configure.in, use as: +# +# 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 +# +# LICENSE +# +# Copyright (c) 2008 Sebastian Huber +# Copyright (c) 2008 Alan W. Irwin +# Copyright (c) 2008 Rafael Laboissiere +# Copyright (c) 2008 Andrew Collier +# Copyright (c) 2011 Murray Cumming +# +# 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 +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# 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 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. + +#serial 11 + +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 + m4_ifval([$3],[$3],[:]) + elif test -n "$1" ; then + 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 + # 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 + # 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_CHECKING([for SWIG library]) + SWIG_LIB=`$SWIG -swiglib` + AC_MSG_RESULT([$SWIG_LIB]) + m4_ifval([$2],[$2],[]) + fi + else + AC_MSG_WARN([cannot determine SWIG version]) + SWIG='' + m4_ifval([$3],[$3],[]) + fi + fi + AC_SUBST([SWIG_LIB]) +]) diff --git a/macros/ax_python_devel.m4 b/macros/ax_python_devel.m4 index a62b860de..def4b4aa8 100644 --- a/macros/ax_python_devel.m4 +++ b/macros/ax_python_devel.m4 @@ -34,9 +34,9 @@ # LICENSE # # Copyright (c) 2009 Sebastian Huber -# Copyright (c) 2009 Alan W. Irwin +# Copyright (c) 2009 Alan W. Irwin # Copyright (c) 2009 Rafael Laboissiere -# Copyright (c) 2009 Andrew Collier +# Copyright (c) 2009 Andrew Collier # Copyright (c) 2009 Matteo Settenvini # Copyright (c) 2009 Horst Knorr # @@ -66,7 +66,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 8 +#serial 11 AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) AC_DEFUN([AX_PYTHON_DEVEL],[ diff --git a/macros/gr_swig.m4 b/macros/gr_swig.m4 deleted file mode 100644 index 1adf4d65c..000000000 --- a/macros/gr_swig.m4 +++ /dev/null @@ -1,87 +0,0 @@ -dnl -dnl Copyright 2003 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -dnl Boston, MA 02111-1307, USA. -dnl - -# SWIG_PROG([required-version]) -# -# Checks for the SWIG program. If found you can (and should) call SWIG via $(SWIG). -# You can use the optional first argument to check if the version of the available SWIG -# is greater 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.) -AC_DEFUN([SWIG_PROG],[ - AC_REQUIRE([AC_PROG_MAKE_SET]) - AC_CHECK_PROG(SWIG,swig,[`which swig`]) - if test -z "$SWIG" ; then - AC_MSG_WARN([cannot find 'swig' program]) - SWIG=false - elif test -n "$1" ; then - AC_MSG_CHECKING([for SWIG version]) - swig_version=`$SWIG -version 2>&1 | \ - awk '/^SWIG Version [[0-9]+\.[0-9]+\.[0-9]]+.*$/ { split($[3],a,"[[^.0-9]]"); print a[[1]] }'` - AC_MSG_RESULT([$swig_version]) - if test -n "$swig_version" ; then - swig_version=`echo $swig_version | \ - awk '{ split($[1],a,"\."); print [a[1]*1000000+a[2]*1000+a[3]] }' 2>/dev/null` - swig_required_version=`echo $1 | \ - awk '{ split($[1],a,"\."); print [a[1]*1000000+a[2]*1000+a[3]] }' 2>/dev/null` - if test $swig_required_version -gt $swig_version ; then - AC_MSG_WARN([SWIG version $1 required]) - SWIG=false - fi - else - AC_MSG_WARN([cannot determine SWIG version]) - SWIG=false - fi - fi -]) - -# SWIG_ENABLE_CXX() -# -# Enable swig C++ support. This effects all invocations of $(SWIG). -AC_DEFUN([SWIG_ENABLE_CXX],[ - AC_REQUIRE([SWIG_PROG]) - AC_REQUIRE([AC_PROG_CXX]) - if test "$SWIG" != "false" ; then - SWIG="$SWIG -c++" - fi -]) - -# SWIG_PYTHON([use-shadow-classes]) -# -# Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS), -# $(SWIG_PYTHON_LIB) and $(SWIG_PYTHON_OPT) output variables. -# $(SWIG_PYTHON_OPT) contains all necessary swig options to generate -# code for Python. If you need multi module support use -# $(SWIG_PYTHON_LIB) (provided by the SWIG_MULTI_MODULE_SUPPORT() -# macro) to link against the appropriate library. It contains the -# SWIG Python runtime library that is needed by the type check system -# for example. - -AC_DEFUN([SWIG_PYTHON],[ - AC_REQUIRE([SWIG_PROG]) - AC_REQUIRE([PYTHON_DEVEL]) - if test "$SWIG" != "false" ; then - AC_SUBST(SWIG_PYTHON_LIB,[-lswigpy]) -dnl test ! "x$1" = "xno" && swig_shadow=" -shadow" || swig_shadow="" -dnl AC_SUBST(SWIG_PYTHON_OPT,[-python$swig_shadow]) - AC_SUBST(SWIG_PYTHON_OPT,[-python]) - fi - AC_SUBST(SWIG_PYTHON_CPPFLAGS,[$PYTHON_CPPFLAGS]) -]) diff --git a/macros/lf_warnings.m4 b/macros/lf_warnings.m4 deleted file mode 100644 index 0ebb97ef9..000000000 --- a/macros/lf_warnings.m4 +++ /dev/null @@ -1,128 +0,0 @@ -dnl Copyright (C) 1988 Eleftherios Gkioulekas -dnl -dnl This program is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this program; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -dnl -dnl As a special exception to the GNU General Public License, if you -dnl distribute this file as part of a program that contains a configuration -dnl script generated by Autoconf, you may include it under the same -dnl distribution terms that you use for the rest of that program. - -# -------------------------------------------------------------------------- -# Check whether the C++ compiler accepts a certain flag -# If it does it adds the flag to CXXFLAGS -# If it does not then it returns an error to lf_ok -# Usage: -# LF_CHECK_CXX_FLAG(-flag1 -flag2 -flag3 ...) -# ------------------------------------------------------------------------- - -AC_DEFUN([LF_CHECK_CXX_FLAG],[ - echo 'void f(){}' > conftest.cc - for i in $1 - do - AC_MSG_CHECKING([whether $CXX accepts $i]) - if test -z "`${CXX} $i -c conftest.cc 2>&1`" - then - CXXFLAGS="${CXXFLAGS} $i" - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - done - rm -f conftest.cc conftest.o -]) - -# -------------------------------------------------------------------------- -# Check whether the C compiler accepts a certain flag -# If it does it adds the flag to CFLAGS -# If it does not then it returns an error to lf_ok -# Usage: -# LF_CHECK_CC_FLAG(-flag1 -flag2 -flag3 ...) -# ------------------------------------------------------------------------- - -AC_DEFUN([LF_CHECK_CC_FLAG],[ - echo 'void f(){}' > conftest.c - for i in $1 - do - AC_MSG_CHECKING([whether $CC accepts $i]) - if test -z "`${CC} $i -c conftest.c 2>&1`" - then - CFLAGS="${CFLAGS} $i" - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - done - rm -f conftest.c conftest.o -]) - -# -------------------------------------------------------------------------- -# Check whether the Fortran compiler accepts a certain flag -# If it does it adds the flag to FFLAGS -# If it does not then it returns an error to lf_ok -# Usage: -# LF_CHECK_F77_FLAG(-flag1 -flag2 -flag3 ...) -# ------------------------------------------------------------------------- - -AC_DEFUN([LF_CHECK_F77_FLAG],[ - cat << EOF > conftest.f -c....:++++++++++++++++++++++++ - PROGRAM MAIN - PRINT*,'Hello World!' - END -EOF - for i in $1 - do - AC_MSG_CHECKING([whether $F77 accepts $i]) - if test -z "`${F77} $i -c conftest.f 2>&1`" - then - FFLAGS="${FFLAGS} $i" - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - done - rm -f conftest.f conftest.o -]) - -# ---------------------------------------------------------------------- -# Provide the configure script with an --with-warnings option that -# turns on warnings. Call this command AFTER you have configured ALL your -# compilers. -# ---------------------------------------------------------------------- - -AC_DEFUN([LF_SET_WARNINGS],[ - dnl Check for --with-warnings - AC_MSG_CHECKING([whether user wants warnings]) - AC_ARG_WITH(warnings, - [ --with-warnings Turn on warnings], - [ lf_warnings=yes ], [ lf_warnings=no ]) - lf_warnings=yes # hard code for now -eb - AC_MSG_RESULT($lf_warnings) - - dnl Warnings for the two main compilers - cc_warning_flags="-Wall" - cxx_warning_flags="-Wall -Woverloaded-virtual" - if test $lf_warnings = yes - then - if test -n "${CC}" - then - LF_CHECK_CC_FLAG($cc_warning_flags) - fi - if test -n "${CXX}" - then - LF_CHECK_CXX_FLAG($cxx_warning_flags) - fi - fi -])