Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tag: debian/…
Fetching contributors…

Cannot retrieve contributors at this time

executable file 52 lines (40 sloc) 1.475 kB
#!/usr/bin/env runhaskell
import Distribution.Simple
import Distribution.PackageDescription
import Distribution.Version
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Program
import Distribution.Verbosity
import Data.Char (isSpace)
import Data.List (dropWhile,reverse)
import Control.Monad
main = defaultMainWithHooks simpleUserHooks {
hookedPrograms = [pgconfigProgram],
confHook = \pkg flags -> do
lbi <- confHook defaultUserHooks pkg flags
bi <- psqlBuildInfo lbi
return lbi {
localPkgDescr = updatePackageDescription
(Just bi, [("runtests", bi)]) (localPkgDescr lbi)
pgconfigProgram = (simpleProgram "pgconfig") {
programFindLocation = \verbosity -> do
pgconfig <- findProgramOnPath "pgconfig" verbosity
pg_config <- findProgramOnPath "pg_config" verbosity
return (pgconfig `mplus` pg_config)
psqlBuildInfo :: LocalBuildInfo -> IO BuildInfo
psqlBuildInfo lbi = do
(pgconfigProg, _) <- requireProgram verbosity
pgconfigProgram AnyVersion (withPrograms lbi)
let pgconfig = rawSystemProgramStdout verbosity pgconfigProg
incDir <- pgconfig ["--includedir"]
libDir <- pgconfig ["--libdir"]
return emptyBuildInfo {
extraLibDirs = [strip libDir],
includeDirs = [strip incDir]
verbosity = normal -- honestly, this is a hack
strip x = dropWhile isSpace $ reverse $ dropWhile isSpace $ reverse x
Jump to Line
Something went wrong with that request. Please try again.