[project @ 2003-08-11 08:53:39 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverFlags.hs
index 22e416a..075d9bf 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.115 2003/05/27 12:40:19 simonmar Exp $
+-- $Id: DriverFlags.hs,v 1.119 2003/08/11 08:53:39 simonmar Exp $
 --
 -- Driver flags
 --
@@ -225,6 +225,7 @@ static_flags =
        ------- Miscellaneous -----------------------------------------------
   ,  ( "no-link-chk"    , NoArg (return ()) ) -- ignored for backwards compat
   ,  ( "no-hs-main"     , NoArg (writeIORef v_NoHsMain True) )
+  ,  ( "main-is"       , SepArg setMainIs )
 
        ------- Output Redirection ------------------------------------------
   ,  ( "odir"          , HasArg (writeIORef v_Output_dir  . Just) )
@@ -251,7 +252,7 @@ static_flags =
                                    then do writeIORef v_Split_object_files True
                                            add v_Opt_C "-fglobalise-toplev-names"
                                    else hPutStrLn stderr
-                                           "warning: don't know how to  split \
+                                           "warning: don't know how to  split \ 
                                            \object files on this architecture"
                                ) )
 
@@ -454,6 +455,7 @@ fFlags = [
   ( "fi",                              Opt_FFI ),  -- support `-ffi'...
   ( "ffi",                             Opt_FFI ),  -- ...and also `-fffi'
   ( "with",                            Opt_With ), -- with keyword
+  ( "arrows",                          Opt_Arrows ), -- arrow syntax
   ( "parr",                            Opt_PArr ),
   ( "allow-overlapping-instances",     Opt_AllowOverlappingInstances ),
   ( "allow-undecidable-instances",     Opt_AllowUndecidableInstances ),
@@ -520,6 +522,21 @@ buildStaticHscOpts = do
 
   return ( static : filtered_opts )
 
+setMainIs :: String -> IO ()
+setMainIs arg
+  | not (null main_mod)                -- The arg looked like "Foo.baz"
+  = do { writeIORef v_MainFunIs (Just main_fn) ;
+        writeIORef v_MainModIs (Just main_mod) }
+
+  | isUpper (head main_fn)     -- The arg looked like "Foo"
+  = writeIORef v_MainModIs (Just main_fn)
+  
+  | otherwise                  -- The arg looked like "baz"
+  = writeIORef v_MainFunIs (Just main_fn)
+  where
+    (main_mod, main_fn) = split_longest_prefix arg (== '.')
+  
+
 -----------------------------------------------------------------------------
 -- Via-C compilation stuff