[project @ 2000-11-21 14:31:58 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / Main.hs
index e9c22d9..dbc9cec 100644 (file)
@@ -1,6 +1,6 @@
 {-# OPTIONS -W -fno-warn-incomplete-patterns #-}
 -----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.25 2000/11/17 16:53:27 simonmar Exp $
+-- $Id: Main.hs,v 1.29 2000/11/21 14:35:52 simonmar Exp $
 --
 -- GHC Driver program
 --
@@ -98,8 +98,8 @@ main =
    -- make sure we clean up after ourselves
    later (do  forget_it <- readIORef v_Keep_tmp_files
              unless forget_it $ do
-             verb <- readIORef v_Verbose
-             cleanTempFiles verb
+             verb <- dynFlag verbosity
+             cleanTempFiles (verb >= 2)
      ) $ do
        -- exceptions will be blocked while we clean the temporary files,
        -- so there shouldn't be any difficulty if we receive further
@@ -114,9 +114,6 @@ main =
    installHandler sigINT  sig_handler Nothing
 #endif
 
-   pgm    <- getProgName
-   writeIORef v_Prog_name pgm
-
    argv   <- getArgs
 
        -- grab any -B options from the command line first
@@ -204,6 +201,12 @@ main =
                   hscLang  = lang,
                  -- leave out hscOutName for now
                   hscOutName = panic "Main.main:hscOutName not set",
+
+                 verbosity = case mode of
+                               DoInteractive -> 1
+                               DoMake        -> 1
+                               _other        -> 0,
+
                  flags = [] }
 
        -- the rest of the arguments are "dynamic"
@@ -216,15 +219,22 @@ main =
        -- complain about any unknown flags
    mapM unknownFlagErr [ f | f@('-':_) <- srcs ]
 
-       -- get the -v flag
-   verb <- readIORef v_Verbose
+       -- save the flag state, because this could be modified by OPTIONS 
+       -- pragmas during the compilation, and we'll need to restore it
+       -- before starting the next compilation.
+   saved_driver_state <- readIORef v_Driver_state
+   writeIORef v_InitDriverState saved_driver_state
 
-   when verb (do hPutStr stderr "Glasgow Haskell Compiler, Version "
-                hPutStr stderr cProjectVersion
-                hPutStr stderr ", for Haskell 98, compiled by GHC version "
-                hPutStrLn stderr cBooterVersion)
+   verb <- dynFlag verbosity
 
-   when verb (hPutStrLn stderr ("Using package config file: " ++ conf_file))
+   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))
 
        -- initialise the finder
    initFinder pkg_details
@@ -250,11 +260,6 @@ main =
 
    if null srcs then throwDyn (UsageError "no input files") else do
 
-       -- save the flag state, because this could be modified by OPTIONS 
-       -- pragmas during the compilation, and we'll need to restore it
-       -- before starting the next compilation.
-   saved_driver_state <- readIORef v_Driver_state
-
    let compileFile (src, phases) = do
          writeIORef v_Driver_state saved_driver_state
          writeIORef v_DynFlags init_dyn_flags
@@ -281,7 +286,7 @@ beginMake pkg_details mods
   = do case mods of
         []    -> throwDyn (UsageError "no input files")
         [mod] -> do state <- cmInit pkg_details Batch
-                    cmLoadModule state (mkModuleName mod)
+                    cmLoadModule state mod
                     return ()
         _     -> throwDyn (UsageError "only one module allowed with --make")
 
@@ -292,7 +297,7 @@ beginInteractive pkg_details mods
   = do state <- cmInit pkg_details Interactive
        case mods of
           []    -> return ()
-          [mod] -> do cmLoadModule state (mkModuleName mod); return ()
+          [mod] -> do cmLoadModule state mod; return ()
           _     -> throwDyn (UsageError 
                                "only one module allowed with --interactive")
        interactiveUI state