946
946
AC_DEFUN([_AM_IF_OPTION],
947
947
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
949
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
950
# Free Software Foundation, Inc.
952
# This file is free software; the Free Software Foundation
953
# gives unlimited permission to copy and/or distribute it,
954
# with or without modifications, as long as this notice is preserved.
956
# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
957
# ---------------------------------------------------------------------------
958
# Adds support for distributing Python modules and packages. To
959
# install modules, copy them to $(pythondir), using the python_PYTHON
960
# automake variable. To install a package with the same name as the
961
# automake package, install to $(pkgpythondir), or use the
962
# pkgpython_PYTHON automake variable.
964
# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
965
# locations to install python extension modules (shared libraries).
966
# Another macro is required to find the appropriate flags to compile
969
# If your package is configured with a different prefix to python,
970
# users will have to add the install directory to the PYTHONPATH
971
# environment variable, or create a .pth file (see the python
972
# documentation for details).
974
# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
975
# cause an error if the version of python installed on the system
976
# doesn't meet the requirement. MINIMUM-VERSION should consist of
977
# numbers and dots only.
978
AC_DEFUN([AM_PATH_PYTHON],
980
dnl Find a Python interpreter. Python versions prior to 2.0 are not
981
dnl supported. (2.0 was released on October 16, 2000).
982
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
983
[python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl
984
python2.1 python2.0])
987
dnl No version check is needed.
988
# Find any Python interpreter.
989
if test -z "$PYTHON"; then
990
AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
992
am_display_PYTHON=python
994
dnl A version check is needed.
995
if test -n "$PYTHON"; then
996
# If the user set $PYTHON, use it and don't search something else.
997
AC_MSG_CHECKING([whether $PYTHON version >= $1])
998
AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
999
[AC_MSG_RESULT(yes)],
1000
[AC_MSG_ERROR(too old)])
1001
am_display_PYTHON=$PYTHON
1003
# Otherwise, try each interpreter until we find one that satisfies
1005
AC_CACHE_CHECK([for a Python interpreter with version >= $1],
1006
[am_cv_pathless_PYTHON],[
1007
for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
1008
test "$am_cv_pathless_PYTHON" = none && break
1009
AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
1011
# Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
1012
if test "$am_cv_pathless_PYTHON" = none; then
1015
AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
1017
am_display_PYTHON=$am_cv_pathless_PYTHON
1021
if test "$PYTHON" = :; then
1022
dnl Run any user-specified action, or abort.
1023
m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
1026
dnl Query Python for its version number. Getting [:3] seems to be
1027
dnl the best way to do this; it's what "site.py" does in the standard
1030
AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
1031
[am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
1032
AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
1034
dnl Use the values of $prefix and $exec_prefix for the corresponding
1035
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
1036
dnl distinct variables so they can be overridden if need be. However,
1037
dnl general consensus is that you shouldn't need this ability.
1039
AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
1040
AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
1042
dnl At times (like when building shared libraries) you may want
1043
dnl to know which OS platform Python thinks this is.
1045
AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
1046
[am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
1047
AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
1050
dnl Set up 4 directories:
1052
dnl pythondir -- where to install python scripts. This is the
1053
dnl site-packages directory, not the python standard library
1054
dnl directory like in previous automake betas. This behavior
1055
dnl is more consistent with lispdir.m4 for example.
1056
dnl Query distutils for this directory. distutils does not exist in
1057
dnl Python 1.5, so we fall back to the hardcoded directory if it
1059
AC_CACHE_CHECK([for $am_display_PYTHON script directory],
1060
[am_cv_python_pythondir],
1061
[if test "x$prefix" = xNONE
1063
am_py_prefix=$ac_default_prefix
1065
am_py_prefix=$prefix
1067
am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null ||
1068
echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
1069
case $am_cv_python_pythondir in
1071
am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
1072
am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
1076
AC_SUBST([pythondir], [$am_cv_python_pythondir])
1078
dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
1079
dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
1080
dnl more consistent with the rest of automake.
1082
AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
1084
dnl pyexecdir -- directory for installing python extension modules
1085
dnl (shared libraries)
1086
dnl Query distutils for this directory. distutils does not exist in
1087
dnl Python 1.5, so we fall back to the hardcoded directory if it
1089
AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
1090
[am_cv_python_pyexecdir],
1091
[if test "x$exec_prefix" = xNONE
1093
am_py_exec_prefix=$am_py_prefix
1095
am_py_exec_prefix=$exec_prefix
1097
am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null ||
1098
echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
1099
case $am_cv_python_pyexecdir in
1100
$am_py_exec_prefix*)
1101
am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
1102
am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
1106
AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
1108
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
1110
AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
1112
dnl Run any user-specified action.
1119
# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
1120
# ---------------------------------------------------------------------------
1121
# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
1122
# Run ACTION-IF-FALSE otherwise.
1123
# This test uses sys.hexversion instead of the string equivalent (first
1124
# word of sys.version), in order to cope with versions such as 2.2c1.
1125
# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
1126
AC_DEFUN([AM_PYTHON_CHECK_VERSION],
1128
# split strings by '.' and convert to numeric. Append some zeros
1129
# because we need at least 4 digits for the hex conversion.
1130
# map returns an iterator in Python 3.0 and a list in 2.x
1131
minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
1133
# xrange is not present in Python 3.0 and range returns an iterator
1134
for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
1135
sys.exit(sys.hexversion < minverhex)"
1136
AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
1138
949
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
1140
951
# This file is free software; the Free Software Foundation