[project @ 2004-10-03 16:28:02 by panne]
[ghc-hetmet.git] / ghc / compiler / main / DriverState.hs
index b6b527e..1efafd2 100644 (file)
@@ -1,5 +1,4 @@
 -----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.98 2004/02/24 17:33:34 simonmar Exp $
 --
 -- Settings for the driver
 --
@@ -9,7 +8,7 @@
 
 module DriverState where
 
-#include "../includes/config.h"
+#include "../includes/ghcconfig.h"
 #include "HsVersions.h"
 
 import ParsePkgConf    ( loadPackageConfig )
@@ -65,19 +64,19 @@ setMode m flag = do
 
 isCompManagerMode DoMake        = True
 isCompManagerMode DoInteractive = True
+isCompManagerMode (DoEval _)    = True
 isCompManagerMode _             = False
 
 -----------------------------------------------------------------------------
 -- Global compilation flags
 
--- Cpp-related flags
-v_Hs_source_cpp_opts = global
+-- Default CPP defines in Haskell source
+hsSourceCppOpts =
        [ "-D__HASKELL1__="++cHaskell1Version
        , "-D__GLASGOW_HASKELL__="++cProjectVersionInt                          
        , "-D__HASKELL98__"
        , "-D__CONCURRENT_HASKELL__"
        ]
-{-# NOINLINE v_Hs_source_cpp_opts #-}
 
 
 -- Keep output from intermediate phases
@@ -203,7 +202,7 @@ split_marker = ':'   -- not configurable (ToDo)
 
 v_Import_paths, v_Include_paths, v_Library_paths :: IORef [String]
 GLOBAL_VAR(v_Import_paths,  ["."], [String])
-GLOBAL_VAR(v_Include_paths, ["."], [String])
+GLOBAL_VAR(v_Include_paths, [], [String])
 GLOBAL_VAR(v_Library_paths, [],         [String])
 
 #ifdef darwin_TARGET_OS
@@ -211,6 +210,10 @@ 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
@@ -521,14 +524,19 @@ GLOBAL_VAR(v_Ways, [] ,[WayName])
 allowed_combination way = and [ x `allowedWith` y 
                              | x <- way, y <- way, x < y ]
   where
+       -- Note ordering in these tests: the left argument is
+       -- <= the right argument, according to the Ord instance
+       -- on Way above.
+
        -- debug is allowed with everything
        _ `allowedWith` WayDebug                = True
        WayDebug `allowedWith` _                = True
 
-       WayProf `allowedWith` WayThreaded       = True
+       WayThreaded `allowedWith` WayProf       = True
        WayProf `allowedWith` WayUnreg          = True
        WayProf `allowedWith` WaySMP            = True
        WayProf `allowedWith` WayNDP            = True
+       _ `allowedWith` _                       = False
 
 
 findBuildTag :: IO [String]  -- new options
@@ -540,15 +548,18 @@ findBuildTag = do
                    "combination not supported: "  ++
                    foldr1 (\a b -> a ++ '/':b) 
                    (map (wayName . lkupWay) ws))
-      else let stuff   = map lkupWay ws
-              tag     = concat [ wayTag w | w <- stuff, not (wayRTSOnly w) ]
-              rts_tag = concat (map wayTag stuff)
-              flags   = map wayOpts stuff
+      else let ways    = map lkupWay ws
+              tag     = mkBuildTag (filter (not.wayRTSOnly) ways)
+              rts_tag = mkBuildTag ways
+              flags   = map wayOpts ways
           in do
           writeIORef v_Build_tag tag
           writeIORef v_RTS_Build_tag rts_tag
           return (concat flags)
 
+mkBuildTag :: [Way] -> String
+mkBuildTag ways = concat (intersperse "_" (map wayTag ways))
+
 lkupWay w = 
    case lookup w way_details of
        Nothing -> error "findBuildTag"
@@ -565,7 +576,7 @@ way_details :: [ (WayName, Way) ]
 way_details =
   [ (WayThreaded, Way "thr" True "Threaded" [
 #if defined(freebsd_TARGET_OS)
-       , "-optc-pthread"
+       "-optc-pthread"
 #endif
        ] ),