-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.112 2003/02/07 09:39:02 simonpj Exp $
+-- $Id: DriverFlags.hs,v 1.117 2003/06/24 07:58:20 simonpj Exp $
--
-- Driver 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) )
#endif
------ HsCpp opts ---------------------------------------------------
- -- With a C compiler whose system() doesn't use a UNIX shell (i.e.
- -- mingwin gcc), -D and -U args must *not* be quoted, as the quotes
- -- will be interpreted as part of the arguments, and not stripped;
- -- on all other systems, quoting is necessary, to avoid interpretation
- -- of shell metacharacters in the arguments (e.g. green-card's
- -- -DBEGIN_GHC_ONLY='}-' trick).
-#ifndef mingw32_HOST_OS
- , ( "D", Prefix (\s -> addOpt_P ("-D'"++s++"'") ) )
- , ( "U", Prefix (\s -> addOpt_P ("-U'"++s++"'") ) )
-#else
- , ( "D", Prefix (\s -> addOpt_P ("-D"++s) ) )
- , ( "U", Prefix (\s -> addOpt_P ("-U"++s) ) )
-#endif
+ , ( "D", AnySuffix addOpt_P )
+ , ( "U", AnySuffix addOpt_P )
------ Debugging ----------------------------------------------------
, ( "dstg-stats", NoArg (writeIORef v_StgStats True) )
( "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 ),
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