+ -- Read the package config(s), and process the package-related
+ -- command-line flags
+ dflags <- initPackages dflags2
+
+ 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 = isSourceFilename 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
+
+ -- Note: have v_Ld_inputs maintain the order in which 'objs' occurred on
+ -- the command-line.
+ mapM_ (add v_Ld_inputs) (reverse objs)
+
+ ---------------- Display banners and configuration -----------
+ showBanners mode dflags static_opts
+
+ ---------------- Final sanity checking -----------
+ checkOptions mode srcs objs
+
+ ---------------- Do the business -----------
+
+ -- Always link in the haskell98 package for static linking. Other
+ -- packages have to be specified via the -package flag.
+ let link_pkgs
+ | Just h98_id <- haskell98PackageId (pkgState dflags) = [h98_id]
+ | otherwise = []
+
+ case mode of
+ DoMake -> doMake dflags srcs
+
+ DoMkDependHS -> do { beginMkDependHS ;
+ compileFiles mode dflags srcs;
+ endMkDependHS dflags }
+ StopBefore p -> do { compileFiles mode dflags srcs; return () }
+ DoMkDLL -> do { o_files <- compileFiles mode dflags srcs;
+ doMkDLL dflags o_files link_pkgs }
+ DoLink -> do { o_files <- compileFiles mode dflags srcs;
+ omit_linking <- readIORef v_NoLink;
+ when (not omit_linking)
+ (staticLink dflags o_files link_pkgs) }