2000-06-10 22:02:12 +04:00
|
|
|
#
|
|
|
|
# Autoconf macros for configuring the build of Python extension modules
|
|
|
|
#
|
2005-10-14 00:40:04 +04:00
|
|
|
# $PostgreSQL: pgsql/config/python.m4,v 1.13 2005/10/13 20:40:04 momjian Exp $
|
2000-06-10 22:02:12 +04:00
|
|
|
#
|
|
|
|
|
2001-05-12 21:49:32 +04:00
|
|
|
# PGAC_PATH_PYTHON
|
2000-06-10 22:02:12 +04:00
|
|
|
# ----------------
|
2002-03-29 20:32:55 +03:00
|
|
|
# Look for Python and set the output variable 'PYTHON'
|
|
|
|
# to 'python' if found, empty otherwise.
|
2001-05-12 21:49:32 +04:00
|
|
|
AC_DEFUN([PGAC_PATH_PYTHON],
|
|
|
|
[AC_PATH_PROG(PYTHON, python)
|
|
|
|
if test x"$PYTHON" = x""; then
|
|
|
|
AC_MSG_ERROR([Python not found])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
# _PGAC_CHECK_PYTHON_DIRS
|
|
|
|
# -----------------------
|
2004-10-11 23:32:19 +04:00
|
|
|
# Determine the name of various directories of a given Python installation.
|
2001-05-12 21:49:32 +04:00
|
|
|
AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
|
|
|
|
[AC_REQUIRE([PGAC_PATH_PYTHON])
|
2004-09-17 03:30:30 +04:00
|
|
|
AC_MSG_CHECKING([for Python distutils module])
|
|
|
|
if "${PYTHON}" 2>&- -c 'import distutils'
|
|
|
|
then
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
else
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
AC_MSG_ERROR([distutils module not found])
|
|
|
|
fi
|
2004-10-10 23:07:55 +04:00
|
|
|
AC_MSG_CHECKING([Python configuration directory])
|
2001-05-12 21:49:32 +04:00
|
|
|
python_version=`${PYTHON} -c "import sys; print sys.version[[:3]]"`
|
2004-09-17 03:30:30 +04:00
|
|
|
python_configdir=`${PYTHON} -c "from distutils.sysconfig import get_python_lib as f; import os; print os.path.join(f(plat_specific=1,standard_lib=1),'config')"`
|
2004-10-06 13:20:41 +04:00
|
|
|
python_includespec=`${PYTHON} -c "import distutils.sysconfig; print '-I'+distutils.sysconfig.get_python_inc()"`
|
2001-05-12 21:49:32 +04:00
|
|
|
|
2004-10-10 23:07:55 +04:00
|
|
|
AC_SUBST(python_version)[]dnl
|
2001-05-12 21:49:32 +04:00
|
|
|
AC_SUBST(python_configdir)[]dnl
|
2001-07-10 20:33:02 +04:00
|
|
|
AC_SUBST(python_includespec)[]dnl
|
|
|
|
# This should be enough of a message.
|
2004-10-10 23:07:55 +04:00
|
|
|
AC_MSG_RESULT([$python_configdir])
|
2001-05-12 21:49:32 +04:00
|
|
|
])# _PGAC_CHECK_PYTHON_DIRS
|
2000-06-10 22:02:12 +04:00
|
|
|
|
|
|
|
|
2001-05-12 21:49:32 +04:00
|
|
|
# PGAC_CHECK_PYTHON_EMBED_SETUP
|
|
|
|
# -----------------------------
|
2004-10-11 23:32:19 +04:00
|
|
|
#
|
|
|
|
# Note: selecting libpython from python_configdir works in all Python
|
|
|
|
# releases, but it generally finds a non-shared library, which means
|
|
|
|
# that we are binding the python interpreter right into libplpython.so.
|
|
|
|
# In Python 2.3 and up there should be a shared library available in
|
|
|
|
# the main library location.
|
2001-05-12 21:49:32 +04:00
|
|
|
AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
|
|
|
|
[AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
|
|
|
|
AC_MSG_CHECKING([how to link an embedded Python application])
|
|
|
|
|
2004-10-11 23:32:19 +04:00
|
|
|
python_libdir=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR')))"`
|
|
|
|
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY')))"`
|
|
|
|
python_so=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('SO')))"`
|
|
|
|
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
|
|
|
|
|
|
|
|
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
|
|
|
|
then
|
|
|
|
# New way: use the official shared library
|
|
|
|
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
|
|
|
|
python_libspec="-L${python_libdir} -l${ldlibrary}"
|
|
|
|
else
|
|
|
|
# Old way: use libpython from python_configdir
|
|
|
|
python_libdir="${python_configdir}"
|
|
|
|
python_libspec="-L${python_libdir} -lpython${python_version}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
|
2001-05-12 21:49:32 +04:00
|
|
|
|
2004-10-11 23:32:19 +04:00
|
|
|
AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
|
2001-05-12 21:49:32 +04:00
|
|
|
|
2004-10-11 23:32:19 +04:00
|
|
|
AC_SUBST(python_libdir)[]dnl
|
2001-05-12 21:49:32 +04:00
|
|
|
AC_SUBST(python_libspec)[]dnl
|
2004-10-11 23:32:19 +04:00
|
|
|
AC_SUBST(python_additional_libs)[]dnl
|
2005-09-26 20:48:28 +04:00
|
|
|
|
|
|
|
# threaded python is not supported on bsd's
|
|
|
|
AC_MSG_CHECKING(whether Python is compiled with thread support)
|
|
|
|
pythreads=`${PYTHON} -c "import sys; print int('thread' in sys.builtin_module_names)"`
|
|
|
|
if test "$pythreads" = "1"; then
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
case $host_os in
|
2005-10-14 00:40:04 +04:00
|
|
|
openbsd*|freebsd4*)
|
2005-09-26 20:48:28 +04:00
|
|
|
AC_MSG_ERROR([*** Threaded Python not supported on this platform ***])
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
fi
|
|
|
|
|
2001-05-12 21:49:32 +04:00
|
|
|
])# PGAC_CHECK_PYTHON_EMBED_SETUP
|