diff --git a/Gtk2HsSetup.hs b/Gtk2HsSetup.hs
--- a/Gtk2HsSetup.hs
+++ b/Gtk2HsSetup.hs
@@ -55,8 +55,8 @@
 import Distribution.Version (Version(..))
 import Distribution.Verbosity
 import Control.Monad (when, unless, filterM, liftM, forM, forM_)
-import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList )
-import Data.List (isPrefixOf, isSuffixOf, stripPrefix, nub)
+import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList, catMaybes )
+import Data.List (isPrefixOf, isSuffixOf, stripPrefix, nub, tails )
 import Data.Char (isAlpha, isNumber)
 import qualified Data.Map as M
 import qualified Data.Set as S
@@ -247,11 +247,24 @@
     = nub $
       ["-I" ++ dir | dir <- PD.includeDirs bi]
    ++ [opt | opt@('-':c:_) <- PD.cppOptions bi ++ PD.ccOptions bi, c `elem` "DIU"]
-   ++ ["-D__GLASGOW_HASKELL__="++show (ghcDefine . versionBranch . compilerVersion $ LBI.compiler lbi)]
+   ++ ["-D__GLASGOW_HASKELL__="++show (ghcDefine . ghcVersion . compilerId $ LBI.compiler lbi)]
  where
   ghcDefine (v1:v2:_) = v1 * 100 + v2
   ghcDefine _ = __GLASGOW_HASKELL__
 
+  ghcVersion :: CompilerId -> [Int]
+-- This version is nicer, but we need to know the Cabal version that includes the new CompilerId
+-- #if CABAL_VERSION_CHECK(1,19,2)
+--   ghcVersion (CompilerId GHC v _) = versionBranch v
+--   ghcVersion (CompilerId _ _ (Just c)) = ghcVersion c
+-- #else
+--   ghcVersion (CompilerId GHC v) = versionBranch v
+-- #endif
+--   ghcVersion _ = []
+-- This version should work fine for now
+  ghcVersion = concat . take 1 . map (read . (++"]") . takeWhile (/=']')) . catMaybes
+               . map (stripPrefix "CompilerId GHC (Version {versionBranch = ") . tails . show
+
 installCHI :: PackageDescription -- ^information from the .cabal file
         -> LocalBuildInfo -- ^information from the configure step
         -> Verbosity -> CopyDest -- ^flags sent to copy or install
@@ -332,6 +345,29 @@
     Just f -> do
       info verb ("Ensuring that callback hooks in "++f++" are up-to-date.")
       genFile signalGenProgram signalsOpts f
+
+  writeFile "gtk2hs_macros.h" $ generateMacros cPkgs
+
+-- Based on Cabal/Distribution/Simple/Build/Macros.hs
+generateMacros :: [PackageId] -> String
+generateMacros cPkgs = concat $
+  "/* DO NOT EDIT: This file is automatically generated by Gtk2HsSetup.hs */\n\n" :
+  [ concat
+    ["/* package ",display pkgid," */\n"
+    ,"#define VERSION_",pkgname," ",show (display version),"\n"
+    ,"#define MIN_VERSION_",pkgname,"(major1,major2,minor) (\\\n"
+    ,"  (major1) <  ",major1," || \\\n"
+    ,"  (major1) == ",major1," && (major2) <  ",major2," || \\\n"
+    ,"  (major1) == ",major1," && (major2) == ",major2," && (minor) <= ",minor,")"
+    ,"\n\n"
+    ]
+  | pkgid@(PackageIdentifier name version) <- cPkgs
+  , let (major1:major2:minor:_) = map show (versionBranch version ++ repeat 0)
+        pkgname = map fixchar (display name)
+  ]
+  where fixchar '-' = '_'
+        fixchar '.' = '_'
+        fixchar c   = c
 
 --FIXME: Cabal should tell us the selected pkg-config package versions in the
 --       LocalBuildInfo or equivalent.
diff --git a/webkitgtk3-javascriptcore.cabal b/webkitgtk3-javascriptcore.cabal
--- a/webkitgtk3-javascriptcore.cabal
+++ b/webkitgtk3-javascriptcore.cabal
@@ -1,5 +1,5 @@
 Name:		webkitgtk3-javascriptcore
-Version:	0.12.5.0
+Version:	0.12.5.1
 Synopsis:       JavaScriptCore FFI from webkitgtk
 Description: 	FFI for JavaScriptCore module from webkitgtk
 License: 	BSD3
@@ -58,4 +58,4 @@
                       -- /usr/lib/x86_64-linux-gnu/glib-2.0/include
         x-c2hs-Header:  hsjscore.h
         pkgconfig-depends: webkitgtk-3.0 >=1.1.15
-        build-depends:     gtk3 >=0.12.5.0 && <0.13, webkitgtk3 >= 0.12.5
+        build-depends:     gtk3 >=0.12.5.4 && <0.13, webkitgtk3 >= 0.12.5
