1 m4_include(scripting/python/ac_pkg_swig.m4)
3 AC_ARG_VAR([PYTHON_VERSION],[The installed Python
4 version to use, for example '2.3'. This string
5 will be appended to the Python interpreter
10 AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
11 if test -z "$PYTHON"; then
13 AC_MSG_WARN([No python found])
17 # Check for a version of Python >= 2.1.0
19 AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
20 ac_supports_python_ver=`$PYTHON -c "import sys, string; \
21 ver = string.split(sys.version)[[0]]; \
22 print ver >= '2.1.0'"`
23 if test "$ac_supports_python_ver" != "True"; then
31 # Check if you have distutils, else fail
33 AC_MSG_CHECKING([for the distutils Python package])
34 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
35 if test -z "$ac_distutils_result"; then
44 # Check for Python include path
46 AC_MSG_CHECKING([for Python include path])
47 if test -z "$PYTHON_CPPFLAGS"; then
48 python_path=`$PYTHON -c "import distutils.sysconfig; \
49 print distutils.sysconfig.get_python_inc();"`
50 if test -n "${python_path}"; then
51 python_path="-I$python_path"
53 PYTHON_CPPFLAGS=$python_path
55 AC_MSG_RESULT([$PYTHON_CPPFLAGS])
56 AC_SUBST([PYTHON_CPPFLAGS])
59 # Check for Python library path
61 AC_MSG_CHECKING([for Python library path])
62 if test -z "$PYTHON_LDFLAGS"; then
63 # (makes two attempts to ensure we've got a version number
64 # from the interpreter)
65 py_version=`$PYTHON -c "from distutils.sysconfig import *; \
66 from string import join; \
67 print join(get_config_vars('VERSION'))"`
68 if test "$py_version" == "[None]"; then
69 if test -n "$PYTHON_VERSION"; then
70 py_version=$PYTHON_VERSION
72 py_version=`$PYTHON -c "import sys; \
73 print sys.version[[:3]]"`
77 PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
78 from string import join; \
79 print '-L' + get_python_lib(0,1), \
80 '-lpython';"`$py_version
82 AC_MSG_RESULT([$PYTHON_LDFLAGS])
83 AC_SUBST([PYTHON_LDFLAGS])
86 # Check for site packages
88 AC_MSG_CHECKING([for Python site-packages path])
89 if test -z "$PYTHON_SITE_PKG"; then
90 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
91 print distutils.sysconfig.get_python_lib(0,0);"`
93 AC_MSG_RESULT([$PYTHON_SITE_PKG])
94 AC_SUBST([PYTHON_SITE_PKG])
97 # libraries which must be linked in when embedding
99 AC_MSG_CHECKING(python extra libraries)
100 if test -z "$PYTHON_EXTRA_LIBS"; then
101 PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
102 conf = distutils.sysconfig.get_config_var; \
103 print conf('LOCALMODLIBS'), conf('LIBS')"`
105 AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
106 AC_SUBST(PYTHON_EXTRA_LIBS)
109 # linking flags needed when embedding
111 AC_MSG_CHECKING(python extra linking flags)
112 if test -z "$PYTHON_EXTRA_LDFLAGS"; then
113 PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
114 conf = distutils.sysconfig.get_config_var; \
115 print conf('LINKFORSHARED')"`
117 AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
118 AC_SUBST(PYTHON_EXTRA_LDFLAGS)
120 SMB_EXT_LIB(LIBPYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CPPFLAGS])
122 if test x$working_python = xyes
124 SMB_ENABLE(LIBPYTHON,YES)
126 SMB_ENABLE(LIBPYTHON,NO)