aboutsummaryrefslogtreecommitdiffhomepage
path: root/Setup.hs
diff options
context:
space:
mode:
authorGravatar Ian Lynagh <igloo@earth.li>2007-04-06 15:37:56 +0000
committerGravatar Ian Lynagh <igloo@earth.li>2007-04-06 15:37:56 +0000
commit8c291e5006db9e9a42ee27fbbcfca044fb05bfae (patch)
treecfaad25cda0056cc6bf6520e53dbf5a0e774819a /Setup.hs
parentc5b205781e3774ccd467898e2253701725d58434 (diff)
parse (but don't pass on) options for ./configure
Diffstat (limited to 'Setup.hs')
-rw-r--r--Setup.hs23
1 files changed, 15 insertions, 8 deletions
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