- -- complain about any unknown flags
- mapM unknownFlagErr [ f | f@('-':_) <- srcs ]
-
- verb <- dynFlag verbosity
-
- -- Show the GHCi banner
-# ifdef GHCI
- when (mode == DoInteractive && verb >= 1) $
- hPutStrLn stdout ghciWelcomeMsg
-# endif
-
- -- Display details of the configuration in verbose mode
- when (verb >= 2)
- (do hPutStr stderr "Glasgow Haskell Compiler, Version "
- hPutStr stderr cProjectVersion
- hPutStr stderr ", for Haskell 98, compiled by GHC version "
- hPutStrLn stderr cBooterVersion)
-
- when (verb >= 2)
- (hPutStrLn stderr ("Using package config file: " ++ conf_file))
+ let
+ {-
+ We split out the object files (.o, .dll) and add them
+ to v_Ld_inputs for use by the linker.
+
+ The following things should be considered compilation manager inputs:
+
+ - haskell source files (strings ending in .hs, .lhs or other
+ haskellish extension),
+
+ - module names (not forgetting hierarchical module names),
+
+ - and finally we consider everything not containing a '.' to be
+ a comp manager input, as shorthand for a .hs or .lhs filename.
+
+ Everything else is considered to be a linker object, and passed
+ straight through to the linker.
+ -}
+ looks_like_an_input m = isSourceFile m
+ || looksLikeModuleName m
+ || '.' `notElem` m
+
+ -- To simplify the handling of filepaths, we normalise all filepaths right
+ -- away - e.g., for win32 platforms, backslashes are converted
+ -- into forward slashes.
+ normal_fileish_paths = map normalisePath fileish_args
+ (srcs, objs) = partition looks_like_an_input normal_fileish_paths
+
+ mapM_ (add v_Ld_inputs) objs
+
+ ---------------- Display banners and configuration -----------
+ showBanners mode conf_file static_opts
+
+ ---------------- Final sanity checking -----------
+ checkOptions mode srcs objs
+
+ ---------------- Do the business -----------
+ case mode of
+ DoMake -> doMake srcs
+
+ DoMkDependHS -> do { beginMkDependHS ;
+ compileFiles mode srcs;
+ endMkDependHS }
+ StopBefore p -> do { compileFiles mode srcs; return () }
+ DoMkDLL -> do { o_files <- compileFiles mode srcs;
+ doMkDLL o_files }
+ DoLink -> do { o_files <- compileFiles mode srcs;
+ omit_linking <- readIORef v_NoLink;
+ when (not omit_linking)
+ (staticLink o_files
+ [basePackage, haskell98Package]) }
+ -- We always link in the base package in
+ -- one-shot linking. Any other packages
+ -- required must be given using -package
+ -- options on the command-line.