-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.113 2003/02/21 13:26:58 simonpj Exp $
+-- $Id: DriverFlags.hs,v 1.124 2003/09/10 16:44:05 simonmar Exp $
--
-- Driver flags
--
findArg spec arg
= case [ (remove_spaces rest, k)
| (pat,k) <- spec,
- Just rest <- [my_prefix_match pat arg],
+ Just rest <- [maybePrefixMatch pat arg],
arg_ok k rest arg ]
of
[] -> Nothing
, ( "-help" , NoArg showGhcUsage)
, ( "-print-libdir" , NoArg (do getTopDir >>= putStrLn
exitWith ExitSuccess))
- , ( "-version" , NoArg (do putStrLn (cProjectName
- ++ ", version " ++ cProjectVersion)
- exitWith ExitSuccess))
+ , ( "V" , NoArg showVersion)
+ , ( "-version" , NoArg showVersion)
, ( "-numeric-version", NoArg (do putStrLn cProjectVersion
exitWith ExitSuccess))
, ( "-make" , PassFlag (setMode DoMake))
, ( "-interactive" , PassFlag (setMode DoInteractive))
, ( "-mk-dll" , PassFlag (setMode DoMkDLL))
+ , ( "e" , HasArg (\s -> setMode (DoEval s) "-e"))
-- -fno-code says to stop after Hsc but don't generate any code.
, ( "fno-code" , PassFlag (\f -> do setMode (StopBefore HCc) f
------- 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) )
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"
) )
#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_TARGET_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) )
, ( "fvia-C", NoArg (setLang HscC) )
, ( "filx", NoArg (setLang HscILX) )
+ , ( "fglasgow-exts", NoArg (mapM_ setDynFlag glasgowExtsFlags) )
+ , ( "fno-glasgow-exts", NoArg (mapM_ unSetDynFlag glasgowExtsFlags) )
+
-- "active negatives"
, ( "fno-implicit-prelude", NoArg (setDynFlag Opt_NoImplicitPrelude) )
, ( "fno-monomorphism-restriction",
( "warn-unused-imports", Opt_WarnUnusedImports ),
( "warn-unused-matches", Opt_WarnUnusedMatches ),
( "warn-deprecations", Opt_WarnDeprecations ),
- ( "glasgow-exts", Opt_GlasgowExts ),
( "fi", Opt_FFI ), -- support `-ffi'...
( "ffi", Opt_FFI ), -- ...and also `-fffi'
( "with", Opt_With ), -- with keyword
+ ( "arrows", Opt_Arrows ), -- arrow syntax
( "parr", Opt_PArr ),
+ ( "th", Opt_TH ),
+ ( "implicit-params", Opt_ImplicitParams ),
( "allow-overlapping-instances", Opt_AllowOverlappingInstances ),
( "allow-undecidable-instances", Opt_AllowUndecidableInstances ),
( "allow-incoherent-instances", Opt_AllowIncoherentInstances ),
( "generics", Opt_Generics )
]
+glasgowExtsFlags = [ Opt_GlasgowExts, Opt_FFI, Opt_TH, Opt_ImplicitParams ]
+
isFFlag f = f `elem` (map fst fFlags)
getFFlag f = fromJust (lookup f fFlags)
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
| prefixMatch "ia64" cTARGETPLATFORM
= return ( [], ["-fomit-frame-pointer", "-G0"] )
+ | prefixMatch "x86_64" cTARGETPLATFORM
+ = return ( [], ["-fomit-frame-pointer"] )
+
| prefixMatch "mips" cTARGETPLATFORM
= return ( ["-static"], [] )
| otherwise = throwDyn (UsageError "can't parse verbosity flag (-v<n>)")
addCmdlineHCInclude a = updDynFlags (\s -> s{cmdlineHcIncludes = a : cmdlineHcIncludes s})
+
+showVersion :: IO ()
+showVersion = do
+ putStrLn (cProjectName ++ ", version " ++ cProjectVersion)
+ exitWith ExitSuccess