changeset 89:82459c7db185 numpyconf

Make NumPy default. Rework configure script. Check for Numeric extentions for Python.
author David <david@stacey>
date Thu, 24 Sep 2009 20:22:08 +0200
parents 834c2c1ac28e
children 935d69473ebd 7deeeaef324f
files ChangeLog configure.ac m4/ax_python_numeric.m4
diffstat 3 files changed, 142 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Sep 24 19:22:47 2009 +0200
+++ b/ChangeLog	Thu Sep 24 20:22:08 2009 +0200
@@ -1,3 +1,10 @@
+2009-09-24  David Grundberg  <individ@acc.umu.se>
+
+	* configure.ac: Make NumPy default. Replace --enable flags with
+	--with-type flags. Rework output. 
+	* m4/ax_python_numeric.m4 (AX_PYTHON_NUMERIC): Check for Numeric
+	extentions for Python.
+
 2009-09-24  David Grundberg  <individ@acc.umu.se>
 
 	* m4/ax_python_numpy.m4 (AX_PYTHON_NUMPY): Restore CPPFLAGS.
--- a/configure.ac	Thu Sep 24 19:22:47 2009 +0200
+++ b/configure.ac	Thu Sep 24 20:22:08 2009 +0200
@@ -17,12 +17,19 @@
 
 AC_PRESERVE_HELP_ORDER
 
-AC_ARG_ENABLE(numpy,
-	      [AS_HELP_STRING([--enable-numpy],
+AC_ARG_WITH(numpy,
+	      [AS_HELP_STRING([--with-numpy],
 			      [use NumPy module (experimental)
-			      @<:@default=check@:>@])],
+			      @<:@default=yes@:>@])],
 			      [pytave_enable_numpy="$enableval"],
-			      [pytave_enable_numpy=check])
+			      [pytave_enable_numpy=yes])
+
+AC_ARG_WITH(numeric,
+	      [AS_HELP_STRING([--with-numeric],
+			      [use legacy Numeric module. NumPy must be disabled.
+			      @<:@default=no@:>@])],
+			      [pytave_enable_numeric="$enableval"],
+			      [pytave_enable_numeric=no])
 
 dnl Define a convenience m4 macro for appending to pytave_missing_libs
 define(addmissing,pytave_missing_libs="$1
@@ -35,17 +42,35 @@
 # Pick a Python library to use
 AX_PYTHON_DEVEL([], [], [addmissing([Python development files])])
 
-AS_IF(test "x$pytave_enable_numpy" != "xno",
+# Check for bad arguments.
+AS_IF(test "x$pytave_enable_numpy" == "xyes" -a "x$pytave_enable_numeric" == "xyes" -o dnl
+"x$pytave_enable_numpy" == "xno" -a "x$pytave_enable_numeric" == "xno", 
+[
+	AC_ERROR([NumPy or Numeric: select one.])
+])
+
+# Select Python matrix interface, prefer numpy.
+AS_IF(test "x$pytave_enable_numpy" == "xno",
+[
+	pytave_matrix_interface="numeric"
+],
+[
+	pytave_matrix_interface="numpy"
+])
+
+# Look for selected matrix interface
+AS_IF(test "$pytave_matrix_interace" == "numpy",
 [
    AX_PYTHON_NUMPY(
    [
        AC_DEFINE([HAVE_NUMPY], 1, [Define if using NumPy])
-       pytave_enable_numpy=yes
    ],
    [
-       AS_IF(test "x$pytave_enable_numpy" == "xyes", [addmissing([NumPy development files])])
-       pytave_enable_numpy='not found'
+       addmissing([NumPy development files])
    ])
+],
+[
+   AX_PYTHON_NUMERIC([], [addmissing([Numeric development files])])
 ])
 
 # Look for boost::python
@@ -144,7 +169,7 @@
   Python boost ....... $BOOST_PYTHON_LIB
 
 Features
-  NumPy .............. $pytave_enable_numpy
+  matrix interface ... $pytave_matrix_interface
   uselocale .......... $pytave_have_uselocale
 
 ========================================================================])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/ax_python_numeric.m4	Thu Sep 24 20:22:08 2009 +0200
@@ -0,0 +1,101 @@
+# ===========================================================================
+#
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PYTHON_NUMERIC([ACTION_IF_FOUND], [ACTION_IF_NOT_FOUND])
+#
+# DESCRIPTION
+#
+#
+# LAST MODIFICATION
+#
+#   2009-08-24
+#
+# COPYING
+#
+#   Copyright (c) 2009 David Grundberg
+#
+#   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 <http://www.gnu.org/licenses/>.
+#
+#   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 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.
+
+AC_DEFUN([AX_PYTHON_NUMERIC],[
+	AC_MSG_CHECKING([for python])
+	AS_IF([test -z "$PYTHON"], [
+		AC_MSG_RESULT([unknown])
+	],[
+		AC_MSG_RESULT([$PYTHON])
+	])
+
+	AS_IF([true], [
+
+		AC_CACHE_CHECK([whether linking to numeric library works], [ax_python_numeric_cv_check],
+		[
+			ax_python_numeric_cv_check=no
+
+			AC_LANG_PUSH([C++])
+
+			ax_python_numeric_cppflags="$CPPFLAGS"
+			ax_python_numeric_ldflags="$LDFLAGS"
+			CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
+			LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
+			
+			AC_LANG_ASSERT(C++)
+			AC_LINK_IFELSE(
+			AC_LANG_PROGRAM(
+				[[
+#define PY_ARRAY_UNIQUE_SYMBOL my_array_symbol
+#include <Python.h>
+#include <Numeric/arrayobject.h>
+typedef int npy_intp;
+]],
+				[[ &PyArray_FromDims; ]]),
+				[ax_python_numeric_cv_check=yes],
+				[ax_python_numeric_cv_check=no])
+			CPPFLAGS="$ax_python_numeric_cppflags"
+			LDFLAGS="$ax_python_numeric_ldflags"
+			
+			AC_LANG_POP([C++])
+		])
+	])
+
+	AS_IF([test "x$ax_python_numeric_cv_check" != "xyes"], [
+		AC_MSG_WARN([[
+========================================================================
+Can not link with Numeric.
+
+Make sure the Numeric development package is installed.
+========================================================================]])
+	])
+
+	# Execute ACTION_IF_FOUND or ACTION_IF_NOT_FOUND
+	if test "x$ax_python_numeric_cv_check" == "xyes" ; then
+		m4_ifvaln([$1],[$1],[:])dnl
+		m4_ifvaln([$2],[else $2])dnl
+	fi
+
+])