diff -Naur a/gi/Makefile.am b/gi/Makefile.am
--- a/gi/Makefile.am	2011-06-13 20:30:25.000000000 +0400
+++ b/gi/Makefile.am	2014-02-23 11:03:40.784200000 +0400
@@ -22,7 +22,8 @@
 _gi_la_LDFLAGS = \
 	-module \
 	-avoid-version \
-	-export-symbols-regex "init_gi|PyInit__gi"
+	-export-symbols-regex "init_gi|PyInit__gi" \
+	-shrext $(PYTHON_SO)
 _gi_la_LIBADD = \
 	$(GI_LIBS) \
 	$(top_builddir)/glib/libpyglib-2.0-@PYTHON_BASENAME@.la
@@ -82,13 +83,13 @@
 # This is to ensure we have a symlink to the .so in the
 # build directory, which the Python interpreter can load
 # directly without having to know how to parse .la files.
-.la.so:
-	test -L $@ || $(LN_S) .libs/$@ $@
+%$(PYTHON_SO): %.la
+	$(LN_S) -f .libs/$@ $@
 
-all-local: $(LTLIBRARIES:.la=.so)
-check-local: $(LTLIBRARIES:.la=.so)
+all-local: $(LTLIBRARIES:.la=$(PYTHON_SO))
+check-local: $(LTLIBRARIES:.la=$(PYTHON_SO))
 clean-local:
-	rm -f $(LTLIBRARIES:.la=.so)
+	rm -f $(LTLIBRARIES:.la=$(PYTHON_SO))
 
 
 
diff -Naur a/gio/Makefile.am b/gio/Makefile.am
--- a/gio/Makefile.am	2011-06-13 20:33:49.000000000 +0400
+++ b/gio/Makefile.am	2014-02-23 11:05:13.589200000 +0400
@@ -25,7 +25,7 @@
 pygio_PYTHON = 	__init__.py
 
 # linker flags
-common_ldflags = -module -avoid-version
+common_ldflags = -module -avoid-version -shrext $(PYTHON_SO)
 if PLATFORM_WIN32
 common_ldflags += -no-undefined
 endif
@@ -67,7 +67,7 @@
 gio.c: $(GIO_DEFS) $(GIO_OVERRIDES)
 _gio_la_CFLAGS = $(GIO_CFLAGS)
 _gio_la_LDFLAGS = $(common_ldflags) -export-symbols-regex init_gio
-_gio_la_LIBADD = $(GIO_LIBS) $(top_builddir)/glib/libpyglib-2.0-@PYTHON_BASENAME@.la
+_gio_la_LIBADD = $(GIO_LIBS) $(PYTHON_LIBS) $(top_builddir)/glib/libpyglib-2.0-@PYTHON_BASENAME@.la
 _gio_la_SOURCES = \
 	giomodule.c \
 	pygio-utils.c \
@@ -85,7 +85,7 @@
 unix.c: $(GIOUNIX_DEFS) unix.override
 unix_la_CFLAGS = $(GIOUNIX_CFLAGS)
 unix_la_LDFLAGS = $(common_ldflags) -export-symbols-regex initunix
-unix_la_LIBADD = $(GIOUNIX_LIBS)
+unix_la_LIBADD = $(GIOUNIX_LIBS) $(PYTHON_LIBS)
 unix_la_SOURCES = unixmodule.c
 nodist_unix_la_SOURCES = unix.c
 if BUILD_GIOUNIX
@@ -108,10 +108,10 @@
 
 
 if BUILD_GIO
-all: $(pkgpyexec_LTLIBRARIES:.la=.so)
-check-local: $(pkgpyexec_LTLIBRARIES:.la=.so)
+all: $(pkgpyexec_LTLIBRARIES:.la=$(PYTHON_SO))
+check-local: $(pkgpyexec_LTLIBRARIES:.la=$(PYTHON_SO))
 clean-local:
-	rm -f $(pkgpyexec_LTLIBRARIES:.la=.so)
-.la.so:
-	$(LN_S) .libs/$@ $@ || true
+	rm -f $(pkgpyexec_LTLIBRARIES:.la=$(PYTHON_SO))
+%$(PYTHON_SO): %.la
+	$(LN_S) -f .libs/$@ $@
 endif
diff -Naur a/glib/Makefile.am b/glib/Makefile.am
--- a/glib/Makefile.am	2011-06-13 20:33:49.000000000 +0400
+++ b/glib/Makefile.am	2014-02-23 11:06:35.612600000 +0400
@@ -20,13 +20,14 @@
 	option.py
 pyglib_LTLIBRARIES = _glib.la
 
-common_ldflags = -module -avoid-version
+common_ldflags = -module -avoid-version -shrext $(PYTHON_SO)
 if PLATFORM_WIN32
 common_ldflags += -no-undefined
 endif
 
 libpyglib_2_0_@PYTHON_BASENAME@_la_CFLAGS = $(GLIB_CFLAGS)
-libpyglib_2_0_@PYTHON_BASENAME@_la_LIBADD = $(GLIB_LIBS) $(FFI_LIBS)
+libpyglib_2_0_@PYTHON_BASENAME@_la_LDFLAGS = -no-undefined
+libpyglib_2_0_@PYTHON_BASENAME@_la_LIBADD = $(GLIB_LIBS) $(FFI_LIBS) $(PYTHON_LIBS)
 libpyglib_2_0_@PYTHON_BASENAME@_la_SOURCES = 	\
 	pyglib.c		\
 	pyglib.h		\
@@ -29,7 +30,7 @@
 
 _glib_la_CFLAGS = $(GLIB_CFLAGS)
 _glib_la_LDFLAGS = $(common_ldflags) -export-symbols-regex "_glib|PyInit__glib"
-_glib_la_LIBADD = $(GLIB_LIBS) libpyglib-2.0-@PYTHON_BASENAME@.la
+_glib_la_LIBADD = $(GLIB_LIBS) $(PYTHON_LIBS) libpyglib-2.0-@PYTHON_BASENAME@.la
 _glib_la_SOURCES = 	 	\
 	glibmodule.c	 	\
 	pygiochannel.c 	 	\
@@ -51,11 +52,11 @@
 _glib_la_CFLAGS += -DPLATFORM_WIN32
 endif
 
-all: $(pyglib_LTLIBRARIES:.la=.so)
-check-local: $(pyglib_LTLIBRARIES:.la=.so)
+all: $(pyglib_LTLIBRARIES:.la=$(PYTHON_SO))
+check-local: $(pyglib_LTLIBRARIES:.la=$(PYTHON_SO))
 clean-local:
-	rm -f $(pyglib_LTLIBRARIES:.la=.so)
-.la.so:
-	$(LN_S) .libs/$@ $@ || true
+	rm -f $(pyglib_LTLIBRARIES:.la=$(PYTHON_SO))
+%$(PYTHON_SO): %.la
+	$(LN_S) -f .libs/$@ $@
 
 -include $(top_srcdir)/git.mk
diff -Naur a/gobject/Makefile.am b/gobject/Makefile.am
--- a/gobject/Makefile.am	2011-06-13 20:33:49.000000000 +0400
+++ b/gobject/Makefile.am	2014-02-23 11:08:30.106000000 +0400
@@ -14,7 +14,7 @@
 	propertyhelper.py
 pygobject_LTLIBRARIES = _gobject.la 
 
-common_ldflags = -module -avoid-version
+common_ldflags = -module -avoid-version -shrext $(PYTHON_SO)
 if PLATFORM_WIN32
 common_ldflags += -no-undefined
 endif
@@ -35,6 +35,7 @@
 _gobject_la_LIBADD = \
 	$(GLIB_LIBS) \
 	$(FFI_LIBS) \
+	$(PYTHON_LIBS) \
 	$(top_builddir)/glib/libpyglib-2.0-@PYTHON_BASENAME@.la
 _gobject_la_SOURCES =           \
         gobjectmodule.c         \
@@ -65,11 +66,11 @@
 endif
 
 
-all: $(pygobject_LTLIBRARIES:.la=.so)
-check-local: $(pygobject_LTLIBRARIES:.la=.so)
+all: $(pygobject_LTLIBRARIES:.la=$(PYTHON_SO))
+check-local: $(pygobject_LTLIBRARIES:.la=$(PYTHON_SO))
 clean-local:
-	rm -f $(pygobject_LTLIBRARIES:.la=.so)
-.la.so:
-	$(LN_S) .libs/$@ $@ || true
+	rm -f $(pygobject_LTLIBRARIES:.la=$(PYTHON_SO))
+%$(PYTHON_SO): %.la
+	$(LN_S) -f .libs/$@ $@
 
 -include $(top_srcdir)/git.mk
diff -Naur a/tests/Makefile.am b/tests/Makefile.am
--- a/tests/Makefile.am	2011-06-13 20:33:49.000000000 +0400
+++ b/tests/Makefile.am	2014-02-23 11:09:57.671800000 +0400
@@ -5,10 +5,10 @@
 
 nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
 libregress_la_CFLAGS = $(GIO_CFLAGS) $(PYCAIRO_CFLAGS)
-libregress_la_LDFLAGS = -module -avoid-version $(GIO_LIBS) $(PYCAIRO_LIBS)
+libregress_la_LDFLAGS = -module -avoid-version -no-undefined $(GIO_LIBS) $(PYCAIRO_LIBS) -shrext $(PYTHON_SO)
 nodist_libgimarshallingtests_la_SOURCES = $(GI_DATADIR)/tests/gimarshallingtests.c $(GI_DATADIR)/tests/gimarshallingtests.h
 libgimarshallingtests_la_CFLAGS = $(GLIB_CFLAGS)
-libgimarshallingtests_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS)
+libgimarshallingtests_la_LDFLAGS = -module -avoid-version -no-undefined $(GLIB_LIBS) -shrext $(PYTHON_SO)
 
 # This is a hack to make sure a shared library is built
 libregress.la: $(libregress_la_OBJECTS) $(libregress_la_DEPENDENCIES)
@@ -49,7 +49,7 @@
 noinst_LTLIBRARIES += testhelper.la
 
 testhelper_la_CFLAGS = -I$(top_srcdir)/gobject -I$(top_srcdir)/glib $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
-testhelper_la_LDFLAGS = -module -avoid-version
+testhelper_la_LDFLAGS = -module -avoid-version -no-undefined $(PYTHON_LIBS) -shrext $(PYTHON_SO)
 testhelper_la_LIBADD = $(GLIB_LIBS)
 testhelper_la_SOURCES = \
 	testhelpermodule.c \
@@ -62,11 +62,11 @@
 	$(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS)
 
 
-.la.so:
-	test -L $@ || $(LN_S) .libs/$@ $@
+%$(PYTHON_SO): %.la
+	$(LN_S) -f .libs/$@ $@
 
 
-all: $(LTLIBRARIES:.la=.so)
+all: $(LTLIBRARIES:.la=$(PYTHON_SO))
 
 TEST_FILES_STATIC = \
 	test_gobject.py \
@@ -109,7 +109,7 @@
 EXTRA_DIST += $(TEST_FILES_STATIC) $(TEST_FILES_GI) $(TEST_FILES_GIO)
 
 clean-local:
-	rm -f $(LTLIBRARIES:.la=.so) file.txt~
+	rm -f $(LTLIBRARIES:.la=$(PYTHON_SO)) file.txt~
 
 DBUS_LAUNCH=$(shell which dbus-launch)
 RUN_TESTS_ENV_VARS= \
@@ -121,7 +121,7 @@
 RUN_TESTS_LAUNCH=$(RUN_TESTS_ENV_VARS) $(DBUS_LAUNCH) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py
 
 # run tests in separately to avoid loading static and introspection bindings in the same process
-check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib gschemas.compiled
+check-local: $(LTLIBRARIES:.la=$(PYTHON_SO)) Regress-1.0.typelib GIMarshallingTests-1.0.typelib gschemas.compiled
 	TEST_FILES="$(TEST_FILES_STATIC)" $(RUN_TESTS_LAUNCH)
 	TEST_FILES="$(TEST_FILES_GI)" $(RUN_TESTS_LAUNCH)
 if BUILD_GIO
