Skip to content

Commit

Permalink
Compat with >=Cabal-2.0
Browse files Browse the repository at this point in the history
As we need the CPP extension I needed to remove the shebang. 

Also switched to `getProgramOutput` as these are long deprecated and `getProgramOutput` exists in >=Cabal-1.8.
  • Loading branch information
alexbiehl committed May 10, 2017
1 parent f57354e commit f59ed78
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Setup.hs
@@ -1,4 +1,8 @@
#!/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
Expand All @@ -12,9 +16,28 @@ import Distribution.Verbosity
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
Expand All @@ -24,15 +47,15 @@ main = defaultMainWithHooks simpleUserHooks {

return lbi {
localPkgDescr = updatePackageDescription
(Just bi, [("runtests", bi)]) (localPkgDescr lbi)
(Just bi, [(unqualComponentName "runtests", bi)]) (localPkgDescr lbi)
}
}

psqlBuildInfo :: LocalBuildInfo -> IO BuildInfo
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"]
Expand Down

0 comments on commit f59ed78

Please sign in to comment.