diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,5 +1,9 @@
-#!/usr/bin/env runhaskell
+{-# LANGUAGE CPP #-}
 
+#ifndef MIN_VERSION_Cabal
+#define MIN_VERSION_Cabal(x,y,z) 0
+#endif
+
 import Distribution.Simple
 import Distribution.Simple.Setup
 import Distribution.PackageDescription
@@ -12,9 +16,28 @@
 import Data.Char (isSpace)
 import Data.List (dropWhile,reverse)
 
+#if MIN_VERSION_Cabal(2,0,0)
+import Distribution.Types.UnqualComponentName
+#endif
+
+flag :: String -> FlagName
+#if MIN_VERSION_Cabal(2,0,0)
+flag = mkFlagName
+#else
+flag = FlagName
+#endif
+
+#if MIN_VERSION_Cabal(2,0,0)
+unqualComponentName :: String -> UnqualComponentName
+unqualComponentName = mkUnqualComponentName
+#else
+unqualComponentName :: String -> String
+unqualComponentName = id
+#endif
+
 main = defaultMainWithHooks simpleUserHooks {
   confHook = \pkg flags -> do
-    if lookup (FlagName "use-pkg-config") 
+    if lookup (flag "use-pkg-config")
               (configConfigurationsFlags flags) == Just True
     then do
       confHook simpleUserHooks pkg flags
@@ -24,7 +47,7 @@
 
       return lbi {
         localPkgDescr = updatePackageDescription
-                          (Just bi, [("runtests", bi)]) (localPkgDescr lbi)
+                          (Just bi, [(unqualComponentName "runtests", bi)]) (localPkgDescr lbi)
       }
 }
 
@@ -32,7 +55,7 @@
 psqlBuildInfo lbi = do
   (pgconfigProg, _) <- requireProgram verbosity
                          (simpleProgram "pg_config") (withPrograms lbi)
-  let pgconfig = rawSystemProgramStdout verbosity pgconfigProg
+  let pgconfig = getProgramOutput verbosity pgconfigProg
 
   incDir <- pgconfig ["--includedir"]
   libDir <- pgconfig ["--libdir"]
diff --git a/postgresql-libpq.cabal b/postgresql-libpq.cabal
--- a/postgresql-libpq.cabal
+++ b/postgresql-libpq.cabal
@@ -1,5 +1,5 @@
 Name:                postgresql-libpq
-Version:             0.9.3.0
+Version:             0.9.3.1
 Synopsis:            low-level binding to libpq
 
 Description:         This is a binding to libpq: the C application
@@ -54,4 +54,4 @@
 source-repository this
   type:     git
   location: http://github.com/lpsmith/postgresql-libpq
-  tag:      v0.9.3.0
+  tag:      v0.9.3.1
