+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
+
-----------------------------------------------------------------------------
--
-- Makefile Dependency Generation
import qualified GHC
import GHC ( Session, ModSummary(..) )
import DynFlags
-import Util ( escapeSpaces, splitFilename, joinFileExt )
+import Util
import HscTypes ( HscEnv, IsBootInterface, msObjFilePath, msHsFilePath )
import SysTools ( newTempName )
import qualified SysTools
import Data.List
import CmdLineParser
-#if __GLASGOW_HASKELL__ <= 408
-import Panic ( catchJust, ioErrors )
-#endif
import ErrUtils ( debugTraceMsg, putMsg )
import Data.IORef ( IORef, readIORef, writeIORef )
import Control.Exception
import System.Exit ( ExitCode(..), exitWith )
import System.Directory
+import System.FilePath
import System.IO
import SYSTEM_IO_ERROR ( isEOFError )
import Control.Monad ( when )
-----------------------------
writeDependency :: Handle -> [FilePath] -> FilePath -> IO ()
-- (writeDependency h [t1,t2] dep) writes to handle h the dependency
--- t1 t2 : dep
+-- t1 t2 : dep
writeDependency hdl targets dep
- = hPutStrLn hdl (unwords (map escapeSpaces targets) ++ " : "
- ++ escapeSpaces dep)
+ = hPutStrLn hdl (unwords (map forOutput targets) ++ " : " ++ forOutput dep)
+ where forOutput = escapeSpaces . reslash Forwards . normalise
-----------------------------
insertSuffixes
-- Lots of other things will break first!
insertSuffixes file_name extras
- = file_name : [ basename `joinFileExt` (extra ++ "_" ++ suffix) | extra <- extras ]
+ = file_name : [ basename <.> (extra ++ "_" ++ suffix) | extra <- extras ]
where
- (basename, suffix) = splitFilename file_name
+ (basename, suffix) = case splitExtension file_name of
+ -- Drop the "." from the extension
+ (b, s) -> (b, drop 1 s)
-----------------------------------------------------------------
[ ( "s", SepArg (consIORef v_Dep_suffixes) )
, ( "f", SepArg (writeIORef v_Dep_makefile) )
, ( "w", NoArg (writeIORef v_Dep_warnings False) )
+
, ( "-include-prelude", NoArg (writeIORef v_Dep_include_pkg_deps True) )
+ -- -include-prelude is the old name for -include-pkg-deps, kept around
+ -- for backward compatibility, but undocumented
+
, ( "-include-pkg-deps", NoArg (writeIORef v_Dep_include_pkg_deps True) )
, ( "-exclude-module=", Prefix (consIORef v_Dep_exclude_mods . mkModuleName) )
, ( "x", Prefix (consIORef v_Dep_exclude_mods . mkModuleName) )