diff --git a/Setup.hs b/Setup.hs index 362b40c..ec18088 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,2 +1,16 @@ import Distribution.Simple -main = defaultMainWithHooks defaultUserHooks +import Distribution.Setup ( ConfigFlags (..) ) +import System.Directory ( findExecutable ) + +main = defaultMainWithHooks (defaultUserHooks { postConf = defaultPostConf }) + where defaultPostConf args flags lbi + = do args' <- fmap (args++) (configToArgs flags) + (postConf defaultUserHooks) args' flags lbi + +configToArgs :: ConfigFlags -> IO [String] +configToArgs (ConfigFlags { configHcPath = Just hcPath }) + = do exec <- findExecutable hcPath + case exec of + Just realPath -> return ["--with-ghc="++realPath] + Nothing -> return ["--with-ghc="++hcPath] +configToArgs _ = return []