816
816
AC_DEFUN([_AM_IF_OPTION],
817
817
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
819
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
820
# Free Software Foundation, Inc.
822
# This file is free software; the Free Software Foundation
823
# gives unlimited permission to copy and/or distribute it,
824
# with or without modifications, as long as this notice is preserved.
826
# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
827
# ---------------------------------------------------------------------------
828
# Adds support for distributing Python modules and packages. To
829
# install modules, copy them to $(pythondir), using the python_PYTHON
830
# automake variable. To install a package with the same name as the
831
# automake package, install to $(pkgpythondir), or use the
832
# pkgpython_PYTHON automake variable.
834
# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
835
# locations to install python extension modules (shared libraries).
836
# Another macro is required to find the appropriate flags to compile
839
# If your package is configured with a different prefix to python,
840
# users will have to add the install directory to the PYTHONPATH
841
# environment variable, or create a .pth file (see the python
842
# documentation for details).
844
# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
845
# cause an error if the version of python installed on the system
846
# doesn't meet the requirement. MINIMUM-VERSION should consist of
847
# numbers and dots only.
848
AC_DEFUN([AM_PATH_PYTHON],
850
dnl Find a Python interpreter. Python versions prior to 2.0 are not
851
dnl supported. (2.0 was released on October 16, 2000).
852
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
853
[python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl
854
python2.1 python2.0])
857
dnl No version check is needed.
858
# Find any Python interpreter.
859
if test -z "$PYTHON"; then
860
AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
862
am_display_PYTHON=python
864
dnl A version check is needed.
865
if test -n "$PYTHON"; then
866
# If the user set $PYTHON, use it and don't search something else.
867
AC_MSG_CHECKING([whether $PYTHON version >= $1])
868
AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
869
[AC_MSG_RESULT(yes)],
870
[AC_MSG_ERROR(too old)])
871
am_display_PYTHON=$PYTHON
873
# Otherwise, try each interpreter until we find one that satisfies
875
AC_CACHE_CHECK([for a Python interpreter with version >= $1],
876
[am_cv_pathless_PYTHON],[
877
for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
878
test "$am_cv_pathless_PYTHON" = none && break
879
AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
881
# Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
882
if test "$am_cv_pathless_PYTHON" = none; then
885
AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
887
am_display_PYTHON=$am_cv_pathless_PYTHON
891
if test "$PYTHON" = :; then
892
dnl Run any user-specified action, or abort.
893
m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
896
dnl Query Python for its version number. Getting [:3] seems to be
897
dnl the best way to do this; it's what "site.py" does in the standard
900
AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
901
[am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
902
AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
904
dnl Use the values of $prefix and $exec_prefix for the corresponding
905
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
906
dnl distinct variables so they can be overridden if need be. However,
907
dnl general consensus is that you shouldn't need this ability.
909
AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
910
AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
912
dnl At times (like when building shared libraries) you may want
913
dnl to know which OS platform Python thinks this is.
915
AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
916
[am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
917
AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
920
dnl Set up 4 directories:
922
dnl pythondir -- where to install python scripts. This is the
923
dnl site-packages directory, not the python standard library
924
dnl directory like in previous automake betas. This behavior
925
dnl is more consistent with lispdir.m4 for example.
926
dnl Query distutils for this directory. distutils does not exist in
927
dnl Python 1.5, so we fall back to the hardcoded directory if it
929
AC_CACHE_CHECK([for $am_display_PYTHON script directory],
930
[am_cv_python_pythondir],
931
[if test "x$prefix" = xNONE
933
am_py_prefix=$ac_default_prefix
937
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 ||
938
echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
939
case $am_cv_python_pythondir in
941
am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
942
am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
945
case $am_py_prefix in
948
am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
954
AC_SUBST([pythondir], [$am_cv_python_pythondir])
956
dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
957
dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
958
dnl more consistent with the rest of automake.
960
AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
962
dnl pyexecdir -- directory for installing python extension modules
963
dnl (shared libraries)
964
dnl Query distutils for this directory. distutils does not exist in
965
dnl Python 1.5, so we fall back to the hardcoded directory if it
967
AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
968
[am_cv_python_pyexecdir],
969
[if test "x$exec_prefix" = xNONE
971
am_py_exec_prefix=$am_py_prefix
973
am_py_exec_prefix=$exec_prefix
975
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 ||
976
echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
977
case $am_cv_python_pyexecdir in
979
am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
980
am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
983
case $am_py_exec_prefix in
986
am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
992
AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
994
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
996
AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
998
dnl Run any user-specified action.
1005
# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
1006
# ---------------------------------------------------------------------------
1007
# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
1008
# Run ACTION-IF-FALSE otherwise.
1009
# This test uses sys.hexversion instead of the string equivalent (first
1010
# word of sys.version), in order to cope with versions such as 2.2c1.
1011
# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
1012
AC_DEFUN([AM_PYTHON_CHECK_VERSION],
1014
# split strings by '.' and convert to numeric. Append some zeros
1015
# because we need at least 4 digits for the hex conversion.
1016
# map returns an iterator in Python 3.0 and a list in 2.x
1017
minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
1019
# xrange is not present in Python 3.0 and range returns an iterator
1020
for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
1021
sys.exit(sys.hexversion < minverhex)"
1022
AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
1024
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
1026
# This file is free software; the Free Software Foundation
1027
# gives unlimited permission to copy and/or distribute it,
1028
# with or without modifications, as long as this notice is preserved.
1030
# AM_RUN_LOG(COMMAND)
1031
# -------------------
1032
# Run COMMAND, save the exit status in ac_status, and log it.
1033
# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
1034
AC_DEFUN([AM_RUN_LOG],
1035
[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
1036
($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
1038
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1039
(exit $ac_status); }])
819
1041
# Check to make sure that the build environment is sane. -*- Autoconf -*-
821
1043
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008