diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,3 +1,11 @@
+{-# LANGUAGE CPP #-}
+
+-- if MIN_VERSION_Cabal is not defined, then most likely we have old
+-- GHC or/and old cabal-install in use.
+#ifndef MIN_VERSION_Cabal
+#define MIN_VERSION_Cabal(x,y,z) 0
+#endif
+
 import Distribution.Simple
 import Distribution.Simple.Setup
 import Distribution.PackageDescription
@@ -26,7 +34,11 @@
   where
     defaultPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
     defaultPostConf args flags pkgdescr lbi = do
+#if MIN_VERSION_Cabal(2,3,0)
+      libdir_ <- getDbProgramOutput (fromFlag (configVerbosity flags))
+#else
       libdir_ <- rawSystemProgramStdoutConf (fromFlag (configVerbosity flags))
+#endif
                      ghcProgram (withPrograms lbi) ["--print-libdir"]
       let libdir = reverse $ dropWhile isSpace $ reverse libdir_
 
diff --git a/ghc-paths.cabal b/ghc-paths.cabal
--- a/ghc-paths.cabal
+++ b/ghc-paths.cabal
@@ -1,5 +1,5 @@
 name: ghc-paths
-version: 0.1.0.9
+version: 0.1.0.12
 license: BSD3
 license-file: LICENSE
 copyright: (c) Simon Marlow
@@ -11,6 +11,9 @@
 category: Development
 cabal-version: >= 1.6
 build-type: Custom
+
+custom-setup
+        setup-depends: base >= 3 && < 5, Cabal >= 1.6 && <3.1, directory
 
 library
         build-depends: base >= 3 && < 5
