MenuEditor: Remove visible_tree mess
[alacarte.git] / acinclude.m4
blob122712372d7d4807629bd49c2dc1b11159001165
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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16 # 02111-1307, USA.
18 # AM_PATH_PYTHON_VERSION(ABI-VERSION1, [MINIMUM-VERSION1 [, ABI-VERSION2, [MINIMUM-VERSION2 ...]]])
20 # An alternative to AM_PATH_PYTHON that checks for specific python ABI/version pairs.
21 # Example:
22 #    AM_PATH_PYTHON_VERSION(2.3, 2.3.5, 2.4, 2.4.0)
23 # checks for a python2.3 binary returning python version >= 2.3.5, and
24 # if that fails it looks for python2.4 containing version >= 2.4.0
25 # It aborts configure with an error if no statisfying version is found.
26 # Env. var. PYTHON can be used to point a specific/laternate version to configure.
28 AC_DEFUN([AM_PATH_PYTHON_VERSION],
29  [
30   m4_pattern_allow([m4_shift])
31   _python_save="$PYTHON"
32   dnl Find a Python interpreter with corresponding ABI version.
34   m4_define(PYTHON_var, PYTHON[]m4_translit($1,[.],[_]))
36   if test -z "$PYTHON"; then
37     AC_PATH_PROG(PYTHON_var, python$1, [])
38   else
39     PYTHON_var="$PYTHON"
40   fi
42   PYTHON="$PYTHON_var"
43   AC_SUBST(PYTHON)
45   if test -n "$PYTHON"; then
47   m4_if([$2],[],[
48   ], [
49       dnl A version check is needed.
50       AC_MSG_CHECKING([whether $PYTHON version is >= $2])
51       AM_PYTHON_CHECK_VERSION([$PYTHON], [$2],
52                               [AC_MSG_RESULT(yes)],
53                               [AC_MSG_RESULT([no]); PYTHON=""])
54   ])
56   fi
58   if test -z "$PYTHON"; then
59     dnl if more arguments, shift/recurse, else fail
60     m4_if([$3],[],[
61         AC_MSG_ERROR([no suitable Python interpreter found])
62     ], [
63         PYTHON="$_python_save"
64         AM_PATH_PYTHON_VERSION(m4_shift(m4_shift($@)))
65     ])
67   else
69   dnl Query Python for its version number.  Getting [:3] seems to be
70   dnl the best way to do this; it's what "site.py" does in the standard
71   dnl library.
73   AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
74     [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
75   AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
77   dnl Use the values of $prefix and $exec_prefix for the corresponding
78   dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
79   dnl distinct variables so they can be overridden if need be.  However,
80   dnl general consensus is that you shouldn't need this ability.
82   AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
83   AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
85   dnl At times (like when building shared libraries) you may want
86   dnl to know which OS platform Python thinks this is.
88   AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
89     [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
90   AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
93   dnl Set up 4 directories:
95   dnl pythondir -- where to install python scripts.  This is the
96   dnl   site-packages directory, not the python standard library
97   dnl   directory like in previous automake betas.  This behavior
98   dnl   is more consistent with lispdir.m4 for example.
99   dnl Query distutils for this directory.  distutils does not exist in
100   dnl Python 1.5, so we fall back to the hardcoded directory if it
101   dnl doesn't work.
102   AC_CACHE_CHECK([for $am_display_PYTHON script directory],
103     [am_cv_python_pythondir],
104     [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
105      echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
106   AC_SUBST([pythondir], [$am_cv_python_pythondir])
108   dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
109   dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
110   dnl   more consistent with the rest of automake.
112   AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
114   dnl pyexecdir -- directory for installing python extension modules
115   dnl   (shared libraries)
116   dnl Query distutils for this directory.  distutils does not exist in
117   dnl Python 1.5, so we fall back to the hardcoded directory if it
118   dnl doesn't work.
119   AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
120     [am_cv_python_pyexecdir],
121     [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
122      echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
123   AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
125   dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
127   AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
129   fi