Index: dsextras.py
===================================================================
--- dsextras.py	(revisione 1002)
+++ dsextras.py	(copia locale)
@@ -145,6 +145,14 @@
         if save_libs != None and save_libs != ext.libraries:
             ext.libraries = save_libs
 
+    def get_export_symbols (self, ext):
+        # if --export-all-symbols is explicitely passed
+        # in the extra_link_args, prevent build_ext
+        # from automatically creating a def file
+        if '--export-all-symbols' in ext.extra_link_args:
+            pass
+        build_ext.get_export_symbols (self, ext)
+
 class InstallLib(install_lib):
 
     local_outputs = []
@@ -220,10 +228,19 @@
     can_build_ok = None
     def __init__(self, **kwargs):
         name = kwargs['pkc_name']
-        kwargs['include_dirs'] = self.get_include_dirs(name) + GLOBAL_INC
+        if 'include_dirs' in kwargs:
+            kwargs['include_dirs'] += self.get_include_dirs(name) + GLOBAL_INC
+        else:
+            kwargs['include_dirs'] = self.get_include_dirs(name) + GLOBAL_INC
         kwargs['define_macros'] = GLOBAL_MACROS
-        kwargs['libraries'] = self.get_libraries(name)
-        kwargs['library_dirs'] = self.get_library_dirs(name)
+        if 'libraries' in kwargs:
+            kwargs['libraries'] += self.get_libraries(name)
+        else:
+            kwargs['libraries'] = self.get_libraries(name)
+        if 'library_dirs' in kwargs:
+            kwargs['library_dirs'] += self.get_library_dirs(name)
+        else:
+            kwargs['library_dirs'] = self.get_library_dirs(name)
         if 'pygobject_pkc' in kwargs:
             self.pygobject_pkc = kwargs.pop('pygobject_pkc')
         if self.pygobject_pkc:
Index: setup.py
===================================================================
--- setup.py	(revisione 1002)
+++ setup.py	(copia locale)
@@ -12,7 +12,7 @@
 
 from dsextras import get_m4_define, getoutput, have_pkgconfig, \
      GLOBAL_INC, GLOBAL_MACROS, InstallLib, InstallData, BuildExt, \
-     PkgConfigExtension
+     PkgConfigExtension, TemplateExtension
 
 if '--yes-i-know-its-not-supported' in sys.argv:
     sys.argv.remove('--yes-i-know-its-not-supported')
@@ -39,7 +39,7 @@
 
 VERSION = "%d.%d.%d" % (MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)
 
-GOBJECT_REQUIRED  = get_m4_define('glib_required_version')
+GLIB_REQUIRED  = get_m4_define('glib_required_version')
 
 PYGOBJECT_SUFFIX = '2.0'
 PYGOBJECT_SUFFIX_LONG = 'gtk-' + PYGOBJECT_SUFFIX
@@ -49,7 +49,7 @@
                   ('PYGOBJECT_MINOR_VERSION', MINOR_VERSION),
                   ('PYGOBJECT_MICRO_VERSION', MICRO_VERSION)]
 
-if sys.platform == 'win33':
+if sys.platform == 'win32':
     GLOBAL_MACROS.append(('VERSION', '"""%s"""' % VERSION))
 else:
     GLOBAL_MACROS.append(('VERSION', '"%s"' % VERSION))
@@ -110,26 +110,67 @@
 PyGObjectBuild.user_options.append(('enable-threading', None,
                                 'enable threading support'))
 
+# pyglib shared library
+pyglib = PkgConfigExtension(name='glib.pyglib',
+                          pkc_name='glib-2.0',
+                          pkc_version=GLIB_REQUIRED,
+                          pygobject_pkc=None,
+                          include_dirs=['glib'],
+                          extra_link_args=['--export-all-symbols'],
+                          sources=['glib/pyglib.c'])
+
+# glib
+glib = PkgConfigExtension(name='glib._glib',
+                          pkc_name='glib-2.0',
+                          pkc_version=GLIB_REQUIRED,
+                          pygobject_pkc=None,
+                          include_dirs=['glib'],
+                          library_dirs=['build\lib.win32-2.5/glib'],
+                          libraries=['pyglib'],
+                          sources=['glib/glibmodule.c',
+                                   'glib/pygiochannel.c',
+                                   'glib/pygmaincontext.c',
+                                   'glib/pygmainloop.c',
+                                   'glib/pygoptioncontext.c',
+                                   'glib/pygoptiongroup.c',
+                                   'glib/pygsource.c',
+                                   'glib/pygspawn.c',
+                                   ])
+
 # GObject
-gobject = PkgConfigExtension(name='gobject._gobject', pkc_name='gobject-2.0',
-                             pkc_version=GOBJECT_REQUIRED,
+gobject = PkgConfigExtension(name='gobject._gobject',
+                             pkc_name='gobject-2.0',
+                             pkc_version=GLIB_REQUIRED,
                              pygobject_pkc=None,
+                             include_dirs=['glib'],
+                             library_dirs=['build\lib.win32-2.5/glib'],
+                             libraries=['pyglib'],
                              sources=['gobject/gobjectmodule.c',
                                       'gobject/pygboxed.c',
                                       'gobject/pygenum.c',
                                       'gobject/pygflags.c',
+                                      'gobject/pyginterface.c',
                                       'gobject/pygobject.c',
-                                      'gobject/pygmaincontext.c',
-                                      'gobject/pygmainloop.c',
-                                      'gobject/pygoptioncontext.c',
-                                      'gobject/pygoptiongroup.c',
                                       'gobject/pygparamspec.c',
                                       'gobject/pygpointer.c',
                                       'gobject/pygtype.c',
-                                      'gobject/pygsource.c',
-                                      'gobject/pygiochannel.c',
                                       ])
 
+# gio
+gio = TemplateExtension(name='gio',
+                        pkc_name='gio-2.0',
+                        pkc_version=GLIB_REQUIRED,
+                        output='gio._gio',
+                        defs='gio/gio.defs',
+                        include_dirs=['glib'],
+                             library_dirs=['build\lib.win32-2.5/glib'],
+                             libraries=['pyglib'],
+                        sources=['gio/giomodule.c',
+                                 'gio/gio.c',
+                                 'gio/pygio-utils.c'],
+                        register=['gio/gio.defs'],
+                        override='gio/gio.override')
+
 data_files = []
 ext_modules = []
 py_modules = []
@@ -139,9 +180,24 @@
     print "Error, could not find pkg-config"
     raise SystemExit
 
+if pyglib.can_build():
+    ext_modules.append(pyglib)
+    data_files.append((INCLUDE_DIR, ('glib/pyglib.h',)))
+else:
+    print
+    print 'ERROR: Nothing to do, glib could not be found and is essential.'
+    raise SystemExit
+
+if glib.can_build():
+    ext_modules.append(glib)
+    py_modules.append('glib.option')
+else:
+    print
+    print 'ERROR: Nothing to do, glib could not be found and is essential.'
+    raise SystemExit
+
 if gobject.can_build():
     ext_modules.append(gobject)
-    py_modules.append('gobject.option')
     data_files.append((INCLUDE_DIR, ('gobject/pygobject.h',)))
     data_files.append((HTML_DIR, glob.glob('docs/html/*.html')))
     data_files.append((HTML_DIR, ['docs/style.css']))
@@ -151,6 +207,13 @@
     print 'ERROR: Nothing to do, gobject could not be found and is essential.'
     raise SystemExit
 
+if gio.can_build():
+    ext_modules.append(gio)
+else:
+    print
+    print 'ERROR: Nothing to do, gio could not be found and is essential.'
+    raise SystemExit
+
 # Threading support
 if '--disable-threading' in sys.argv:
     sys.argv.remove('--disable-threading')
Index: glib/pygiochannel.c
===================================================================
--- glib/pygiochannel.c	(revisione 1002)
+++ glib/pygiochannel.c	(copia locale)
@@ -10,6 +10,7 @@
 
 #include "pyglib.h"
 #include "pyglib-private.h"
+#include "pygsource.h"
 
 typedef struct {
     PyObject_HEAD
