[project @ 2005-01-28 12:55:17 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverState.hs
index 23c7cbb..4f953eb 100644 (file)
@@ -8,7 +8,6 @@
 
 module DriverState where
 
-#include "../includes/ghcconfig.h"
 #include "HsVersions.h"
 
 import CmdLineOpts
@@ -43,7 +42,7 @@ data GhcMode
   | DoInteractive                      -- ghc --interactive
   | DoLink                             -- [ the default ]
   | DoEval String                      -- ghc -e
-  deriving (Eq,Show)
+  deriving (Show)
 
 GLOBAL_VAR(v_GhcMode,     DoLink, GhcMode)
 GLOBAL_VAR(v_GhcModeFlag, "",     String)
@@ -58,6 +57,24 @@ setMode m flag = do
   writeIORef v_GhcMode m
   writeIORef v_GhcModeFlag flag
 
+isInteractiveMode, isInterpretiveMode     :: GhcMode -> Bool
+isMakeMode, isLinkMode, isCompManagerMode :: GhcMode -> Bool
+
+isInteractiveMode DoInteractive = True
+isInteractiveMode _            = False
+
+-- isInterpretiveMode: byte-code compiler involved
+isInterpretiveMode DoInteractive = True
+isInterpretiveMode (DoEval _)    = True
+isInterpretiveMode _             = False
+
+isMakeMode DoMake = True
+isMakeMode _      = False
+
+isLinkMode DoLink  = True
+isLinkMode DoMkDLL = True
+isLinkMode _       = False
+
 isCompManagerMode DoMake        = True
 isCompManagerMode DoInteractive = True
 isCompManagerMode (DoEval _)    = True
@@ -93,7 +110,6 @@ GLOBAL_VAR(v_NoLink,                         False,          Bool)
 GLOBAL_VAR(v_NoHsMain,                         False,          Bool)
 GLOBAL_VAR(v_MainModIs,                        Nothing,        Maybe String)
 GLOBAL_VAR(v_MainFunIs,                        Nothing,        Maybe String)
-GLOBAL_VAR(v_Recomp,                   True,           Bool)
 GLOBAL_VAR(v_Collect_ghc_timing,       False,          Bool)
 GLOBAL_VAR(v_Do_asm_mangling,          True,           Bool)
 GLOBAL_VAR(v_Excess_precision,         False,          Bool)
@@ -111,14 +127,19 @@ GLOBAL_VAR(v_Split_info,          ("",0),         (String,Int))
 
        
 can_split :: Bool
-can_split =  prefixMatch "i386"    cTARGETPLATFORM
-         || prefixMatch "alpha"   cTARGETPLATFORM
-         || prefixMatch "hppa"    cTARGETPLATFORM
-         || prefixMatch "m68k"    cTARGETPLATFORM
-         || prefixMatch "mips"    cTARGETPLATFORM
-         || prefixMatch "powerpc" cTARGETPLATFORM
-         || prefixMatch "rs6000"  cTARGETPLATFORM
-         || prefixMatch "sparc"   cTARGETPLATFORM
+can_split =  
+#if    defined(i386_TARGET_ARCH)     \
+    || defined(alpha_TARGET_ARCH)    \
+    || defined(hppa_TARGET_ARCH)     \
+    || defined(m68k_TARGET_ARCH)     \
+    || defined(mips_TARGET_ARCH)     \
+    || defined(powerpc_TARGET_ARCH)  \
+    || defined(rs6000_TARGET_ARCH)   \
+    || defined(sparc_TARGET_ARCH) 
+   True
+#else
+   False
+#endif
 
 -----------------------------------------------------------------------------
 -- Compiler output options
@@ -157,8 +178,8 @@ verifyOutputFiles = do
                              show dir ++ " does not exist (used with " ++ 
                             show flg ++ " option.)"))
 
-GLOBAL_VAR(v_Object_suf,  phaseInputExt Ln, String)
-GLOBAL_VAR(v_HC_suf,     Nothing, Maybe String)
+GLOBAL_VAR(v_Object_suf,  phaseInputExt StopLn, String)
+GLOBAL_VAR(v_HC_suf,     phaseInputExt HCc,    String)
 GLOBAL_VAR(v_Hi_dir,      Nothing, Maybe String)
 GLOBAL_VAR(v_Hi_suf,      "hi",           String)
 
@@ -205,21 +226,20 @@ GLOBAL_VAR(v_Framework_paths, [], [String])
 GLOBAL_VAR(v_Cmdline_frameworks, [], [String])
 #endif
 
-addToOrDeleteDirList :: IORef [String] -> String -> IO ()
-addToOrDeleteDirList ref ""   = writeIORef ref []
-addToOrDeleteDirList ref path = addToDirList ref path
-
 addToDirList :: IORef [String] -> String -> IO ()
 addToDirList ref path
   = do paths           <- readIORef ref
-       shiny_new_ones  <- splitUp path
-       writeIORef ref (paths ++ filter notNull shiny_new_ones)
+       shiny_new_ones  <- splitPathList path
+       writeIORef ref (paths ++ shiny_new_ones)
+
+
+splitPathList :: String -> IO [String]
+splitPathList s = do ps <- splitUp s; return (filter notNull ps)
                -- empty paths are ignored: there might be a trailing
                -- ':' in the initial list, for example.  Empty paths can
                -- cause confusion when they are translated into -I options
                -- for passing to gcc.
   where
-    splitUp ::String -> IO [String]
 #ifdef mingw32_TARGET_OS
      -- 'hybrid' support for DOS-style paths in directory lists.
      --