[project @ 2002-03-12 10:41:48 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverPipeline.hs
index 345c513..fb98729 100644 (file)
@@ -45,7 +45,9 @@ import Config
 import Panic
 import Util
 
+#ifdef GHCI
 import Time            ( getClockTime )
+#endif
 import Directory
 import System
 import IOExts
@@ -56,7 +58,6 @@ import Monad
 import Maybe
 
 import PackedString
-import MatchPS
 
 -----------------------------------------------------------------------------
 -- genPipeline
@@ -438,17 +439,19 @@ run_phase MkDependHS basename suff input_fn output_fn
       hdl <- readIORef v_Dep_tmp_hdl
 
        -- std dependency of the object(s) on the source file
-      hPutStrLn hdl (unwords objs ++ " : " ++ basename ++ '.':suff)
+      hPutStrLn hdl (unwords (map escapeSpaces objs) ++ " : " ++
+                    escapeSpaces (basename ++ '.':suff))
 
       let genDep (dep, False {- not an hi file -}) = 
-            hPutStrLn hdl (unwords objs ++ " : " ++ dep)
+            hPutStrLn hdl (unwords (map escapeSpaces objs) ++ " : " ++
+                           escapeSpaces dep)
           genDep (dep, True  {- is an hi file -}) = do
             hisuf <- readIORef v_Hi_suf
             let dep_base = remove_suffix '.' dep
                 deps = (dep_base ++ hisuf)
                        : map (\suf -> dep_base ++ suf ++ '_':hisuf) extra_suffixes
                  -- length objs should be == length deps
-            sequence_ (zipWith (\o d -> hPutStrLn hdl (o ++ " : " ++ d)) objs deps)
+            sequence_ (zipWith (\o d -> hPutStrLn hdl (escapeSpaces o ++ " : " ++ escapeSpaces d)) objs deps)
 
       sequence_ (map genDep [ d | Just d <- deps ])
       return (Just output_fn)
@@ -471,6 +474,7 @@ run_phase MkDependHS basename suff input_fn output_fn
           -- (where .o is $osuf, and the other suffixes come from
           -- the cmdline -s options).
    
+
 -----------------------------------------------------------------------------
 -- Hsc phase
 
@@ -525,10 +529,13 @@ run_phase Hsc basename suff input_fn output_fn
        do_recomp   <- readIORef v_Recomp
        todo        <- readIORef v_GhcMode
        expl_o_file <- readIORef v_Output_file
-        let o_file = 
-               case expl_o_file of
-                 Nothing -> unJust "source_unchanged" (ml_obj_file location)
-                 Just x  -> x
+
+       let o_file -- if the -o option is given and IT IS THE OBJECT FILE FOR
+                  -- THIS COMPILATION, then use that to determine if the 
+                  -- source is unchanged.
+               | Just x <- expl_o_file, todo == StopBefore Ln  =  x
+               | otherwise = unJust "source_unchanged" (ml_obj_file location)
+
        source_unchanged <- 
           if not (do_recomp && ( todo == DoLink || todo == StopBefore Ln ))
             then return False
@@ -711,7 +718,7 @@ run_phase SplitAs basename _suff _input_fn output_fn
 
        odir <- readIORef v_Output_dir
        let real_odir = case odir of
-                               Nothing -> basename
+                               Nothing -> basename ++ "_split"
                                Just d  -> d
 
        let assemble_file n
@@ -910,8 +917,7 @@ doLink o_files = do
                      ++ pkg_extra_ld_opts
                      ++ extra_ld_opts
                      ++ if static && not no_hs_main then
-                           [ "-u", prefixUnderscore "PrelMain_mainIO_closure",
-                             "-u", prefixUnderscore "__stginit_PrelMain"] 
+                           [ "-u", prefixUnderscore "Main_zdmain_closure"] 
                         else []))
 
     -- parallel only: move binary to another dir -- HWL
@@ -980,9 +986,9 @@ doMkDLL o_files = do
         ++ pkg_lib_path_opts
         ++ pkg_lib_opts
         ++ pkg_extra_ld_opts
-         ++ (case findPS (packString (concat extra_ld_opts)) (packString "--def") of
-               Nothing -> [ "--export-all" ]
-              Just _  -> [ "" ])
+         ++ (if "--def" `elem` (concatMap words extra_ld_opts)
+              then [ "" ]
+               else [ "--export-all" ])
         ++ extra_ld_opts
        ))
 
@@ -1115,7 +1121,6 @@ compile ghci_mode summary source_unchanged have_object
 
       HscRecomp pcs details iface
        stub_h_exists stub_c_exists maybe_interpreted_code -> do
-          
           let 
           maybe_stub_o <- compileStub dyn_flags' stub_c_exists
           let stub_unlinked = case maybe_stub_o of