Taken (and slightly modified) from gtk2hs upstream as:
Thu Dec 10 19:29:42 EET 2009  Duncan Coutts <duncan@haskell.org>
  * Handle installed package ids for ghc-6.12
Fri Feb 12 10:23:26 EET 2010  Axel.Simon@in.tum.de
  * Avoid using rec because of -XDoRec notation
diff --git a/acinclude.m4 b/acinclude.m4
index a109713..d2d576d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -98,8 +98,14 @@ if test "$USERPKGCONF" = "yes"; then
 fi
 if echo "${C}" | ${GREP} $1 > /dev/null 2> /dev/null
 then
-	$2=$(for pkg in ${C} ; do echo "${pkg}" | sed -e 's/^[[A-Za-z0-9-]]*-\([[0-9.]]*\)$/\1/' ; done | sort -r -n | head -n1)
-	AC_MSG_RESULT([yes, version $$2])
+	VER=$(for pkg in ${C} ; do echo "${pkg}" | sed -e 's/^[[A-Za-z0-9-]]*-\([[0-9.]]*\)$/\1/' ; done | sort -r -n | head -n1)
+	$2=${VER}
+	if test "${GHC_VERSION_612}" = "yes"; then
+		$3=$(${GHCPKG} field $1-${VER} id | cut -d' ' -f2)
+	else
+		$3=$1-${VER}
+	fi
+	AC_MSG_RESULT([yes, version ${VER}])
 else
 	AC_MSG_ERROR([
 Missing GHC package "$1". Install "$1" and re-run ./configure
diff --git a/cairo/cairo.package.conf.in b/cairo/cairo.package.conf.in
index 8195597..5651b8d 100644
--- a/cairo/cairo.package.conf.in
+++ b/cairo/cairo.package.conf.in
@@ -1,5 +1,6 @@
 name: cairo
 version: @PACKAGE_VERSION@
+id: cairo-@PACKAGE_VERSION@
 license: BSD3
 license-file: cairo/COPYRIGHT
 copyright: (c) Paolo Martini 2005, (c) Abraham Egnor 2003, 2004, (c) Aetion Technologies LLC 2004
@@ -15,5 +16,5 @@ hs-libraries: HScairo
 extra-libraries: @CAIRO_LIBS_CQ@
 include-dirs: @CAIRO_CFLAGS_CQ@
 includes: @CAIRO_HEADERS@
-depends: base-@PKG_BASE_VERSION@ mtl-@PKG_MTL_VERSION@ glib-@PACKAGE_VERSION@ @CAIRO_SPLITBASE_DEPENDS@
+depends: @PKG_BASE_ID@ @PKG_MTL_ID@ glib-@PACKAGE_VERSION@ @CAIRO_SPLITBASE_DEPENDS@
 ld-options: @CAIRO_LIBEXTRA_CQ@
diff --git a/configure.ac b/configure.ac
index 185044f..eaa5eb7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,6 +121,9 @@ GTKHS_PROG_CHECK_VERSION($GHC_VERSION, -ge, 6.10,
   GHC_VERSION_610=yes, GHC_VERSION_610=no)
 AM_CONDITIONAL(GHC_VERSION_610, test "$GHC_VERSION_610" = "yes")
 
+GTKHS_PROG_CHECK_VERSION($GHC_VERSION, -ge, 6.12,
+  GHC_VERSION_612=yes, GHC_VERSION_612=no)
+
 dnl Calculate a version number with 3 digits (i.e. 502 for 5.2)
 GHC_VERSION_NUMBER=`echo $GHC_VERSION | $SED "s/[[0-9]*\.\([0-9]]*\).*/0\1/"`
 GHC_VERSION_NUMBER=`echo $GHC_VERSION_NUMBER | $SED "s/[[0-9]*\([0-9][0-9]]\)/\1/"`
@@ -234,39 +237,53 @@ AC_ARG_WITH(pkgconf,
 	   [AS_HELP_STRING([--with-pkgconf=FILE], [GHC package file to install packages])],
 	   [PKGCONF=$withval;],[PKGCONF=;])
 
+m4_pattern_allow([^PKG_])
 
 dnl Check for various GHC packages:
-GHC_PKG_CHECK(base,PKG_BASE_VERSION)
-GTKHS_PROG_CHECK_VERSION($PKG_BASE_VERSION, -ge, 4.0,
-AC_DEFINE(HAVE_NEW_CONTROL_EXCEPTION,[1],[Define if you have the new Control.Exception module (from GHC 6.10)]))
-GHC_PKG_CHECK(haskell98,PKG_HASKELL98_VERSION)
-GHC_PKG_CHECK(mtl,PKG_MTL_VERSION)
+GHC_PKG_CHECK(base,      [PKG_BASE_VERSION],      [PKG_BASE_ID])
+GHC_PKG_CHECK(haskell98, [PKG_HASKELL98_VERSION], [PKG_HASKELL98_ID])
+GHC_PKG_CHECK(mtl,       [PKG_MTL_VERSION],       [PKG_MTL_ID])
+if test "$HAVE_SPLIT_BASE" = "yes"; then
+	GHC_PKG_CHECK(bytestring, [PKG_BYTESTRING_VERSION], [PKG_BYTESTRING_ID])
+	GHC_PKG_CHECK(containers, [PKG_CONTAINERS_VERSION], [PKG_CONTAINERS_ID])
+	GHC_PKG_CHECK(array,      [PKG_ARRAY_VERSION],      [PKG_ARRAY_ID])
+	GHC_PKG_CHECK(old-time,   [PKG_OLDTIME_VERSION],    [PKG_OLDTIME_ID])
+	GHC_PKG_CHECK(pretty,     [PKG_PRETTY_VERSION],     [HSPKG_PRETTY_ID])
+
+	CAIRO_SPLITBASE_DEPENDS="${PKG_BYTESTRING_ID} ${PKG_ARRAY_ID}"
+	GTK_SPLITBASE_DEPENDS="${PKG_CONTAINERS_ID} ${PKG_ARRAY_ID}"
+	SOEGTK_SPLITBASE_DEPENDS="${PKG_OLDTIME_ID}"
+	GNOMEVFS_SPLITBASE_DEPENDS="${PKG_BYTESTRING_ID}"
+	GSTREAMER_SPLITBASE_DEPENDS="${PKG_BYTESTRING_ID}"
+fi
 AC_SUBST(PKG_BASE_VERSION)
 AC_SUBST(PKG_HASKELL98_VERSION)
 AC_SUBST(PKG_MTL_VERSION)
-if test "$HAVE_SPLIT_BASE" = "yes"; then
-	GHC_PKG_CHECK(bytestring,PKG_BYTESTRING_VERSION)
-	CAIRO_SPLITBASE_DEPENDS="bytestring-${PKG_BYTESTRING_VERSION}"
-	GHC_PKG_CHECK(containers, [PKG_CONTAINERS_VERSION])
-	GHC_PKG_CHECK(array, [PKG_ARRAY_VERSION])
-	GHC_PKG_CHECK(old-time, [PKG_OLDTIME_VERSION])
-	GHC_PKG_CHECK(pretty, [PKG_PRETTY_VERSION])
-	GTK_SPLITBASE_DEPENDS="containers-${PKG_CONTAINERS_VERSION} array-${PKG_ARRAY_VERSION}"
-	SOEGTK_SPLITBASE_DEPENDS="old-time-${PKG_OLDTIME_VERSION}"
-	GNOMEVFS_SPLITBASE_DEPENDS="bytestring-${PKG_BYTESTRING_VERSION}"
-	GSTREAMER_SPLITBASE_DEPENDS="bytestring-${PKG_BYTESTRING_VERSION}"
-fi
 AC_SUBST(PKG_BYTESTRING_VERSION)
 AC_SUBST(PKG_CONTAINERS_VERSION)
 AC_SUBST(PKG_ARRAY_VERSION)
 AC_SUBST(PKG_OLDTIME_VERSION)
 AC_SUBST(PKG_PRETTY_VERSION)
+
+AC_SUBST(PKG_BASE_ID)
+AC_SUBST(PKG_HASKELL98_ID)
+AC_SUBST(PKG_MTL_ID)
+AC_SUBST(PKG_BYTESTRING_ID)
+AC_SUBST(PKG_CONTAINERS_ID)
+AC_SUBST(PKG_ARRAY_ID)
+AC_SUBST(PKG_OLDTIME_ID)
+AC_SUBST(PKG_PRETTY_ID)
+
 AC_SUBST(CAIRO_SPLITBASE_DEPENDS)
 AC_SUBST(GTK_SPLITBASE_DEPENDS)
 AC_SUBST(SOEGTK_SPLITBASE_DEPENDS)
 AC_SUBST(GNOMEVFS_SPLITBASE_DEPENDS)
 AC_SUBST(GSTREAMER_SPLITBASE_DEPENDS)
 
+GTKHS_PROG_CHECK_VERSION($PKG_BASE_VERSION, -ge, 4.0,
+AC_DEFINE(HAVE_NEW_CONTROL_EXCEPTION,[1],
+ [Define if you have the new Control.Exception module (from GHC 6.10)]))
+
 dnl Check for the GTK&Co libraries. Use the special PKG_CHECK_MODULES
 dnl macro from the pkg-config program.
 PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.0.0 gobject-2.0 >= 2.0.0], [], AC_MSG_ERROR([
diff --git a/gconf/gconf.package.conf.in b/gconf/gconf.package.conf.in
index b87b18f..7a3fd25 100644
--- a/gconf/gconf.package.conf.in
+++ b/gconf/gconf.package.conf.in
@@ -1,5 +1,6 @@
 name: gconf
 version: @PACKAGE_VERSION@
+id: gconf-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSgconf
 extra-libraries: @GCONF_LIBS_CQ@
 include-dirs: @GCONF_CFLAGS_CQ@
 includes: gconf/gconf-client.h
-depends: base-@PKG_BASE_VERSION@ glib-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ glib-@PACKAGE_VERSION@
 ld-options: @GCONF_LIBEXTRA_CQ@
diff --git a/gio/gio.package.conf.in b/gio/gio.package.conf.in
index d026012..4bc25f0 100644
--- a/gio/gio.package.conf.in
+++ b/gio/gio.package.conf.in
@@ -1,5 +1,6 @@
 name: gio
 version: @PACKAGE_VERSION@
+id: gio-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSgio
 extra-libraries: @GIO_LIBS_CQ@
 include-dirs: @GIO_CFLAGS_CQ@, "${pkglibdir}/include"
 includes: gio/gio.h
-depends: base-@PKG_BASE_VERSION@ glib-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ glib-@PACKAGE_VERSION@
 ld-options: @GIO_LIBEXTRA_CQ@
diff --git a/glade/glade.package.conf.in b/glade/glade.package.conf.in
index c975736..73020f8 100644
--- a/glade/glade.package.conf.in
+++ b/glade/glade.package.conf.in
@@ -1,5 +1,6 @@
 name: glade
 version: @PACKAGE_VERSION@
+id: glade-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSglade
 extra-libraries: @LIBGLADE_LIBS_CQ@
 include-dirs: @LIBGLADE_CFLAGS_CQ@
 includes: glade/glade.h
-depends: base-@PKG_BASE_VERSION@ gtk-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ gtk-@PACKAGE_VERSION@
 ld-options: @LIBGLADE_LIBEXTRA_CQ@
diff --git a/glib/glib.package.conf.in b/glib/glib.package.conf.in
index 29393aa..72845f1 100644
--- a/glib/glib.package.conf.in
+++ b/glib/glib.package.conf.in
@@ -1,5 +1,6 @@
 name: glib
 version: @PACKAGE_VERSION@
+id: glib-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSglib
 extra-libraries: @GLIB_LIBS_CQ@
 include-dirs: @GLIB_CFLAGS_CQ@, "${pkglibdir}/include"
 includes: glib.h, glib-object.h
-depends: base-@PKG_BASE_VERSION@
+depends: @PKG_BASE_ID@
 ld-options: @GLIB_LIBEXTRA_CQ@
diff --git a/gnomevfs/gnomevfs.package.conf.in b/gnomevfs/gnomevfs.package.conf.in
index 6ab0ce8..809f275 100644
--- a/gnomevfs/gnomevfs.package.conf.in
+++ b/gnomevfs/gnomevfs.package.conf.in
@@ -1,5 +1,6 @@
 name: gnomevfs
 version: @PACKAGE_VERSION@
+id: gnomevfs-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LGPLv3
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSgnomevfs
 extra-libraries: @GNOMEVFS_LIBS_CQ@
 include-dirs: @GNOMEVFS_CFLAGS_CQ@
 includes: libgnomevfs/gnome-vfs.h libgnomevfs/gnome-vfs-mime.h
-depends: glib-@PACKAGE_VERSION@ mtl-@PKG_MTL_VERSION@ @GNOMEVFS_SPLITBASE_DEPENDS@
+depends: glib-@PACKAGE_VERSION@ @PKG_MTL_ID@ @GNOMEVFS_SPLITBASE_DEPENDS@
 ld-options: @GNOMEVFS_LIBEXTRA_CQ@
diff --git a/gstreamer/gstreamer.package.conf.in b/gstreamer/gstreamer.package.conf.in
index 62d2d0c..9020bb1 100644
--- a/gstreamer/gstreamer.package.conf.in
+++ b/gstreamer/gstreamer.package.conf.in
@@ -1,5 +1,6 @@
 name: gstreamer
 version: @PACKAGE_VERSION@
+id: gstreamer-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSgstreamer
 extra-libraries: @GSTREAMER_LIBS_CQ@
 include-dirs: @GSTREAMER_CFLAGS_CQ@
 includes: gst/gst.h
-depends: glib-@PACKAGE_VERSION@ mtl-@PKG_MTL_VERSION@ @GSTREAMER_SPLITBASE_DEPENDS@
+depends: glib-@PACKAGE_VERSION@ @PKG_MTL_ID@ @GSTREAMER_SPLITBASE_DEPENDS@
 ld-options: @GSTREAMER_LIBEXTRA_CQ@
diff --git a/gtk/Graphics/UI/Gtk/Display/StatusIcon.chs.pp b/gtk/Graphics/UI/Gtk/Display/StatusIcon.chs.pp
index d5f8f00..05eb5e4 100644
--- a/gtk/Graphics/UI/Gtk/Display/StatusIcon.chs.pp
+++ b/gtk/Graphics/UI/Gtk/Display/StatusIcon.chs.pp
@@ -448,9 +448,9 @@ statusIconGetGeometry self =
          (toStatusIcon self) nullPtr (castPtr recPtr) orPtr) >>= \b ->
         if b 
           then do
-            rec <- peek recPtr
+            rec_ <- peek recPtr
             or <- peek orPtr
-            return $ Just (rec,toEnum $ fromIntegral or)
+            return $ Just (rec_,toEnum $ fromIntegral or)
         else return Nothing
 
 
diff --git a/gtk/gtk.package.conf.in b/gtk/gtk.package.conf.in
index ace6cdc..ed6c9ac 100644
--- a/gtk/gtk.package.conf.in
+++ b/gtk/gtk.package.conf.in
@@ -1,5 +1,6 @@
 name: gtk
 version: @PACKAGE_VERSION@
+id: gtk-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSgtk
 extra-libraries: @GTK_LIBS_CQ@
 include-dirs: @GTK_CFLAGS_CQ@
 includes: gtk/gtk.h
-depends: base-@PKG_BASE_VERSION@ mtl-@PKG_MTL_VERSION@ glib-@PACKAGE_VERSION@ @GTK_CAIRO_DEPEND@ @GTK_SPLITBASE_DEPENDS@
+depends: @PKG_BASE_ID@ @PKG_MTL_ID@ glib-@PACKAGE_VERSION@ @GTK_CAIRO_DEPEND@ @GTK_SPLITBASE_DEPENDS@
 ld-options: @GTK_LIBEXTRA_CQ@
diff --git a/gtkglext/gtkglext.package.conf.in b/gtkglext/gtkglext.package.conf.in
index bb0d5e3..447036d 100644
--- a/gtkglext/gtkglext.package.conf.in
+++ b/gtkglext/gtkglext.package.conf.in
@@ -1,5 +1,6 @@
 name: gtkglext
 version: @PACKAGE_VERSION@
+id: gtkglext-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSgtkglext
 extra-libraries: @GTKGLEXT_LIBS_CQ@
 include-dirs: @GTKGLEXT_CFLAGS_CQ@
 includes: gtk/gtkgl.h
-depends: base-@PKG_BASE_VERSION@ gtk-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ gtk-@PACKAGE_VERSION@
 ld-options: @GTKGLEXT_LIBEXTRA_CQ@
diff --git a/gtksourceview2/gtksourceview2.package.conf.in b/gtksourceview2/gtksourceview2.package.conf.in
index 34f0bfd..ba9f69d 100644
--- a/gtksourceview2/gtksourceview2.package.conf.in
+++ b/gtksourceview2/gtksourceview2.package.conf.in
@@ -1,5 +1,6 @@
 name: gtksourceview2
 version: @PACKAGE_VERSION@
+id: gtksourceview2-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -22,5 +23,5 @@ includes: gtksourceview/gtksourcebuffer.h,
           gtksourceview/gtksourcestyleschememanager.h,
           gtksourceview/gtksourceview.h,
           gtksourceview/gtksourceview-typebuiltins.h
-depends: base-@PKG_BASE_VERSION@ gtk-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ gtk-@PACKAGE_VERSION@
 ld-options: @GTKSOURCEVIEW2_LIBEXTRA_CQ@
diff --git a/mozembed/mozembed.package.conf.in b/mozembed/mozembed.package.conf.in
index 0bea05f..ef1872e 100644
--- a/mozembed/mozembed.package.conf.in
+++ b/mozembed/mozembed.package.conf.in
@@ -1,5 +1,6 @@
 name: mozembed
 version: @PACKAGE_VERSION@
+id: mozembed-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -13,5 +14,5 @@ hs-libraries: HSmozembed
 extra-libraries: @MOZEMBED_LIBS_CQ@
 include-dirs: @MOZEMBED_CFLAGS_CQ@
 includes: gtkmozembed.h
-depends: base-@PKG_BASE_VERSION@ gtk-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ gtk-@PACKAGE_VERSION@
 ld-options: @MOZEMBED_LIBEXTRA_CQ@
diff --git a/soegtk/soegtk.package.conf.in b/soegtk/soegtk.package.conf.in
index 61f1232..5208a6f 100644
--- a/soegtk/soegtk.package.conf.in
+++ b/soegtk/soegtk.package.conf.in
@@ -1,5 +1,6 @@
 name: soegtk
 version: @PACKAGE_VERSION@
+id: soegtk-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -10,4 +11,4 @@ exposed-modules: Graphics.SOE.Gtk
 import-dirs: "${pkglibdir}/imports/soegtk"
 library-dirs: @GTK_LIBDIR_CQ@
 hs-libraries: HSsoegtk
-depends: base-@PKG_BASE_VERSION@ mtl-@PKG_MTL_VERSION@ gtk-@PACKAGE_VERSION@ @GTK_CAIRO_DEPEND@ @SOEGTK_SPLITBASE_DEPENDS@
+depends: @PKG_BASE_ID@ @PKG_MTL_ID@ gtk-@PACKAGE_VERSION@ @GTK_CAIRO_DEPEND@ @SOEGTK_SPLITBASE_DEPENDS@
diff --git a/sourceview/sourceview.package.conf.in b/sourceview/sourceview.package.conf.in
index d3af320..5ef518f 100644
--- a/sourceview/sourceview.package.conf.in
+++ b/sourceview/sourceview.package.conf.in
@@ -1,5 +1,6 @@
 name: sourceview
 version: @PACKAGE_VERSION@
+id: sourceview-@PACKAGE_VERSION@
 license: LGPL
 license-file: COPYING.LIB
 maintainer: gtk2hs-users@lists.sourceforge.net
@@ -16,5 +17,5 @@ includes: gtksourceview/gtksourcelanguagesmanager.h,
           gtksourceview/gtksourcetag.h,
           gtksourceview/gtksourceiter.h,
 	  gtksourceview/gtksourceview.h
-depends: base-@PKG_BASE_VERSION@ gtk-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ gtk-@PACKAGE_VERSION@
 ld-options: @SOURCEVIEW_LIBEXTRA_CQ@
diff --git a/svgcairo/svgcairo.package.conf.in b/svgcairo/svgcairo.package.conf.in
index 3867d53..9b32287 100644
--- a/svgcairo/svgcairo.package.conf.in
+++ b/svgcairo/svgcairo.package.conf.in
@@ -1,5 +1,6 @@
 name: svgcairo
 version: @PACKAGE_VERSION@
+id: svgcairo-@PACKAGE_VERSION@
 license: BSD3
 license-file: cairo/COPYRIGHT
 copyright: (c) Duncan Coutts 2005, (c) Paolo Martini 2005
@@ -15,5 +16,5 @@ hs-libraries: HSsvgcairo
 extra-libraries: @SVGCAIRO_LIBS_CQ@
 include-dirs: @SVGCAIRO_CFLAGS_CQ@
 includes: librsvg/rsvg-cairo.h, librsvg/rsvg.h
-depends: base-@PKG_BASE_VERSION@ mtl-@PKG_MTL_VERSION@ glib-@PACKAGE_VERSION@ cairo-@PACKAGE_VERSION@
+depends: @PKG_BASE_ID@ @PKG_MTL_ID@ glib-@PACKAGE_VERSION@ cairo-@PACKAGE_VERSION@
 ld-options: @SVGCAIRO_LIBEXTRA_CQ@
