Index: config/python.m4
===================================================================
RCS file: /projects/cvsroot/pgsql-server/config/python.m4,v
retrieving revision 1.8
diff -c -r1.8 python.m4
*** config/python.m4	16 Sep 2004 23:30:30 -0000	1.8
--- config/python.m4	26 Sep 2004 14:28:56 -0000
***************
*** 34,48 ****
  python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
  python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
  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')"`
! python_includespec="-I${python_prefix}/include/python${python_version}"
! if test "$python_prefix" != "$python_execprefix"; then
!   python_includespec="-I${python_execprefix}/include/python${python_version} $python_includespec"
! fi
  
  AC_SUBST(python_prefix)[]dnl
  AC_SUBST(python_execprefix)[]dnl
  AC_SUBST(python_configdir)[]dnl
  AC_SUBST(python_includespec)[]dnl
  # This should be enough of a message.
  if test "$python_prefix" != "$python_execprefix"; then
    AC_MSG_RESULT([$python_prefix/lib/python${python_version} and $python_execprefix/lib/python${python_version}])
--- 34,46 ----
  python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
  python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
  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')"`
! python_includespec=`${PYTHON} -c "import distutils.sysconfig; print '-I'+distutils.sysconfig.get_python_inc()"`
  
  AC_SUBST(python_prefix)[]dnl
  AC_SUBST(python_execprefix)[]dnl
  AC_SUBST(python_configdir)[]dnl
  AC_SUBST(python_includespec)[]dnl
+ AC_SUBST(python_version)[]dnl
  # This should be enough of a message.
  if test "$python_prefix" != "$python_execprefix"; then
    AC_MSG_RESULT([$python_prefix/lib/python${python_version} and $python_execprefix/lib/python${python_version}])
***************
*** 54,77 ****

  # PGAC_CHECK_PYTHON_EMBED_SETUP
  # -----------------------------
- # Courtesy of the INN 2.3.1 package...
  AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
  [AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
  AC_MSG_CHECKING([how to link an embedded Python application])

! if test ! -f "$python_configdir/Makefile"; then
!   AC_MSG_RESULT(no)
!   AC_MSG_ERROR([Python Makefile not found])
! fi
!
! _python_libs=`grep '^LIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libc=`grep '^LIBC=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libm=`grep '^LIBM=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_liblocalmod=`grep '^LOCALMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libbasemod=`grep '^BASEMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
!
! pgac_tab="	" # tab character
! python_libspec=`echo X"-L$python_configdir $_python_libs $_python_libc $_python_libm -lpython$python_version $_python_liblocalmod $_python_libbasemod" | sed -e 's/^X//' -e "s/[[ $pgac_tab]][[ $pgac_tab]]*/ /g"`

  AC_MSG_RESULT([${python_libspec}])

--- 52,62 ----

  # PGAC_CHECK_PYTHON_EMBED_SETUP
  # -----------------------------
  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 string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`

  AC_MSG_RESULT([${python_libspec}])

Index: src/Makefile.global.in
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/Makefile.global.in,v
retrieving revision 1.195
diff -c -r1.195 Makefile.global.in
*** src/Makefile.global.in	18 Sep 2004 13:28:54 -0000	1.195
--- src/Makefile.global.in	26 Sep 2004 14:30:14 -0000
***************
*** 137,142 ****
--- 137,143 ----
  python_includespec	= @python_includespec@
  python_libspec		= @python_libspec@
  python_configdir	= @python_configdir@
+ python_version		= @python_version@

  krb_srvtab = @krb_srvtab@

Index: src/pl/plpython/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/pl/plpython/Makefile,v
retrieving revision 1.14
diff -c -r1.14 Makefile
*** src/pl/plpython/Makefile	24 Sep 2004 20:08:42 -0000	1.14
--- src/pl/plpython/Makefile	26 Sep 2004 14:45:26 -0000
***************
*** 12,17 ****
--- 12,23 ----
  shared_libpython = yes
  endif

+ # Convert backslashed paths to normal slashes
+ ifeq ($(PORTNAME), win32)
+ shared_libpython = yes
+ python_includespec := $(subst \,/,$(python_includespec))
+ endif
+
  # Darwin (OS X) has its own ideas about how to do this.
  ifeq ($(PORTNAME), darwin)
  shared_libpython = yes
***************
*** 30,35 ****
--- 36,56 ----
  SO_MINOR_VERSION = 0
  OBJS = plpython.o

+
+ # Python on win32 ships with import libraries only for Microsoft Visual C++,
+ # which are not compatible with mingw gcc. Therefore we need to build a
+ # new import library to link with.
+ ifeq ($(PORTNAME), win32)
+ pytverstr=$(subst .,,${python_version})
+ OBJS += libpython${pytverstr}.a
+ libpython23.a: python${pytverstr}.def
+ 	dlltool --dllname python${pytverstr}.dll --def python${pytverstr}.def --output-lib  libpython${pytverstr}.a
+ WD=$(subst \,/,$(WINDIR))
+ python23.def: $(WD)/system32/python${pytverstr}.dll
+ 	pexports $(WD)/system32/python${pytverstr}.dll > python${pytverstr}.def
+ endif
+
+
  SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec)

  include $(top_srcdir)/src/Makefile.shlib
***************
*** 55,60 ****
--- 76,84 ----
  clean distclean maintainer-clean: clean-lib
  	rm -f $(OBJS)
  	@rm -f error.diff feature.diff error.output feature.output test.log
+ ifeq ($(PORTNAME), win32)
+ 	rm -f python${pytverstr}.def
+ endif

  installcheck:
  	PATH=$(bindir):$$PATH $(SHELL) $(srcdir)/test.sh
