forked from jgoerzen/missingpy
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copied Setup.hs from HDBC-postgresql
- Loading branch information
Showing
2 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,40 @@ | ||
#!/usr/bin/env runhugs | ||
arch-tag: Main setup script | ||
#!/usr/bin/env runhaskell | ||
|
||
> import Distribution.Simple | ||
\begin{code} | ||
import Distribution.PackageDescription | ||
import Distribution.Simple | ||
import Distribution.Simple.LocalBuildInfo | ||
import Distribution.Simple.Program | ||
import qualified Distribution.Verbosity as Verbosity | ||
|
||
> main = defaultMain | ||
main = defaultMainWithHooks defaultUserHooks { | ||
hookedPrograms = [pgConfigProgram], | ||
postConf=configure | ||
} | ||
|
||
pgConfigProgram = (simpleProgram "pg_config") { | ||
programFindVersion = findProgramVersion "--version" $ \str -> | ||
-- Invoking "pg_config --version" gives a string like "PostgreSQL 8.0.13" | ||
case words str of | ||
(_:ver:_) -> ver | ||
_ -> "" | ||
} | ||
|
||
configure _ _ _ lbi = do | ||
mb_bi <- pgConfigBuildInfo Verbosity.normal lbi | ||
writeHookedBuildInfo "HDBC-postgresql.buildinfo" (mb_bi,[]) | ||
\end{code} | ||
|
||
Populate BuildInfo using pg_config tool. | ||
\begin{code} | ||
pgConfigBuildInfo verbosity lbi = do | ||
(pgConfigProg, _) <- requireProgram verbosity pgConfigProgram | ||
(orLaterVersion $ Version [8] []) (withPrograms lbi) | ||
let pg_config = rawSystemProgramStdout verbosity pgConfigProg | ||
libDir <- pg_config ["--libdir"] | ||
incDir <- pg_config ["--includedir"] | ||
return $ Just emptyBuildInfo { | ||
extraLibDirs = lines libDir, | ||
includeDirs = lines incDir | ||
} | ||
\end{code} |