+-- Turn the -B<dir> option to gcc into the GCC_EXEC_PREFIX env var, to
+-- workaround a bug in MinGW gcc on Windows Vista, see bug #1110.
+getGccEnv :: [Option] -> IO ([Option], Maybe [(String,String)])
+getGccEnv opts =
+#if __GLASGOW_HASKELL__ < 603
+ return (opts,Nothing)
+#else
+ if null b_dirs
+ then return (opts,Nothing)
+ else do env <- getEnvironment
+ return (rest, Just (("GCC_EXEC_PREFIX", head b_dirs) : env))
+ where
+ (b_dirs, rest) = partitionWith get_b_opt opts
+
+ get_b_opt (Option ('-':'B':dir)) = Left dir
+ get_b_opt other = Right other
+#endif
+