[project @ 2005-05-17 12:00:04 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverMkDepend.hs
index 410f5b1..36990cb 100644 (file)
@@ -15,7 +15,7 @@ module DriverMkDepend (
 import qualified GHC
 import GHC             ( Session, ModSummary(..) )
 import DynFlags                ( DynFlags( verbosity, opt_dep ), getOpts )
-import Util            ( escapeSpaces, splitFilename )
+import Util            ( escapeSpaces, splitFilename, joinFileExt )
 import HscTypes                ( HscEnv, IsBootInterface, msObjFilePath, msHsFilePath )
 import Packages                ( PackageIdH(..) )
 import SysTools                ( newTempName )
@@ -27,6 +27,7 @@ import Finder         ( findModule, FindResult(..) )
 import Util             ( global, consIORef )
 import Outputable
 import Panic
+import SrcLoc          ( unLoc )
 import CmdLineParser
 
 import DATA_IOREF      ( IORef, readIORef, writeIORef )
@@ -40,6 +41,7 @@ import Maybe            ( isJust )
 #if __GLASGOW_HASKELL__ <= 408
 import Panic           ( catchJust, ioErrors )
 #endif
+import ErrUtils         ( debugTraceMsg )
 
 -----------------------------------------------------------------
 --
@@ -54,7 +56,7 @@ doMkDependHS session srcs
        ; files <- beginMkDependHS dflags
 
                -- Do the downsweep to find all the modules
-       ; targets <- mapM GHC.guessTarget srcs
+       ; targets <- mapM (\s -> GHC.guessTarget s Nothing) srcs
        ; GHC.setTargets session targets
        ; excl_mods <- readIORef v_Dep_exclude_mods
        ; GHC.depanal session excl_mods
@@ -62,12 +64,10 @@ doMkDependHS session srcs
 
                -- Sort into dependency order
                -- There should be no cycles
-       ; let sorted = GHC.topSortModuleGraph False mod_summaries
+       ; let sorted = GHC.topSortModuleGraph False mod_summaries Nothing
 
                -- Print out the dependencies if wanted
-       ; if verbosity dflags >= 2 then
-               hPutStrLn stderr (showSDoc (text "Module dependencies" $$ ppr sorted))
-         else return ()
+       ; debugTraceMsg dflags 2 (showSDoc (text "Module dependencies" $$ ppr sorted))
                
                -- Prcess them one by one, dumping results into makefile
                -- and complaining about cycles
@@ -200,8 +200,8 @@ processDeps session hdl (AcyclicSCC node)
        ; writeDependency hdl obj_files src_file
 
                -- Emit a dependency for each import
-       ; mapM_ (do_imp True)  (ms_srcimps node)        -- SOURCE imports
-       ; mapM_ (do_imp False) (ms_imps node)           -- regular imports
+       ; mapM_ (do_imp True . unLoc)  (ms_srcimps node)        -- SOURCE imports
+       ; mapM_ (do_imp False . unLoc) (ms_imps node)           -- regular imports
        }
 
 
@@ -256,7 +256,7 @@ insertSuffixes
        -- Lots of other things will break first!
 
 insertSuffixes file_name extras
-  = file_name : [ basename ++ "." ++ extra ++ "_" ++ suffix | extra <- extras ]
+  = file_name : [ basename `joinFileExt` (extra ++ "_" ++ suffix) | extra <- extras ]
   where
     (basename, suffix) = splitFilename file_name