README: Update/remove incorrect/outdated content - bug 787786
[alacarte.git] / acinclude.m4
blob372e0b2b4fe7e9e65596e8fdcc90f325449f0ebe
1 # Copyright 1999, 2000, 2001, 2002, 2003  Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2, or (at your option)
6 # any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <http://www.gnu.org/licenses/>.
16 # AM_PATH_PYTHON_VERSION(ABI-VERSION1, [MINIMUM-VERSION1 [, ABI-VERSION2, [MINIMUM-VERSION2 ...]]])
18 # An alternative to AM_PATH_PYTHON that checks for specific python ABI/version pairs.
19 # Example:
20 #    AM_PATH_PYTHON_VERSION(2.3, 2.3.5, 2.4, 2.4.0)
21 # checks for a python2.3 binary returning python version >= 2.3.5, and
22 # if that fails it looks for python2.4 containing version >= 2.4.0
23 # It aborts configure with an error if no statisfying version is found.
24 # Env. var. PYTHON can be used to point a specific/laternate version to configure.
26 AC_DEFUN([AM_PATH_PYTHON_VERSION],
27  [
28   m4_pattern_allow([m4_shift])
29   _python_save="$PYTHON"
30   dnl Find a Python interpreter with corresponding ABI version.
32   m4_define(PYTHON_var, PYTHON[]m4_translit($1,[.],[_]))
34   if test -z "$PYTHON"; then
35     AC_PATH_PROG(PYTHON_var, python$1, [])
36   else
37     PYTHON_var="$PYTHON"
38   fi
40   PYTHON="$PYTHON_var"
41   AC_SUBST(PYTHON)
43   if test -n "$PYTHON"; then
45   m4_if([$2],[],[
46   ], [
47       dnl A version check is needed.
48       AC_MSG_CHECKING([whether $PYTHON version is >= $2])
49       AM_PYTHON_CHECK_VERSION([$PYTHON], [$2],
50                               [AC_MSG_RESULT(yes)],
51                               [AC_MSG_RESULT([no]); PYTHON=""])
52   ])
54   fi
56   if test -z "$PYTHON"; then
57     dnl if more arguments, shift/recurse, else fail
58     m4_if([$3],[],[
59         AC_MSG_ERROR([no suitable Python interpreter found])
60     ], [
61         PYTHON="$_python_save"
62         AM_PATH_PYTHON_VERSION(m4_shift(m4_shift($@)))
63     ])
65   else
67   dnl Query Python for its version number.  Getting [:3] seems to be
68   dnl the best way to do this; it's what "site.py" does in the standard
69   dnl library.
71   AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
72     [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
73   AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
75   dnl Use the values of $prefix and $exec_prefix for the corresponding
76   dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
77   dnl distinct variables so they can be overridden if need be.  However,
78   dnl general consensus is that you shouldn't need this ability.
80   AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
81   AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
83   dnl At times (like when building shared libraries) you may want
84   dnl to know which OS platform Python thinks this is.
86   AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
87     [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
88   AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
91   dnl Set up 4 directories:
93   dnl pythondir -- where to install python scripts.  This is the
94   dnl   site-packages directory, not the python standard library
95   dnl   directory like in previous automake betas.  This behavior
96   dnl   is more consistent with lispdir.m4 for example.
97   dnl Query distutils for this directory.  distutils does not exist in
98   dnl Python 1.5, so we fall back to the hardcoded directory if it
99   dnl doesn't work.
100   AC_CACHE_CHECK([for $am_display_PYTHON script directory],
101     [am_cv_python_pythondir],
102     [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
103      echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
104   AC_SUBST([pythondir], [$am_cv_python_pythondir])
106   dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
107   dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
108   dnl   more consistent with the rest of automake.
110   AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
112   dnl pyexecdir -- directory for installing python extension modules
113   dnl   (shared libraries)
114   dnl Query distutils for this directory.  distutils does not exist in
115   dnl Python 1.5, so we fall back to the hardcoded directory if it
116   dnl doesn't work.
117   AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
118     [am_cv_python_pyexecdir],
119     [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
120      echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
121   AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
123   dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
125   AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
127   fi