2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-01 14:55:10 +00:00

python2/3 compatible ac_python_devel.m4

This commit is contained in:
Dmitrijs Ledkovs
2012-06-12 13:56:57 +01:00
parent 9f19fb7b53
commit 5fcbcf3ddc

View File

@@ -17,9 +17,9 @@ AC_DEFUN([AC_PYTHON_DEVEL],[
# Check for a version of Python >= 2.1.0 # Check for a version of Python >= 2.1.0
# #
AC_MSG_CHECKING([for a version of Python >= '2.1.0']) AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
ac_supports_python_ver=`$PYTHON -c "import sys, string; \ ac_supports_python_ver=`$PYTHON -c "import sys; \
ver = string.split(sys.version)[[0]]; \ ver = sys.version.split()[[0]]; \
print ver >= '2.1.0'"` sys.stdout.write(str(ver >= '2.1.0'))"`
if test "$ac_supports_python_ver" != "True"; then if test "$ac_supports_python_ver" != "True"; then
if test -z "$PYTHON_NOVERSIONCHECK"; then if test -z "$PYTHON_NOVERSIONCHECK"; then
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
@@ -44,9 +44,9 @@ to something else than an empty string.
# #
if test -n "$1"; then if test -n "$1"; then
AC_MSG_CHECKING([for a version of Python $1]) AC_MSG_CHECKING([for a version of Python $1])
ac_supports_python_ver=`$PYTHON -c "import sys, string; \ ac_supports_python_ver=`$PYTHON -c "import sys; \
ver = string.split(sys.version)[[0]]; \ ver = sys.version.split()[[0]]; \
print ver $1"` sys.stdout.write("%s\n" % (ver == $1))"`
if test "$ac_supports_python_ver" = "True"; then if test "$ac_supports_python_ver" = "True"; then
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
else else
@@ -80,8 +80,8 @@ $ac_distutils_result])
# #
AC_MSG_CHECKING([for Python include path]) AC_MSG_CHECKING([for Python include path])
if test -z "$PYTHON_CPPFLAGS"; then if test -z "$PYTHON_CPPFLAGS"; then
python_path=`$PYTHON -c "import distutils.sysconfig; \ python_path=`$PYTHON -c "import sys; import distutils.sysconfig;\
print distutils.sysconfig.get_python_inc();"` sys.stdout.write('%s\n' % distutils.sysconfig.get_python_inc());"`
if test -n "${python_path}"; then if test -n "${python_path}"; then
python_path="-I$python_path" python_path="-I$python_path"
fi fi
@@ -97,22 +97,20 @@ $ac_distutils_result])
if test -z "$PYTHON_LDFLAGS"; then if test -z "$PYTHON_LDFLAGS"; then
# (makes two attempts to ensure we've got a version number # (makes two attempts to ensure we've got a version number
# from the interpreter) # from the interpreter)
py_version=`$PYTHON -c "from distutils.sysconfig import *; \ py_version=`$PYTHON -c "import sys; from distutils.sysconfig import *; \
from string import join; \ sys.stdout.write('%s\n' % ''.join(get_config_vars('VERSION')))"`
print join(get_config_vars('VERSION'))"`
if test "$py_version" == "[None]"; then if test "$py_version" == "[None]"; then
if test -n "$PYTHON_VERSION"; then if test -n "$PYTHON_VERSION"; then
py_version=$PYTHON_VERSION py_version=$PYTHON_VERSION
else else
py_version=`$PYTHON -c "import sys; \ py_version=`$PYTHON -c "import sys; \
print sys.version[[:3]]"` sys.stdout.write("%s\n" % sys.version[[:3]])"`
fi fi
fi fi
PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \ PYTHON_LDFLAGS=`$PYTHON -c "import sys; from distutils.sysconfig import *; \
from string import join; \ sys.stdout.write('-L' + get_python_lib(0,1) + ' -lpython\n')"`$py_version`$PYTHON -c \
print '-L' + get_python_lib(0,1), \ "import sys; sys.stdout.write('%s' % getattr(sys,'abiflags',''))"`
'-lpython';"`$py_version
fi fi
AC_MSG_RESULT([$PYTHON_LDFLAGS]) AC_MSG_RESULT([$PYTHON_LDFLAGS])
AC_SUBST([PYTHON_LDFLAGS]) AC_SUBST([PYTHON_LDFLAGS])
@@ -122,8 +120,8 @@ $ac_distutils_result])
# #
AC_MSG_CHECKING([for Python site-packages path]) AC_MSG_CHECKING([for Python site-packages path])
if test -z "$PYTHON_SITE_PKG"; then if test -z "$PYTHON_SITE_PKG"; then
PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ PYTHON_SITE_PKG=`$PYTHON -c "import sys; import distutils.sysconfig; \
print distutils.sysconfig.get_python_lib(0,0);"` sys.stdout.write('%s\n' % distutils.sysconfig.get_python_lib(0,0));"`
fi fi
AC_MSG_RESULT([$PYTHON_SITE_PKG]) AC_MSG_RESULT([$PYTHON_SITE_PKG])
AC_SUBST([PYTHON_SITE_PKG]) AC_SUBST([PYTHON_SITE_PKG])
@@ -133,9 +131,9 @@ $ac_distutils_result])
# #
AC_MSG_CHECKING(python extra libraries) AC_MSG_CHECKING(python extra libraries)
if test -z "$PYTHON_EXTRA_LIBS"; then if test -z "$PYTHON_EXTRA_LIBS"; then
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ PYTHON_EXTRA_LIBS=`$PYTHON -c "import sys; import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \ conf = distutils.sysconfig.get_config_var; \
print conf('LOCALMODLIBS'), conf('LIBS')"` sys.stdout.write('%s %s\n' % (conf('LOCALMODLIBS'), conf('LIBS')))"`
fi fi
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
AC_SUBST(PYTHON_EXTRA_LIBS) AC_SUBST(PYTHON_EXTRA_LIBS)
@@ -145,9 +143,9 @@ $ac_distutils_result])
# #
AC_MSG_CHECKING(python extra linking flags) AC_MSG_CHECKING(python extra linking flags)
if test -z "$PYTHON_EXTRA_LDFLAGS"; then if test -z "$PYTHON_EXTRA_LDFLAGS"; then
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import sys; import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \ conf = distutils.sysconfig.get_config_var; \
print conf('LINKFORSHARED')"` sys.stdout.write('%s\n' % conf('LINKFORSHARED'))"`
fi fi
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
AC_SUBST(PYTHON_EXTRA_LDFLAGS) AC_SUBST(PYTHON_EXTRA_LDFLAGS)