changeset 96:66bd40c8d36e

Make Pytave compile against Octave 3.3+. Fix configuration bugs.
author David Grundberg <individ@acc.umu.se>
date Sat, 11 Sep 2010 18:37:08 +0200
parents 9ddccdf6d318
children 348090c479e2
files configure.ac m4/ax_octave.m4 pytave.cc
diffstat 3 files changed, 53 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Mon Dec 21 15:30:13 2009 +0100
+++ b/configure.ac	Sat Sep 11 18:37:08 2010 +0200
@@ -4,6 +4,27 @@
 AC_PREREQ(2.61)
 AC_INIT(pytave, 0.1.1, [[https://bugs.launchpad.net/pytave]])
 
+AC_ARG_WITH(numpy,
+	      [AS_HELP_STRING([--with-numpy],
+			      [use NumPy module (experimental)
+			      @<:@default=yes@:>@])],
+			      [pytave_enable_numpy="$withval"],
+			      [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="$withval"],
+			      [pytave_enable_numeric=no])
+
+# 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.])
+])
+
 # Some important programs.
 AC_LANG(C++)
 AC_PROG_CXX
@@ -15,22 +36,6 @@
 AC_CONFIG_SRCDIR([pytave.cc])
 AC_CONFIG_HEADER([config.h])
 
-AC_PRESERVE_HELP_ORDER
-
-AC_ARG_WITH(numpy,
-	      [AS_HELP_STRING([--with-numpy],
-			      [use NumPy module (experimental)
-			      @<:@default=yes@:>@])],
-			      [pytave_enable_numpy="$enableval"],
-			      [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
 $pytave_missing_libs")
@@ -42,15 +47,8 @@
 # Pick a Python library to use
 AX_PYTHON_DEVEL([], [], [addmissing([Python development files])])
 
-# 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",
+AS_IF(test "x$pytave_enable_numpy" = "xno",
 [
 	pytave_matrix_interface="numeric"
 ],
@@ -59,7 +57,7 @@
 ])
 
 # Look for selected matrix interface
-AS_IF(test "$pytave_matrix_interface" == "numpy",
+AS_IF(test "$pytave_matrix_interface" = "numpy",
 [
    AX_PYTHON_NUMPY(
    [
@@ -174,6 +172,16 @@
 
 ========================================================================])
 
+AS_IF(test "x$pytave_have_uselocale" = "xno",
+[
+	AC_MSG_WARN([This system doesn't have uselocale support.
+           The Octave interpreter will NOT work correctly in any
+           locale but the C (POSIX) locale.  Pytave would use the
+           uselocale function to work around this limitation.  Pytave
+           can be compiled without it but will only work correcly in C
+           (POSIX) locale.])
+])
+
 AS_IF(test -n "$pytave_missing_libs",
 [
 	AC_MSG_ERROR([[Configuration failure. Halt.]])
--- a/m4/ax_octave.m4	Mon Dec 21 15:30:13 2009 +0100
+++ b/m4/ax_octave.m4	Sat Sep 11 18:37:08 2010 +0200
@@ -133,11 +133,21 @@
 	])
 
 	AS_IF([test -z "$ax_octave_ok"], [
+		# After the 3.2 series, the include path ends with
+		# /octave, but that part we don't want.
+		AC_MSG_CHECKING([[if the include directory is 3.3+ style]])
+		if test -f "$OCTAVE_INCLUDEDIR/oct.h" ; then
+			OCTAVE_INCLUDEDIR="$OCTAVE_INCLUDEDIR/.."
+			AC_MSG_RESULT([yes])
+		else
+			AC_MSG_RESULT([no])
+		fi
+
 		OCTAVE_LDFLAGS="-L$OCTAVE_LIBRARYDIR"
 		OCTAVE_LIBS="-loctave -lcruft -loctinterp"
 		OCTAVE_CPPFLAGS="-I$OCTAVE_INCLUDEDIR"
 
-		AC_CACHE_CHECK([whether linking to Octave library works], [ax_octave_cv_lib_octave],
+		AC_CACHE_CHECK([whether linking to Octave works], [ax_octave_cv_lib_octave],
 		[
 			ax_octave_cv_lib_octave=no
 
@@ -146,9 +156,10 @@
 			ax_octave_old_ldflags="$LDFLAGS"
 			ax_octave_old_cppflags="$CPPFLAGS"
 			ax_octave_old_libs="$LIBS"
-			LDFLAGS="$OCTAVE_LDFLAGS $LDFLAGS"
-			CPPFLAGS="$OCTAVE_CPPFLAGS $CPPFLAGS"
-			LIBS="$OCTAVE_LIBS $LIBS"
+
+			LDFLAGS="$OCTAVE_LDFLAGS $ax_octave_old_ldflags"
+			CPPFLAGS="$OCTAVE_CPPFLAGS $ax_octave_old_cppflags"
+			LIBS="$OCTAVE_LIBS $ax_octave_old_libs"
 
 			AC_LANG_ASSERT(C++)
 			AC_LINK_IFELSE(
@@ -158,6 +169,7 @@
 				[[MatrixType()]]),
 				[ax_octave_cv_lib_octave=yes],
 				[ax_octave_cv_lib_octave=no])
+
 			LDFLAGS="$ax_octave_old_ldflags"
 			CPPFLAGS="$ax_octave_old_cppflags"
 			LIBS="$ax_octave_old_libs"
--- a/pytave.cc	Mon Dec 21 15:30:13 2009 +0100
+++ b/pytave.cc	Sat Sep 11 18:37:08 2010 +0200
@@ -76,13 +76,14 @@
       const char* argv[] = {"octave",
                             "--no-line-editing",
                             "--no-history",
+                            "--no-init-file",
                             "--silent",
                             NULL};
-      int argc = 4;
+      int argc = 5;
 
       if (silent) {
-         argv[3] = 0;
-         argc = 3;
+         argc--;
+         argv[argc] = 0;
       }
 
 #ifdef HAVE_USELOCALE