From 8c291e5006db9e9a42ee27fbbcfca044fb05bfae Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 6 Apr 2007 15:37:56 +0000 Subject: parse (but don't pass on) options for ./configure --- Setup.hs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'Setup.hs') diff --git a/Setup.hs b/Setup.hs index 9fff242..cf84de0 100644 --- a/Setup.hs +++ b/Setup.hs @@ -12,21 +12,28 @@ import System.Environment main :: IO () main = do args <- getArgs let (ghcArgs, args') = extractGhcArgs args - let hooks = defaultUserHooks { + (_, args'') = extractConfigureArgs args' + hooks = defaultUserHooks { buildHook = add_ghc_options ghcArgs $ buildHook defaultUserHooks } - withArgs args' $ defaultMainWithHooks hooks + withArgs args'' $ defaultMainWithHooks hooks extractGhcArgs :: [String] -> ([String], [String]) -extractGhcArgs args +extractGhcArgs = extractPrefixArgs "--ghc-option=" + +extractConfigureArgs :: [String] -> ([String], [String]) +extractConfigureArgs = extractPrefixArgs "--configure-option=" + +extractPrefixArgs :: String -> [String] -> ([String], [String]) +extractPrefixArgs prefix args = let f [] = ([], []) f (x:xs) = case f xs of - (ghcArgs, otherArgs) -> - case removePrefix "--ghc-option=" x of - Just ghcArg -> - (ghcArg:ghcArgs, otherArgs) + (wantedArgs, otherArgs) -> + case removePrefix prefix x of + Just wantedArg -> + (wantedArg:wantedArgs, otherArgs) Nothing -> - (ghcArgs, x:otherArgs) + (wantedArgs, x:otherArgs) in f args removePrefix :: String -> String -> Maybe String -- cgit v1.2.3