[project @ 2004-08-16 11:19:24 by simonmar]
authorsimonmar <unknown>
Mon, 16 Aug 2004 11:19:27 +0000 (11:19 +0000)
committersimonmar <unknown>
Mon, 16 Aug 2004 11:19:27 +0000 (11:19 +0000)
Define <arch>_TARGET_ARCH and <os>_TARGET_OS by default when CPP'ing.
This avoids the main reason for needing to #include config.h into
Haskell source, so most files that previously just #include "config.h" can now

  #if __GLASGOW_HASKELL__ < 603
  #include "config.h"
  #endif

ghc/compiler/Makefile
ghc/compiler/codeGen/SMRep.lhs
ghc/compiler/main/DriverPipeline.hs

index ee40fc1..399757f 100644 (file)
@@ -192,6 +192,8 @@ $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
        @echo "cHscIfaceFileVersion  = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
        @echo "cHOSTPLATFORM         = \"$(HOSTPLATFORM)\"" >> $(CONFIG_HS)
        @echo "cTARGETPLATFORM       = \"$(TARGETPLATFORM)\"" >> $(CONFIG_HS)
+       @echo "cTARGETOS             = \"$(TargetOS_CPP)\"" >> $(CONFIG_HS)
+       @echo "cTARGETARCH           = \"$(TargetArch_CPP)\"" >> $(CONFIG_HS)
        @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
        @echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
        @echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
index 92b9513..9e1b7a7 100644 (file)
@@ -41,7 +41,7 @@ module SMRep (
 import Id              ( Id, idType )
 import Type            ( Type, typePrimRep, PrimRep(..) )
 import TyCon           ( TyCon, tyConPrimRep )
-import MachOp          ( MachRep(..), MachHint(..), wordRep )
+import MachOp--                ( MachRep(..), MachHint(..), wordRep )
 import CmdLineOpts     ( opt_SccProfilingOn, opt_GranMacros, opt_Unregisterised )
 import Constants
 import Outputable
index 81c2f46..0673abb 100644 (file)
@@ -1167,11 +1167,16 @@ doCpp raw include_cc_opts input_fn output_fn = do
     let cpp_prog args | raw       = SysTools.runCpp args
                      | otherwise = SysTools.runCc (SysTools.Option "-E" : args)
 
+    let target_defs = 
+         [ "-D" ++ cTARGETOS   ++ "_TARGET_OS=1",
+           "-D" ++ cTARGETARCH ++ "_TARGET_ARCH=1" ]
+
     cpp_prog       ([SysTools.Option verb]
                    ++ map SysTools.Option include_paths
                    ++ map SysTools.Option hsSourceCppOpts
                    ++ map SysTools.Option hscpp_opts
                    ++ map SysTools.Option cc_opts
+                   ++ map SysTools.Option target_defs
                    ++ [ SysTools.Option     "-x"
                       , SysTools.Option     "c"
                       , SysTools.Option     input_fn