diff --git a/Graphics/UI/Gtk/OSX/Types.chs b/Graphics/UI/Gtk/OSX/Types.chs
--- a/Graphics/UI/Gtk/OSX/Types.chs
+++ b/Graphics/UI/Gtk/OSX/Types.chs
@@ -1,5 +1,5 @@
-{-# OPTIONS_HADDOCK hide #-}
 {-# LANGUAGE CPP #-}
+{-# OPTIONS_HADDOCK hide #-}
 -- -*-haskell-*-
 -- -------------------- automatically generated file - do not edit ----------
 --  Object hierarchy for the GIMP Toolkit (GTK) Binding for Haskell
@@ -42,7 +42,12 @@
   castToApplication, gTypeApplication
   ) where
 
-import Foreign.ForeignPtr (ForeignPtr, castForeignPtr, unsafeForeignPtrToPtr)
+import Foreign.ForeignPtr (ForeignPtr, castForeignPtr)
+#if __GLASGOW_HASKELL__ >= 707
+import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
+#else
+import Foreign.ForeignPtr (unsafeForeignPtrToPtr)
+#endif
 import Foreign.C.Types    (CULong(..), CUInt(..))
 import System.Glib.GType  (GType, typeInstanceIsA)
 {#import Graphics.UI.GtkInternals#}
diff --git a/Gtk2HsSetup.hs b/Gtk2HsSetup.hs
--- a/Gtk2HsSetup.hs
+++ b/Gtk2HsSetup.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE CPP #-}
+{-# LANGUAGE CPP, ViewPatterns #-}
 
 #ifndef CABAL_VERSION_CHECK
 #error This module has to be compiled via the Setup.hs program which generates the gtk2hs-macros.h file
@@ -29,7 +29,7 @@
                                                emptyBuildInfo, allBuildInfo,
                                                Library(..),
                                                libModules, hasLibs)
-import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..),
+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(withPackageDB, buildDir, localPkgDescr, installedPkgs, withPrograms),
                                            InstallDirs(..),
                                            componentPackageDeps,
                                            absoluteInstallDirs)
@@ -56,13 +56,25 @@
 import Distribution.Verbosity
 import Control.Monad (when, unless, filterM, liftM, forM, forM_)
 import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList )
-import Data.List (isPrefixOf, isSuffixOf, nub)
-import Data.Char (isAlpha)
+import Data.List (isPrefixOf, isSuffixOf, stripPrefix, nub)
+import Data.Char (isAlpha, isNumber)
 import qualified Data.Map as M
 import qualified Data.Set as S
+import qualified Distribution.Simple.LocalBuildInfo as LBI
 
 import Control.Applicative ((<$>))
 
+#if CABAL_VERSION_CHECK(1,17,0)
+import Distribution.Simple.Program.Find ( defaultProgramSearchPath )
+onDefaultSearchPath f a b = f a b defaultProgramSearchPath
+libraryConfig lbi = case [clbi | (LBI.CLibName, clbi, _) <- LBI.componentsConfigs lbi] of
+  [clbi] -> Just clbi
+  _ -> Nothing
+#else
+onDefaultSearchPath = id
+libraryConfig = LBI.libraryConfig
+#endif
+
 -- the name of the c2hs pre-compiled header file
 precompFile = "precompchs.bin"
 
@@ -99,10 +111,16 @@
 
 fixLibs :: [FilePath] -> [String] -> [String]
 fixLibs dlls = concatMap $ \ lib ->
-    case filter (("lib" ++ lib) `isPrefixOf`) dlls of
+    case filter (isLib lib) dlls of
                 dll:_ -> [dropExtension dll]
                 _     -> if lib == "z" then [] else [lib]
-
+  where
+    isLib lib dll =
+        case stripPrefix ("lib"++lib) dll of
+            Just ('.':_)                -> True
+            Just ('-':n:_) | isNumber n -> True
+            _                           -> False
+        
 -- The following code is a big copy-and-paste job from the sources of
 -- Cabal 1.8 just to be able to fix a field in the package file. Yuck.
 
@@ -135,8 +153,8 @@
 register :: PackageDescription -> LocalBuildInfo
          -> RegisterFlags -- ^Install in the user's database?; verbose
          -> IO ()
-register pkg@PackageDescription { library       = Just lib  }
-         lbi@LocalBuildInfo     { libraryConfig = Just clbi } regFlags
+register pkg@(library       -> Just lib )
+         lbi@(libraryConfig -> Just clbi) regFlags
   = do
 
     installedPkgInfoRaw <- generateRegistrationInfo
@@ -228,6 +246,7 @@
     = nub $
       ["-I" ++ dir | dir <- PD.includeDirs bi]
    ++ [opt | opt@('-':c:_) <- PD.cppOptions bi ++ PD.ccOptions bi, c `elem` "DIU"]
+   ++ ["-D__GLASGOW_HASKELL__="++show __GLASGOW_HASKELL__]
 
 installCHI :: PackageDescription -- ^information from the .cabal file
         -> LocalBuildInfo -- ^information from the configure step
@@ -283,8 +302,9 @@
                  | PackageIdentifier name (Version (major:minor:_) _) <- cPkgs
                  , let name' = filter isAlpha (display name)
                  , tag <- name'
-                        : [ name' ++ "-" ++ show major ++ "." ++ show digit
-                          | digit <- [0,2..minor] ]
+                        :[ name' ++ "-" ++ show maj ++ "." ++ show d2
+                          | (maj, d2) <- [(maj,   d2) | maj <- [0..(major-1)], d2 <- [0,2..20]]
+                                      ++ [(major, d2) | d2 <- [0,2..minor]] ]
                  ]
 
       signalsOpts :: [ProgArg]
@@ -417,7 +437,7 @@
 checkGtk2hsBuildtools :: [Program] -> IO ()
 checkGtk2hsBuildtools programs = do
   programInfos <- mapM (\ prog -> do
-                         location <- programFindLocation prog normal
+                         location <- onDefaultSearchPath programFindLocation prog normal
                          return (programName prog, location)
                       ) programs
   let printError name = do
diff --git a/SetupWrapper.hs b/SetupWrapper.hs
--- a/SetupWrapper.hs
+++ b/SetupWrapper.hs
@@ -29,6 +29,24 @@
 import Control.Monad
 
 
+-- moreRecentFile is implemented in Distribution.Simple.Utils, but only in
+-- Cabal >= 1.18. For backwards-compatibility, we implement a copy with a new
+-- name here. Some desirable alternate strategies don't work:
+-- * We can't use CPP to check which version of Cabal we're up against because
+--   this is the file that's generating the macros for doing that.
+-- * We can't use the name moreRecentFiles and use
+--   import D.S.U hiding (moreRecentFiles)
+--   because on old GHC's (and according to the Report) hiding a name that
+--   doesn't exist is an error.
+moreRecentFile' :: FilePath -> FilePath -> IO Bool
+moreRecentFile' a b = do
+  exists <- doesFileExist b
+  if not exists
+    then return True
+    else do tb <- getModificationTime b
+            ta <- getModificationTime a
+            return (ta > tb)
+
 setupWrapper :: FilePath -> IO ()
 setupWrapper setupHsFile = do
   args <- getArgs
@@ -91,8 +109,8 @@
     -- Currently this is GHC only. It should really be generalised.
     --
     compileSetupExecutable = do
-      setupHsNewer      <- setupHsFile      `moreRecentFile` setupProgFile
-      cabalVersionNewer <- setupVersionFile `moreRecentFile` setupProgFile
+      setupHsNewer      <- setupHsFile      `moreRecentFile'` setupProgFile
+      cabalVersionNewer <- setupVersionFile `moreRecentFile'` setupProgFile
       let outOfDate = setupHsNewer || cabalVersionNewer
       when outOfDate $ do
         debug verbosity "Setup script is out of date, compiling..."
@@ -144,12 +162,3 @@
                    Nothing Nothing Nothing
       exitCode <- waitForProcess process
       unless (exitCode == ExitSuccess) $ exitWith exitCode
-
-moreRecentFile :: FilePath -> FilePath -> IO Bool
-moreRecentFile a b = do
-  exists <- doesFileExist b
-  if not exists
-    then return True
-    else do tb <- getModificationTime b
-            ta <- getModificationTime a
-            return (ta > tb)
diff --git a/gtk-mac-integration.cabal b/gtk-mac-integration.cabal
--- a/gtk-mac-integration.cabal
+++ b/gtk-mac-integration.cabal
@@ -1,12 +1,12 @@
 Name:           gtk-mac-integration
-Version:        0.2.0.0
+Version:        0.2.0.4
 License:        LGPL-2.1
 License-file:   COPYING
 Copyright:      (c) 2001-2010 The Gtk2Hs Team
 Author:         Duncan Coutts, Peter Gavin, Axel Simon, Hamish Mackenzie
 Maintainer:     gtk2hs-users@sourceforge.net
 Build-Type:     Custom
-Cabal-Version:  >= 1.6.0
+Cabal-Version:  >= 1.8.0
 Stability:      provisional
 homepage:       http://www.haskell.org/gtk2hs/
 bug-reports:    http://hackage.haskell.org/trac/gtk2hs/
@@ -34,15 +34,15 @@
 x-Types-Hierarchy:  hierarchy.list
 
 Source-Repository head
-  type:         darcs
-  location:     http://code.haskell.org/gtk-mac-integration/
+  type:         git
+  location:     https://github.com/gtk2hs/ige-mac-integration
 
 Library
         build-depends:  base >= 4 && < 5, array, containers, mtl,
-                        glib  >= 0.11 && < 0.13,
-                        gtk   >= 0.11 && < 0.13
+                        glib  >=0.12.5.0 && <0.13,
+                        gtk   >=0.12.5.0 && <0.13
 
-        build-tools:    gtk2hsC2hs >= 0.13.5,
+        build-tools:    gtk2hsC2hs >= 0.13.9,
                         gtk2hsHookGenerator, gtk2hsTypeGen
 
         exposed-modules:
@@ -61,5 +61,5 @@
         x-Signals-Types: marshal.list
 
         x-c2hs-Header:  hs-gtk-mac-integration.h
-        pkgconfig-depends: gtk-mac-integration >= 2.0.0
+        pkgconfig-depends: gtk-mac-integration >=2.0.0
 
