]> sourceware.org Git - automake.git/commitdiff
Fix for PR automake/398:
authorAlexandre Duret-Lutz <adl@gnu.org>
Sun, 17 Aug 2003 18:09:09 +0000 (18:09 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sun, 17 Aug 2003 18:09:09 +0000 (18:09 +0000)
* m4/python.m4: Do not call AC_PATH_PROGS if $PYTHON is already
set.  Display `none' instead of `:' and $PYTHON is set to `:'
when no suitable interpreter is found.  Honor ACTION-IF-FOUND and
ACTION-IF-NOT-FOUND.
* automake.texi (Python): Document ACTION-IF-FOUND and
ACTION-IF-NOT-FOUND.
* tests/python4.test, tests/python5.test, tests/python6.test,
tests/python7.test, tests/python8.test, tests/python9.test: New
files.
* tests/Makefile.am (TESTS): Add them.
Report from Per Cederqvist.

14 files changed:
ChangeLog
NEWS
automake.texi
m4/python.m4
stamp-vti
tests/Makefile.am
tests/Makefile.in
tests/python4.test [new file with mode: 0755]
tests/python5.test [new file with mode: 0755]
tests/python6.test [new file with mode: 0755]
tests/python7.test [new file with mode: 0755]
tests/python8.test [new file with mode: 0755]
tests/python9.test [new file with mode: 0755]
version.texi

index c5095deaed09feb6f714f6e55316964700a8c555..f0607008653d8d789a2c795c1e65aa30f6deffc1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2003-08-17  Alexandre Duret-Lutz  <adl@gnu.org>
+
+       Fix for PR automake/398:
+       * m4/python.m4: Do not call AC_PATH_PROGS if $PYTHON is already
+       set.  Display `none' instead of `:' and $PYTHON is set to `:'
+       when no suitable interpreter is found.  Honor ACTION-IF-FOUND and
+       ACTION-IF-NOT-FOUND.
+       * automake.texi (Python): Document ACTION-IF-FOUND and
+       ACTION-IF-NOT-FOUND.
+       * tests/python4.test, tests/python5.test, tests/python6.test,
+       tests/python7.test, tests/python8.test, tests/python9.test: New
+       files.
+       * tests/Makefile.am (TESTS): Add them.
+       Report from Per Cederqvist.
+
 2003-08-13  Alexandre Duret-Lutz  <adl@gnu.org>
 
        Fix for PR automake/399:
diff --git a/NEWS b/NEWS
index c3dd132f385951e4b935733f1a3954ac9a7569b0..f506a0fd4686587395981e11b9130200dee1645e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,10 @@ New in 1.7a:
     links as part of the distclean target and including source files in
     distributions.
 
+  - AM_PATH_PYTHON now support ACTION-IF-FOUND and ACTION-IF-NOT-FOUND
+    argument.  The latter can be used to override the default behavior
+    (which is to abort).
+
 * Obsolete features
 
   - lisp_DATA is now allowed.  If you are using the empty ELCFILES
index 4e310c15e5ccccaa93e886e64901f08b3e8491ac..4136bcbce0d32c350fdfc916a64676f531136f32 100644 (file)
@@ -4392,17 +4392,45 @@ variables: @samp{python_PYTHON}, @samp{pkgpython_PYTHON},
 @samp{pyexecdir_PYTHON}, @samp{pkgpyexecdir_PYTHON}, depending where you
 want your files installed.
 
-@code{AM_PATH_PYTHON} takes a single optional argument.  This argument,
-if present, is the minimum version of Python which can be used for this
-package.  If the version of Python found on the system is older than the
-required version, then @code{AM_PATH_PYTHON} will cause an error.
+@code{AM_PATH_PYTHON([@var{VERSION}], [@var{ACTION-IF-FOUND}],
+[@var{ACTION-IF-NOT-FOUND}])} takes three optional arguments.  It will
+search a Python interpreter on the system.  The first argument, if
+present, is the minimum version of Python required for this package:
+@code{AM_PATH_PYTHON} will skip any Python interpreter which is older
+than @var{VERSION}.  If an interpreter is found and satisfies
+@var{VERSION}, then @var{ACTION-IF-FOUND} is run.  Otherwise,
+@var{ACTION-IF-NOT-FOUND} is run.
+
+If @var{ACTION-IF-NOT-FOUND} is not specified, the default is to abort
+configure.  This is fine when Python is an absolute requirement for the
+package.  Therefore if Python >= 2.2 is only @emph{optional} to the
+package, @code{AM_PATH_PYTHON} could be called as follows.
+
+@example
+  AM_PATH_PYTHON(2.2,, :)
+@end example
 
 @code{AM_PATH_PYTHON} creates several output variables based on the
 Python installation found during configuration.
 
 @vtable @code
 @item PYTHON
-The name of the Python executable.
+The name of the Python executable, or @code{:} if no suitable
+interpreter could be found.
+
+Assuming @var{ACTION-IF-NOT-FOUND} is used (otherwise @file{./configure}
+will abort if Python is absent), the value of @code{PYTHON} can be used
+to setup a conditional in order to disable the relevant part of a build
+as follows.
+
+@example
+  AM_PATH_PYTHON(,, :)
+  AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
+@end example
+
+
+If the @var{ACTION-IF-NOT-FOUND}
+is specified
 
 @item PYTHON_VERSION
 The Python version number, in the form @var{major}.@var{minor}
index a327598bbd3e07165c94505571b020058e02d757..cd4e0535d2d8e37122bbe7f3c4e26efc65627798 100644 (file)
@@ -21,7 +21,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 # 02111-1307, USA.
 
-# AM_PATH_PYTHON([MINIMUM-VERSION])
+# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 
 # Adds support for distributing Python modules and packages.  To
 # install modules, copy them to $(pythondir), using the python_PYTHON
@@ -56,7 +56,10 @@ AC_DEFUN([AM_PATH_PYTHON],
   m4_if([$1],[],[
     dnl No version check is needed.
     # Find any Python interpreter.
-    AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST)
+    if test -z "$PYTHON"; then
+      PYTHON=:
+      AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST)
+    fi
     am_display_PYTHON=python
   ], [
     dnl A version check is needed.
@@ -71,18 +74,25 @@ AC_DEFUN([AM_PATH_PYTHON],
       # VERSION.
       AC_CACHE_CHECK([for a Python interpreter with version >= $1],
        [am_cv_pathless_PYTHON],[
-       for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST : ; do
-         if test "$am_cv_pathless_PYTHON" = : ; then
-           AC_MSG_ERROR([no suitable Python interpreter found])
-         fi
+       for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
+         test "$am_cv_pathless_PYTHON" = none && break
          AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
        done])
       # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
-      AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+      if test "$am_cv_pathless_PYTHON" = none; then
+       PYTHON=:
+      else
+        AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+      fi
       am_display_PYTHON=$am_cv_pathless_PYTHON
     fi
   ])
 
+  if test "$PYTHON" = :; then
+  dnl Run any user-specified action, or abort.
+    m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
+  else
+
   dnl Query Python for its version number.  Getting [:3] seems to be
   dnl the best way to do this; it's what "site.py" does in the standard
   dnl library.
@@ -142,6 +152,11 @@ AC_DEFUN([AM_PATH_PYTHON],
   dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
 
   AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
+
+  dnl Run any user-specified action.
+  $2
+  fi
+
 ])
 
 
index 03e1d2b64371161c21becbccad33f877c2d98025..bf69f5f69a6c31f67890b5807a02fb0c9baa5e27 100644 (file)
--- a/stamp-vti
+++ b/stamp-vti
@@ -1,4 +1,4 @@
-@set UPDATED 31 July 2003
-@set UPDATED-MONTH July 2003
+@set UPDATED 14 August 2003
+@set UPDATED-MONTH August 2003
 @set EDITION 1.7a
 @set VERSION 1.7a
index f9c2b72585b21d66525e64721b4bf9c0005bf7e1..2ebe2c73dc56c7971ebfccefdc64398b361710e5 100644 (file)
@@ -361,6 +361,12 @@ proginst.test \
 python.test \
 python2.test \
 python3.test \
+python4.test \
+python5.test \
+python6.test \
+python7.test \
+python8.test \
+python9.test \
 recurs.test \
 recurs2.test \
 remake.test \
index c8878a504a032fc2d1dd90c4208800775f27e130..4052aa6a0053fec658c3e8bf5e60ea85f36d9bd4 100644 (file)
@@ -472,6 +472,12 @@ proginst.test \
 python.test \
 python2.test \
 python3.test \
+python4.test \
+python5.test \
+python6.test \
+python7.test \
+python8.test \
+python9.test \
 recurs.test \
 recurs2.test \
 remake.test \
diff --git a/tests/python4.test b/tests/python4.test
new file mode 100755 (executable)
index 0000000..c1f8851
--- /dev/null
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 autoconf; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Simulate no Python
+./configure PYTHON=: 2>stderr && exit 1
+cat stderr
+grep 'no suitable Python interpreter found' stderr
diff --git a/tests/python5.test b/tests/python5.test
new file mode 100755 (executable)
index 0000000..0371829
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 autoconf; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+# Same as python4.test, but requiring a version.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON(9999.9)
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr && exit 1
+cat stderr
+grep 'no suitable Python interpreter found' stderr
diff --git a/tests/python6.test b/tests/python6.test
new file mode 100755 (executable)
index 0000000..7c797d3
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 autoconf; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+# Same as python4.test, but using a custom ACTION-IF-NOT-FOUND.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<\EOF
+AM_PATH_PYTHON(,, [echo "GREP ME$PYTHON" >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Simulate no Python
+./configure PYTHON=: 2>stderr
+cat stderr
+grep 'GREP ME:' stderr
diff --git a/tests/python7.test b/tests/python7.test
new file mode 100755 (executable)
index 0000000..369d292
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 autoconf; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+# Same as python6.test, but requiring a version.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<\EOF
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON(9999.9,, [echo "GREP ME$PYTHON" >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr
+cat stderr
+grep 'GREP ME:' stderr
diff --git a/tests/python8.test b/tests/python8.test
new file mode 100755 (executable)
index 0000000..4ddbb14
--- /dev/null
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 autoconf; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test ACTION-IF-TRUE in AM_PATH_PYTHON.
+
+required=python
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+AM_PATH_PYTHON(, [echo 'GREP ME' >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr
+cat stderr
+grep 'GREP ME' stderr
diff --git a/tests/python9.test b/tests/python9.test
new file mode 100755 (executable)
index 0000000..76c29a1
--- /dev/null
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 autoconf; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test ACTION-IF-TRUE in AM_PATH_PYTHON.
+# Same as python8.test, but requiring a version.
+
+required=python
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+AM_PATH_PYTHON(0.0, [echo 'GREP ME' >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr
+cat stderr
+grep 'GREP ME' stderr
index 03e1d2b64371161c21becbccad33f877c2d98025..bf69f5f69a6c31f67890b5807a02fb0c9baa5e27 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 31 July 2003
-@set UPDATED-MONTH July 2003
+@set UPDATED 14 August 2003
+@set UPDATED-MONTH August 2003
 @set EDITION 1.7a
 @set VERSION 1.7a
This page took 0.058631 seconds and 5 git commands to generate.