diff --git a/config/python.m4 b/config/python.m4 index 2a61559f8a..17dd085b97 100644 --- a/config/python.m4 +++ b/config/python.m4 @@ -1,7 +1,7 @@ # # 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 @@ -18,7 +18,7 @@ fi # _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]) @@ -44,13 +44,37 @@ AC_MSG_RESULT([$python_configdir]) # 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}$//"` -AC_MSG_RESULT([${python_libspec}]) +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} ${python_additional_libs}]) + +AC_SUBST(python_libdir)[]dnl AC_SUBST(python_libspec)[]dnl +AC_SUBST(python_additional_libs)[]dnl ])# PGAC_CHECK_PYTHON_EMBED_SETUP diff --git a/configure b/configure index e1a3057ba9..cbe7d901ca 100755 --- a/configure +++ b/configure @@ -4249,10 +4249,26 @@ echo "${ECHO_T}$python_configdir" >&6 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 @@ -18893,7 +18909,9 @@ s,@PYTHON@,$PYTHON,;t t 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 diff --git a/src/Makefile.global.in b/src/Makefile.global.in index f76fd0874a..49a684ad19 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-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, @@ -135,7 +135,9 @@ enable_debug = @enable_debug@ 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@ diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile index 569a981119..5987e817b1 100644 --- a/src/pl/plpython/Makefile +++ b/src/pl/plpython/Makefile @@ -1,4 +1,4 @@ -# $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 = ../../.. @@ -6,24 +6,26 @@ include $(top_builddir)/src/Makefile.global # 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 @@ -53,7 +55,7 @@ python${pytverstr}.def: $(WD)/system32/python${pytverstr}.dll endif -SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) +SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) $(python_additional_libs) include $(top_srcdir)/src/Makefile.shlib