- case mods of
- [] -> throwDyn (UsageError "no input files")
- mod -> do state <- cmInit Batch
- (_, ok, _) <- cmLoadModule state mods
- when (not ok) (exitWith (ExitFailure 1))
- return ()
+ -- Verify that output files point somewhere sensible.
+ verifyOutputFiles
+
+-- -----------------------------------------------------------------------------
+-- Compile files in one-shot mode.
+
+compileFiles :: GhcMode
+ -> DynFlags
+ -> [String] -- Source files
+ -> IO [String] -- Object files
+compileFiles mode dflags srcs = mapM (compileFile mode dflags) srcs
+
+
+doLink :: DynFlags -> Phase -> [FilePath] -> IO ()
+doLink dflags stop_phase o_files
+ | not (isStopLn stop_phase)
+ = return () -- We stopped before the linking phase
+
+ | otherwise
+ = do { ghc_link <- readIORef v_GhcLink
+ ; case ghc_link of
+ NoLink -> return ()
+ StaticLink -> staticLink dflags o_files link_pkgs
+ MkDLL -> doMkDLL dflags o_files link_pkgs
+ }
+ where
+ -- Always link in the haskell98 package for static linking. Other
+ -- packages have to be specified via the -package flag.
+ link_pkgs
+ | ExtPackage h98_id <- haskell98PackageId (pkgState dflags) = [h98_id]
+ | otherwise = []
+
+
+-- ----------------------------------------------------------------------------
+-- Run --make mode
+
+doMake :: DynFlags -> [String] -> IO ()
+doMake dflags [] = throwDyn (UsageError "no input files")
+doMake dflags srcs = do
+ state <- cmInit Batch dflags
+ graph <- cmDepAnal state srcs
+ (_, ok_flag, _) <- cmLoadModules state graph
+ when (failed ok_flag) (exitWith (ExitFailure 1))
+ return ()
+
+-- ---------------------------------------------------------------------------
+-- Various banners and verbosity output.
+
+showBanners :: GhcMode -> DynFlags -> [String] -> IO ()
+showBanners mode dflags static_opts = do
+ let verb = verbosity dflags