#
# Autoconf macros for configuring the build of Python extension modules
#
-# $PostgreSQL: pgsql/config/python.m4,v 1.10 2004/10/10 19:07:52 tgl Exp $
+# $PostgreSQL: pgsql/config/python.m4,v 1.11 2004/10/11 19:32:16 tgl Exp $
#
# PGAC_PATH_PYTHON
# _PGAC_CHECK_PYTHON_DIRS
# -----------------------
-# Determine the name of various directory of a given Python installation.
+# Determine the name of various directories of a given Python installation.
AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
[AC_REQUIRE([PGAC_PATH_PYTHON])
AC_MSG_CHECKING([for Python distutils module])
# PGAC_CHECK_PYTHON_EMBED_SETUP
# -----------------------------
+#
+# 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.
AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
[AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
AC_MSG_CHECKING([how to link an embedded Python application])
-python_libspec=`${PYTHON} -c "import distutils.sysconfig,string; print '-lpython${python_version} '+string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
+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')))"`
-AC_MSG_RESULT([${python_libspec}])
+AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
+AC_SUBST(python_libdir)[]dnl
AC_SUBST(python_libspec)[]dnl
+AC_SUBST(python_additional_libs)[]dnl
])# PGAC_CHECK_PYTHON_EMBED_SETUP
echo "$as_me:$LINENO: checking how to link an embedded Python application" >&5
echo $ECHO_N "checking how to link an embedded Python application... $ECHO_C" >&6
-python_libspec=`${PYTHON} -c "import distutils.sysconfig,string; print '-lpython${python_version} '+string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
+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}$//"`
-echo "$as_me:$LINENO: result: ${python_libspec}" >&5
-echo "${ECHO_T}${python_libspec}" >&6
+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')))"`
+
+echo "$as_me:$LINENO: result: ${python_libspec} ${python_additional_libs}" >&5
+echo "${ECHO_T}${python_libspec} ${python_additional_libs}" >&6
fi
s,@python_version@,$python_version,;t t
s,@python_configdir@,$python_configdir,;t t
s,@python_includespec@,$python_includespec,;t t
+s,@python_libdir@,$python_libdir,;t t
s,@python_libspec@,$python_libspec,;t t
+s,@python_additional_libs@,$python_additional_libs,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@HAVE_IPV6@,$HAVE_IPV6,;t t
s,@acx_pthread_config@,$acx_pthread_config,;t t
# -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.200 2004/10/06 15:14:13 momjian Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.201 2004/10/11 19:32:19 tgl Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
enable_thread_safety = @enable_thread_safety@
python_includespec = @python_includespec@
+python_libdir = @python_libdir@
python_libspec = @python_libspec@
+python_additional_libs = @python_additional_libs@
python_configdir = @python_configdir@
python_version = @python_version@
-# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.16 2004/10/10 19:07:55 tgl Exp $
+# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.17 2004/10/11 19:32:19 tgl Exp $
subdir = src/pl/plpython
top_builddir = ../../..
# On some platforms we can only build PL/Python if libpython is a
-# shared library. Since there is no official way to determine this,
-# we see if there is a file that is named like a shared library.
-ifneq (,$(wildcard $(python_configdir)/libpython*$(DLSUFFIX)*))
+# shared library. Since there is no official way to determine this
+# (at least not in pre-2.3 Python), we see if there is a file that is
+# named like a shared library.
+ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
shared_libpython = yes
endif
# Windows needs to convert backslashed paths to normal slashes,
-# and we have to remove -lpython from libspec since we are building our own
+# and we have to remove -lpython from the link since we are building our own
ifeq ($(PORTNAME), win32)
shared_libpython = yes
python_includespec := $(subst \,/,$(python_includespec))
-python_libspec := $(subst -lpython$(python_version),,$(python_libspec))
+override python_libspec :=
endif
# Darwin (OS X) has its own ideas about how to do this.
ifeq ($(PORTNAME), darwin)
shared_libpython = yes
override python_libspec := -framework Python
+override python_additional_libs :=
endif
# If we don't have a shared library and the platform doesn't allow it
endif
-SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec)
+SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) $(python_additional_libs)
include $(top_srcdir)/src/Makefile.shlib