Index: m4/python.m4
===================================================================
--- m4/python.m4	(revision 993)
+++ m4/python.m4	(working copy)
@@ -254,4 +254,38 @@
 [AC_MSG_RESULT(not found)
 $2])
 CPPFLAGS="$save_CPPFLAGS"
+
+	# This bit is copied from Planner. murrayc.
+	# Check for Python library path
+        AC_MSG_CHECKING([for Python library path])
+
+	# Win32 has libpython25.a instead of libpython2.5.a, so we look
+	# for both. TODO: Only look for libpython25.a on Windows, and for
+	# libpython2.5.a on unix.
+	WIN32_PYTHON_VERSION=`echo $PYTHON_VERSION | sed "s,\.,,"`
+
+        python_path=`dirname $PYTHON | sed "s,/bin.*$,,"`
+        for i in "$python_path/lib/python$PYTHON_VERSION/config/" "$python_path/lib/python$PYTHON_VERSION/" "$python_path/lib/python/config/" "$python_path/lib/python/" "$python_path/" ; do
+		if test -e "$i"; then
+	                python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
+        	        if test -n "$python_path" ; then
+				python_lib="python$PYTHON_VERSION"
+                	        break
+	                fi
+
+			# Additionally test WIN32_PYTHON_VERSION
+	                python_path=`find $i -type f -name libpython$WIN32_PYTHON_VERSION.* -print | sed "1q"`
+        	        if test -n "$python_path" ; then
+				python_lib="python$WIN32_PYTHON_VERSION"
+                	        break
+	                fi
+		fi
+        done
+
+        python_path=`echo $python_path | sed "s,/libpython.*$,,"`
+        AC_MSG_RESULT([$python_path])
+        if test -z "$python_path" ; then
+                AC_MSG_ERROR([cannot find Python library path])
+        fi
+        AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -l$python_lib"])
 ])
Index: gobject/Makefile.am
===================================================================
--- gobject/Makefile.am	(revision 993)
+++ gobject/Makefile.am	(working copy)
@@ -70,4 +70,5 @@
 
 if PLATFORM_WIN32
 _gobject_la_CFLAGS += -DPLATFORM_WIN32
+_gobject_la_LIBADD += $(PYTHON_LDFLAGS)
 endif
Index: glib/Makefile.am
===================================================================
--- glib/Makefile.am	(revision 993)
+++ glib/Makefile.am	(working copy)
@@ -21,6 +21,12 @@
 
 libpyglib_2_0_la_CFLAGS = $(GLIB_CFLAGS)
 libpyglib_2_0_la_LIBADD = $(GLIB_LIBS) $(FFI_LIBS)
+
+if PLATFORM_WIN32
+libpyglib_2_0_la_LIBADD += $(PYTHON_LDFLAGS)
+libpyglib_2_0_la_LDFLAGS = -no-undefined
+endif
+
 libpyglib_2_0_la_SOURCES = 	\
 	pyglib.c		\
 	pyglib.h		\
@@ -30,6 +36,11 @@
 _glib_la_CFLAGS = $(GLIB_CFLAGS)
 _glib_la_LDFLAGS = $(common_ldflags) -export-symbols-regex "_glib|PyInit__glib"
 _glib_la_LIBADD = $(GLIB_LIBS) libpyglib-2.0.la
+
+if PLATFORM_WIN32
+_glib_la_LIBADD += $(PYTHON_LDFLAGS)
+endif
+
 _glib_la_SOURCES = 	 	\
 	glibmodule.c	 	\
 	pygiochannel.c 	 	\
Index: gio/Makefile.am
===================================================================
--- gio/Makefile.am	(revision 993)
+++ gio/Makefile.am	(working copy)
@@ -60,11 +60,16 @@
 	pygio-utils.c \
 	pygio-utils.h
 nodist__gio_la_SOURCES = gio.c
+
 if BUILD_GIO
 pkgpyexec_LTLIBRARIES += _gio.la
 defs_DATA += $(GIO_DEFS)
 endif
 
+if PLATFORM_WIN32
+_gio_la_LIBADD += $(PYTHON_LDFLAGS)
+endif
+
 # giounix module
 GIOUNIX_DEFS = unix.defs unix-types.defs unix.override
 CLEANFILES += unix.c
@@ -75,11 +80,15 @@
 unix_la_LIBADD = $(GIOUNIX_LIBS)
 unix_la_SOURCES = unixmodule.c
 nodist_unix_la_SOURCES = unix.c
+
 if BUILD_GIOUNIX
 pkgpyexec_LTLIBRARIES += unix.la
 defs_DATA += $(GIOUNIX_DEFS)
 endif
 
+if PLATFORM_WIN32
+unix_la_LIBADD += $(PYTHON_LDFLAGS)
+endif
 
 # code generator
 .defs.c:
