-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retrieve the ghc lib dir at build time
- Loading branch information
jeanphilippe.bernardy@gmail.com
committed
Mar 1, 2007
1 parent
c08458d
commit d60973d
Showing
2 changed files
with
31 additions
and
1 deletion.
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,33 @@ | |||
#!/usr/bin/env runhaskell | #!/usr/bin/env runhaskell | ||
module Main where | |||
|
|||
import Distribution.Simple | import Distribution.Simple | ||
import Distribution.PackageDescription | |||
import System.Info | |||
import System.Process | |||
import Data.List | |||
import System.IO | |||
--import Config | |||
|
|||
main :: IO () | |||
main = defaultMainWithHooks defaultUserHooks | main = defaultMainWithHooks defaultUserHooks | ||
{ preBuild = setConfigInfo } | |||
|
|||
setConfigInfo args _ | |||
= getLibDir args >>= \libdir -> | |||
return | |||
(Nothing, | |||
[("yi", emptyBuildInfo | |||
{ options = [(GHC,[mkOpt ("GHC_LIBDIR",show libdir)])] })]) | |||
where mkOpt (name,def) = "-D"++name++"="++def | |||
|
|||
getLibDir [arg] | |||
| "--with-ghc" `isPrefixOf` arg | |||
= do (_, out, _, pid) <- runInteractiveProcess ghcPath ["--print-libdir"] | |||
Nothing Nothing | |||
libDir <- hGetLine out | |||
waitForProcess pid | |||
return libDir | |||
where ghcPath = drop 1 (dropWhile (/='=') arg) | |||
|
|||
getLibDir _ = error "failed to extract ghc path from command line" |