]> sourceware.org Git - automake.git/commitdiff
* m4/python.m4 (AM_PATH_PYTHON): Check all known Python interpreters
authorAlexandre Duret-Lutz <adl@gnu.org>
Wed, 12 Dec 2001 11:11:38 +0000 (11:11 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Wed, 12 Dec 2001 11:11:38 +0000 (11:11 +0000)
in loop until we find one the satisfies the user supplied version.
Add python2 to the list of known interpreters.  Don't use
changequote.  Cache the calculation of PYTHON_VERSION and
PYTHON_PLATFORM.
(AM_PYTHON_CHECK_VERSION): New function, extracted from
AM_PATH_PYTHON and modernized.
* m4/runlog.m4: New file.
* m4/Makefile.am (m4data_DATA): Add it.

ChangeLog
m4/Makefile.am
m4/Makefile.in
m4/python.m4
m4/runlog.m4 [new file with mode: 0644]

index 8255fd13794237f0c98e38707386c0db85b4e06f..50f91a20a6fe818049076fa611be896a1c34808a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2001-12-12  Alexandre Duret-Lutz  <duret_g@epita.fr>
+
+       * m4/python.m4 (AM_PATH_PYTHON): Check all known Python interpreters
+       in loop until we find one the satisfies the user supplied version.
+       Add python2 to the list of known interpreters.  Don't use
+       changequote.  Cache the calculation of PYTHON_VERSION and
+       PYTHON_PLATFORM.
+       (AM_PYTHON_CHECK_VERSION): New function, extracted from
+       AM_PATH_PYTHON and modernized.
+       * m4/runlog.m4: New file.
+       * m4/Makefile.am (m4data_DATA): Add it.
+
 2001-12-06  Alexandre Duret-Lutz  <duret_g@epita.fr>
 
        * tests/confsub.test, tests/depdist.test, tests/extra5.test,
index 1676f47c63b9f390d0fe22a821cc15e61c629828..f0d2eda8132479744fc2f170652e09b76744b601 100644 (file)
@@ -24,7 +24,7 @@ m4datadir = $(datadir)/aclocal
 m4data_DATA = as.m4 auxdir.m4 ccstdc.m4 cond.m4 depend.m4 depout.m4 \
 dmalloc.m4 gcj.m4 header.m4 init.m4 install-sh.m4 lex.m4 \
 lispdir.m4 make.m4 maintainer.m4 minuso.m4 missing.m4 multi.m4 \
-protos.m4 python.m4 regex.m4 sanity.m4 strip.m4 \
+protos.m4 python.m4 regex.m4 runlog.m4 sanity.m4 strip.m4 \
 termios.m4 winsz.m4
 
 EXTRA_DIST = $(m4data_DATA)
index 6b6453ae398e4343b52e0065dbba8bafce731efa..899fc93f3243066ed318619a0865753871088ce5 100644 (file)
@@ -1,5 +1,5 @@
 # Makefile.in generated by automake 1.5a from Makefile.am.
-# Generated automatically from automake.in by configure.
+# @configure_input@
 
 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
 # Free Software Foundation, Inc.
@@ -48,6 +48,7 @@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+install_sh_DATA = $(install_sh) -c -m 644
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_HEADER = $(INSTALL_DATA)
 transform = @program_transform_name@
@@ -77,7 +78,7 @@ m4datadir = $(datadir)/aclocal
 m4data_DATA = as.m4 auxdir.m4 ccstdc.m4 cond.m4 depend.m4 depout.m4 \
 dmalloc.m4 gcj.m4 header.m4 init.m4 install-sh.m4 lex.m4 \
 lispdir.m4 make.m4 maintainer.m4 minuso.m4 missing.m4 multi.m4 \
-protos.m4 python.m4 regex.m4 sanity.m4 strip.m4 \
+protos.m4 python.m4 regex.m4 runlog.m4 sanity.m4 strip.m4 \
 termios.m4 winsz.m4
 
 
@@ -96,18 +97,17 @@ $(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
        cd $(top_srcdir) && \
          $(AUTOMAKE) --gnu  m4/Makefile
 Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
-       cd $(top_builddir) && \
-         CONFIG_HEADERS= CONFIG_LINKS= \
-         CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 uninstall-info-am:
+m4dataDATA_INSTALL = $(INSTALL_DATA)
 install-m4dataDATA: $(m4data_DATA)
        @$(NORMAL_INSTALL)
        $(mkinstalldirs) $(DESTDIR)$(m4datadir)
        @list='$(m4data_DATA)'; for p in $$list; do \
          if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
          f="`echo $$p | sed -e 's|^.*/||'`"; \
-         echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(m4datadir)/$$f"; \
-         $(INSTALL_DATA) $$d$$p $(DESTDIR)$(m4datadir)/$$f; \
+         echo " $(m4dataDATA_INSTALL) $$d$$p $(DESTDIR)$(m4datadir)/$$f"; \
+         $(m4dataDATA_INSTALL) $$d$$p $(DESTDIR)$(m4datadir)/$$f; \
        done
 
 uninstall-m4dataDATA:
@@ -120,7 +120,6 @@ uninstall-m4dataDATA:
 tags: TAGS
 TAGS:
 
-
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
 top_distdir = ..
@@ -128,7 +127,7 @@ distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
-         if test -f $$file; then d=.; else d=$(srcdir); fi; \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
          dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
          if test "$$dir" != "$$file" && test "$$dir" != "."; then \
            $(mkinstalldirs) "$(distdir)/$$dir"; \
index 348a44a5c4df889eaf901944adeb6a3c63722b77..e7ad53b1fedcd3d99f062853c237e7af317c4ab5 100644 (file)
 # doesn't meet the requirement.  MINIMUM-VERSION should consist of
 # numbers and dots only.
 
-
 AC_DEFUN([AM_PATH_PYTHON],
  [
-  dnl Find a version of Python.  I could check for python versions 1.4
-  dnl or earlier, but the default installation locations changed from
+  dnl Find a Python interpreter.  Python versions prior to 1.5 are not
+  dnl supported because the default installation locations changed from
   dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
-  dnl in 1.5, and I don't want to maintain that logic.
-
-  AC_PATH_PROG(PYTHON, python python2.1 python2.0 python1.6 python1.5)
-
-  dnl should we do the version check?
-  ifelse([$1],[],,[
-    AC_MSG_CHECKING(if Python version >= $1)
-    changequote(<<, >>)dnl
-    prog="
-import sys, string
-minver = '$1'
-pyver = string.split(sys.version)[0]  # first word is version string
-# split strings by '.' and convert to numeric
-minver = map(string.atoi, string.split(minver, '.'))
-pyver = map(string.atoi, string.split(pyver, '.'))
-# we can now do comparisons on the two lists:
-if pyver >= minver:
-       sys.exit(0)
-else:
-       sys.exit(1)"
-    changequote([, ])dnl
-    if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
-    then
-      AC_MSG_RESULT(okay)
+  dnl in 1.5.
+  m4_define([_AM_PYTHON_INTERPRETER_LIST],
+           [python python2 python2.1 python2.0 python1.6 python1.5])
+
+  m4_if([$1],[],[
+    dnl No version check is needed.
+    # Find any Python interpreter.
+    AC_PATH_PROG([PYTHON], _AM_PYTHON_INTERPRETER_LIST)],[
+    dnl A version check is needed.
+    if test -n "$PYTHON"; then
+      # If the user set $PYTHON, use it and don't search something else.
+      AC_MSG_CHECKING([whether $PYTHON version >= $1])
+      AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
+                             [AC_MSG_RESULT(yes)],
+                             [AC_MSG_ERROR(too old)])
     else
-      AC_MSG_ERROR(too old)
+      # Otherwise, try each interpreter until we find one that satisfies
+      # 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
+          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])
     fi
   ])
 
-  AC_MSG_CHECKING([local Python configuration])
-
   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.  Need to change quote character because of [:3]
-
-  AC_SUBST(PYTHON_VERSION)
-  changequote(<<, >>)dnl
-  PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
-  changequote([, ])dnl
+  dnl library.
 
+  AC_CACHE_CHECK([for $am_cv_pathless_PYTHON version], [am_cv_python_version],
+    [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
+  AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
 
   dnl Use the values of $prefix and $exec_prefix for the corresponding
   dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
   dnl distinct variables so they can be overridden if need be.  However,
   dnl general consensus is that you shouldn't need this ability.
 
-  AC_SUBST(PYTHON_PREFIX)
-  PYTHON_PREFIX='${prefix}'
-
-  AC_SUBST(PYTHON_EXEC_PREFIX)
-  PYTHON_EXEC_PREFIX='${exec_prefix}'
+  AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
+  AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
 
   dnl At times (like when building shared libraries) you may want
   dnl to know which OS platform Python thinks this is.
 
-  AC_SUBST(PYTHON_PLATFORM)
-  PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
+  AC_CACHE_CHECK([for $am_cv_pathless_PYTHON platform],
+                [am_cv_python_platform],
+    [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
+  AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
 
 
   dnl Set up 4 directories:
@@ -119,28 +115,39 @@ else:
   dnl Also, if the package prefix isn't the same as python's prefix,
   dnl then the old $(pythondir) was pretty useless.
 
-  AC_SUBST(pythondir)
-  pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
+  AC_SUBST([pythondir],
+          [$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages])
 
   dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
   dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
   dnl   more consistent with the rest of automake.
   dnl   Maybe this should be put in python.am?
 
-  AC_SUBST(pkgpythondir)
-  pkgpythondir=\${pythondir}/$PACKAGE
+  AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
 
   dnl pyexecdir -- directory for installing python extension modules
   dnl   (shared libraries)  Was PYTHON_SITE_EXEC in previous betas.
 
-  AC_SUBST(pyexecdir)
-  pyexecdir=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
+  AC_SUBST([pyexecdir],
+          [${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages])
 
   dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
   dnl   Maybe this should be put in python.am?
 
-  AC_SUBST(pkgpyexecdir)
-  pkgpyexecdir=\${pyexecdir}/$PACKAGE
-
-  AC_MSG_RESULT([looks good])
+  AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
 ])
+
+
+# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# ---------------------------------------------------------------------------
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
+# Run ACTION-IF-FALSE otherwise.
+AC_DEFUN([AM_PYTHON_CHECK_VERSION],
+ [prog="import sys, string
+pyver = string.split(sys.version)[[0]]  # first word is version string
+# split strings by '.' and convert to numeric
+minver = map(string.atoi, string.split('$2', '.'))
+pyver = map(string.atoi, string.split(pyver, '.'))
+# we can now do comparisons on the two lists:
+sys.exit(pyver < minver)"
+  AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
diff --git a/m4/runlog.m4 b/m4/runlog.m4
new file mode 100644 (file)
index 0000000..f2525c2
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright 2001 Free Software Foundation, Inc.             -*- Autoconf -*-
+
+# 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, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   (exit $ac_status); }])
This page took 0.045579 seconds and 5 git commands to generate.