From 55f13a324c9a9427fd4e0ae425d7f1d2ee475b66 Mon Sep 17 00:00:00 2001 From: ijones <ijones@syntaxpolice.org> Date: Fri, 15 Jul 2005 15:44:27 +0000 Subject: [PATCH] simonMar: ppCpp': Use GHC instead of cpphs if the latter is not available --- Distribution/PreProcess.hs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Distribution/PreProcess.hs b/Distribution/PreProcess.hs index 06e49020b1..c6eb553a35 100644 --- a/Distribution/PreProcess.hs +++ b/Distribution/PreProcess.hs @@ -205,21 +205,34 @@ ppCpp :: BuildInfo -> LocalBuildInfo -> PreProcessor ppCpp = ppCpp' [] ppCpp' :: [String] -> BuildInfo -> LocalBuildInfo -> PreProcessor -ppCpp' inputArgs bi lbi - = maybe (ppNone "cpphs") pp (withCpphs lbi) - where pp cpphs inFile outFile verbose +ppCpp' inputArgs bi lbi = + case withCpphs lbi of + Just path -> use_cpphs path + Nothing | compilerFlavor hc == GHC -> use_ghc + _otherwise -> ppNone "cpphs (or GHC)" + where + hc = compiler lbi + + use_cpphs cpphs inFile outFile verbose #if __HUGS__ && mingw32_TARGET_OS - = rawSystemVerbose verbose "sh" (cpphs : extraArgs ++ ["-O" ++ outFile, inFile]) + = rawSystemVerbose verbose "sh" (cpphs : cpphsArgs) #else - = rawSystemVerbose verbose cpphs (extraArgs ++ ["-O" ++ outFile, inFile]) + = rawSystemVerbose verbose cpphs cpphsArgs #endif - extraArgs = "--noline" : "--strip" : - sysDefines ++ cppOptions bi lbi ++ inputArgs + where cpphsArgs = ("-O"++outFile) : inFile : "--noline" : "--strip" + : extraArgs + + extraArgs = sysDefines ++ cppOptions bi lbi ++ inputArgs + sysDefines = ["-D" ++ os ++ "_" ++ loc ++ "_OS" | loc <- locations] ++ ["-D" ++ arch ++ "_" ++ loc ++ "_ARCH" | loc <- locations] locations = ["BUILD", "HOST"] + use_ghc inFile outFile verbose + = rawSystemVerbose verbose (compilerPath hc) + (["-E", "-cpp", "-optP-P", "-o", outFile, inFile] ++ extraArgs) + ppHsc2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor ppHsc2hs bi lbi = maybe (ppNone "hsc2hs") pp (withHsc2hs lbi) -- GitLab