-filter_modules_hook :: Hook a -> Hook a
-filter_modules_hook f pd lbi uhs x
- = let build_filter = case compilerFlavor $ compiler lbi of
- GHC -> forGHCBuild
- _ -> isPortableBuild
- lib' = case library pd of
- Just lib ->
- let ems = filter build_filter (exposedModules lib)
- in lib { exposedModules = ems }
- Nothing -> error "Expected a library"
- pd' = pd { library = Just lib' }
- in f pd' lbi uhs x
-
-isPortableBuild :: String -> Bool
-isPortableBuild s
- | "GHC" `isPrefixOf` s = False
- | "Data.Generics" `isPrefixOf` s = False
- | otherwise = s `notElem` ["Foreign.Concurrent", "System.Timeout"]
-
-forGHCBuild :: String -> Bool
-forGHCBuild = ("GHC.Prim" /=)
-
-add_extra_deps :: ConfHook -> ConfHook
-add_extra_deps f pd cf
- = do lbi <- f pd cf
- case compilerFlavor (compiler lbi) of
- GHC ->
- do -- Euch. We should just add the right thing to the lbi
- -- ourselves rather than rerunning configure.
- let pd' = pd { buildDepends = Dependency "rts" AnyVersion
- : buildDepends pd }
- f pd' cf
- _ ->
- return lbi
+-- Replace a file only if the new version is different from the old.
+-- This prevents make from doing unnecessary work after we run 'setup makefile'
+maybeUpdateFile :: FilePath -> FilePath -> IO ()
+maybeUpdateFile source target = do
+ r <- rawSystem "cmp" ["-s" {-quiet-}, source, target]
+ case r of
+ ExitSuccess -> removeFile source
+ ExitFailure _ -> do try (removeFile target); renameFile source target