Skip to content

Commit

Permalink
Retrieve the ghc lib dir at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanphilippe.bernardy@gmail.com committed Mar 1, 2007
1 parent c08458d commit d60973d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gtk:
cd gtk && @runhaskell Setup.hs build cd gtk && @runhaskell Setup.hs build


build: build:
@runhaskell Setup.hs build @runhaskell Setup.hs --with-ghc=ghc build


config: config:
@runhaskell Setup.hs configure @runhaskell Setup.hs configure
Expand Down
30 changes: 30 additions & 0 deletions Setup.hs
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"

0 comments on commit d60973d

Please sign in to comment.