[project @ 2001-02-28 11:48:34 by simonpj]
[ghc-hetmet.git] / ghc / compiler / main / Main.hs
index 6e14950..bfd2087 100644 (file)
@@ -1,6 +1,6 @@
 {-# OPTIONS -fno-warn-incomplete-patterns #-}
 -----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.52 2001/02/13 17:13:39 sewardj Exp $
+-- $Id: Main.hs,v 1.57 2001/02/28 11:44:39 simonpj Exp $
 --
 -- GHC Driver program
 --
@@ -18,6 +18,7 @@ module Main (main) where
 
 #ifdef GHCI
 import InteractiveUI
+import Char            ( toLower )
 #endif
 
 #ifndef mingw32_TARGET_OS
@@ -32,7 +33,7 @@ import DriverFlags
 import DriverMkDepend
 import DriverUtil
 import Panic
-import DriverPhases    ( Phase(..), haskellish_file )
+import DriverPhases    ( Phase(..), haskellish_file, objish_file )
 import CmdLineOpts
 import TmpFiles
 import Finder          ( initFinder )
@@ -49,7 +50,6 @@ import Exception
 import IO
 import Monad
 import List
-import Char            ( toLower )
 import System
 import Maybe
 
@@ -67,7 +67,6 @@ import Maybe
 -- new mkdependHS doesn't support all the options that the old one did (-X et al.)
 -- time commands when run with -v
 -- split marker
--- mkDLL
 -- java generation
 -- user ways
 -- Win32 support: proper signal handling
@@ -196,15 +195,6 @@ main =
    static_opts <- buildStaticHscOpts
    writeIORef v_Static_hsc_opts static_opts
 
-       -- warnings
-   warn_level <- readIORef v_Warning_opt
-
-   let warn_opts =  case warn_level of
-                       W_default -> standardWarnings
-                       W_        -> minusWOpts
-                       W_all     -> minusWallOpts
-                       W_not     -> []
-
    -- build the default DynFlags (these may be adjusted on a per
    -- module basis by OPTIONS pragmas and settings in the interpreter).
 
@@ -237,8 +227,7 @@ main =
                        }
 
        -- the rest of the arguments are "dynamic"
-   srcs <- processArgs dynamic_flags (way_non_static ++ 
-                                       non_static ++ warn_opts) []
+   srcs <- processArgs dynamic_flags (way_non_static ++ non_static) []
        -- save the "initial DynFlags" away
    init_dyn_flags <- readIORef v_DynFlags
    writeIORef v_InitDynFlags init_dyn_flags
@@ -320,8 +309,11 @@ setTopDir args = do
   return others
 
 beginMake :: [String] -> IO ()
-beginMake mods
-  = do case mods of
+beginMake fileish_args
+  = do let (objs, mods) = partition objish_file fileish_args
+       mapM (add v_Ld_inputs) objs
+
+       case mods of
         []    -> throwDyn (UsageError "no input files")
         [mod] -> do state <- cmInit Batch
                     cmLoadModule state mod
@@ -334,18 +326,15 @@ beginInteractive :: [String] -> IO ()
 beginInteractive = throwDyn (OtherError "not built for interactive use")
 #else
 beginInteractive fileish_args
-  = do let is_libraryish nm
-              = let nmr = map toLower (reverse nm)
-                    in take 2 nmr == "o." ||
-                       take 3 nmr == "os." ||
-                       take 4 nmr == "lld."
-           libs = filter is_libraryish fileish_args
-           mods = filter (not.is_libraryish) fileish_args
-           mod = case mods of
-                   []    -> Nothing
-                   [mod] -> Just mod
-                   _     -> throwDyn (UsageError 
-                                       "only one module allowed with --interactive")
+  = do minus_ls <- readIORef v_Cmdline_libraries
+
+       let (objs, mods) = partition objish_file fileish_args
+          libs = map Left objs ++ map Right minus_ls
+
        state <- cmInit Interactive
-       interactiveUI state mod libs
+       case mods of
+         []    -> interactiveUI state Nothing    libs
+         [mod] -> interactiveUI state (Just mod) libs
+         _     -> throwDyn (UsageError 
+                             "only one module allowed with --interactive")
 #endif