From: Alexandre Duret-Lutz Date: Sun, 17 Aug 2003 18:09:09 +0000 (+0000) Subject: Fix for PR automake/398: X-Git-Tag: Release-1-7b~74 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=6299376d223824cc68d44ba208f5db219cd53cf9;p=automake.git 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. --- diff --git a/ChangeLog b/ChangeLog index c5095dea..f0607008 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-08-17 Alexandre Duret-Lutz + + 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 Fix for PR automake/399: diff --git a/NEWS b/NEWS index c3dd132f..f506a0fd 100644 --- 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 diff --git a/automake.texi b/automake.texi index 4e310c15..4136bcbc 100644 --- a/automake.texi +++ b/automake.texi @@ -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} diff --git a/m4/python.m4 b/m4/python.m4 index a327598b..cd4e0535 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -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 + ]) diff --git a/stamp-vti b/stamp-vti index 03e1d2b6..bf69f5f6 100644 --- 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 diff --git a/tests/Makefile.am b/tests/Makefile.am index f9c2b725..2ebe2c73 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/Makefile.in b/tests/Makefile.in index c8878a50..4052aa6a 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 index 00000000..c1f8851f --- /dev/null +++ b/tests/python4.test @@ -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 < 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 index 00000000..0371829c --- /dev/null +++ b/tests/python5.test @@ -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 < 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 index 00000000..7c797d34 --- /dev/null +++ b/tests/python6.test @@ -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 index 00000000..369d292e --- /dev/null +++ b/tests/python7.test @@ -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 index 00000000..4ddbb149 --- /dev/null +++ b/tests/python8.test @@ -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 <&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 index 00000000..76c29a17 --- /dev/null +++ b/tests/python9.test @@ -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 <&2]) +AC_OUTPUT +EOF + +: > Makefile.am + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --add-missing + +./configure 2>stderr +cat stderr +grep 'GREP ME' stderr diff --git a/version.texi b/version.texi index 03e1d2b6..bf69f5f6 100644 --- a/version.texi +++ b/version.texi @@ -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