From e3d95da870e58a799d8db4079192ba2471d7853d Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 16 Aug 2004 11:19:27 +0000 Subject: [PATCH 1/1] [project @ 2004-08-16 11:19:24 by simonmar] Define _TARGET_ARCH and _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 | 2 ++ ghc/compiler/codeGen/SMRep.lhs | 2 +- ghc/compiler/main/DriverPipeline.hs | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile index ee40fc1..399757f 100644 --- a/ghc/compiler/Makefile +++ b/ghc/compiler/Makefile @@ -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) diff --git a/ghc/compiler/codeGen/SMRep.lhs b/ghc/compiler/codeGen/SMRep.lhs index 92b9513..9e1b7a7 100644 --- a/ghc/compiler/codeGen/SMRep.lhs +++ b/ghc/compiler/codeGen/SMRep.lhs @@ -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 diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs index 81c2f46..0673abb 100644 --- a/ghc/compiler/main/DriverPipeline.hs +++ b/ghc/compiler/main/DriverPipeline.hs @@ -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 -- 1.7.10.4