-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.127 2003/10/09 11:58:56 simonpj Exp $
--
-- Driver flags
--
--- (c) Simon Marlow 2000
+-- (c) The University of Glasgow 2000-2003
--
-----------------------------------------------------------------------------
addCmdlineHCInclude a = updDynFlags (\s -> s{cmdlineHcIncludes = a : cmdlineHcIncludes s})
+-- -----------------------------------------------------------------------------
+-- Version and usage messages
+
showVersion :: IO ()
showVersion = do
putStrLn (cProjectName ++ ", version " ++ cProjectVersion)
exitWith ExitSuccess
+
+showGhcUsage = do
+ (ghc_usage_path,ghci_usage_path) <- getUsageMsgPaths
+ mode <- readIORef v_GhcMode
+ let usage_path
+ | mode == DoInteractive = ghci_usage_path
+ | otherwise = ghc_usage_path
+ usage <- readFile usage_path
+ dump usage
+ exitWith ExitSuccess
+ where
+ dump "" = return ()
+ dump ('$':'$':s) = hPutStr stderr progName >> dump s
+ dump (c:s) = hPutChar stderr c >> dump s
-----------------------------------------------------------------------------
--
--- (c) The University of Glasgow 2001
+-- (c) The University of Glasgow 2001-2003
--
-- Access to system tools: gcc, cp, rm etc
--
getTopDir, -- IO String -- The value of $libdir
getPackageConfigPath, -- IO String -- Where package.conf is
+ getUsageMsgPaths, -- IO (String,String)
-- Interface to system tools
runUnlit, runCpp, runCc, -- [Option] -> IO ()
system, -- String -> IO ExitCode
-- Misc
- showGhcUsage, -- IO () Shows usage message and exits
getSysMan, -- IO String Parallel system only
Option(..)
import DriverPhases ( isHaskellUserSrcFilename )
import Config
import Outputable
-import Panic ( progName, GhcException(..) )
+import Panic ( GhcException(..) )
import Util ( global, notNull )
import CmdLineOpts ( dynFlag, verbosity )
import DATA_INT
import Monad ( when, unless )
-import System ( ExitCode(..), exitWith, getEnv, system )
+import System ( ExitCode(..), getEnv, system )
import IO ( try, catch,
- openFile, hPutChar, hPutStrLn, hPutStr, hClose, hFlush, IOMode(..),
+ openFile, hPutStrLn, hPutStr, hClose, hFlush, IOMode(..),
stderr )
import Directory ( doesFileExist, removeFile )
import List ( intersperse, partition )
GLOBAL_VAR(v_Pgm_CP, error "pgm_CP", String) -- cp
GLOBAL_VAR(v_Path_package_config, error "path_package_config", String)
-GLOBAL_VAR(v_Path_usage, error "ghc_usage.txt", String)
+GLOBAL_VAR(v_Path_usages, error "ghc_usage.txt", (String,String))
GLOBAL_VAR(v_TopDir, error "TopDir", String) -- -B<dir>
| am_installed = installed "ghc-usage.txt"
| otherwise = inplace cGHC_DRIVER_DIR_REL "ghc-usage.txt"
+ ghci_usage_msg_path
+ | am_installed = installed "ghci-usage.txt"
+ | otherwise = inplace cGHC_DRIVER_DIR_REL "ghci-usage.txt"
+
-- For all systems, unlit, split, mangle are GHC utilities
-- architecture-specific stuff is done when building Config.hs
unlit_path
-- Initialise the global vars
; writeIORef v_Path_package_config pkgconfig_path
- ; writeIORef v_Path_usage ghc_usage_msg_path
+ ; writeIORef v_Path_usages (ghc_usage_msg_path,
+ ghci_usage_msg_path)
; writeIORef v_Pgm_sysman (top_dir ++ "/ghc/rts/parallel/SysMan")
-- Hans: this isn't right in general, but you can
getSysMan = readIORef v_Pgm_sysman
\end{code}
-%************************************************************************
-%* *
-\subsection{GHC Usage message}
-%* *
-%************************************************************************
-
-Show the usage message and exit
-
\begin{code}
-showGhcUsage = do { usage_path <- readIORef v_Path_usage
- ; usage <- readFile usage_path
- ; dump usage
- ; exitWith ExitSuccess }
- where
- dump "" = return ()
- dump ('$':'$':s) = hPutStr stderr progName >> dump s
- dump (c:s) = hPutChar stderr c >> dump s
+getUsageMsgPaths :: IO (FilePath,FilePath)
+ -- the filenames of the usage messages (ghc, ghci)
+getUsageMsgPaths = readIORef v_Path_usages
\end{code}
\begin{code}
slash :: String -> String -> String
-absPath, relPath :: [String] -> String
-
-relPath [] = ""
-relPath xs = foldr1 slash xs
-
-absPath xs = "" `slash` relPath xs
-
slash s1 s2 = s1 ++ ('/' : s2)
\end{code}
--- /dev/null
+Usage:
+
+ ghci [command-line-options-and-input-files]
+
+The kinds of input files that can be given on the command-line
+include:
+
+ - Haskell source files (.hs or .lhs suffix)
+ - Object files (.o suffix, or .obj on Windows)
+ - Dynamic libraries (.so suffix, or .dll on Windows)
+
+In addition, ghci accepts most of the command-line options that plain
+GHC does. Some of the options that are commonly used are:
+
+ -fglasgow-exts Allow Glasgow extensions (unboxed types, etc.)
+
+ -i<dir> Search for imported modules in the directory <dir>.
+
+ -H32m Increase GHC's default heap size to 32m
+
+ -cpp Enable CPP processing of source files
+
+Full details can be found in the User's Guide, an online copy of which
+can be found here:
+
+ http://www.haskell.org/ghc/documentation.html