This patch adds lots of --target-X options to cabal, which are used during the build, but which are not needed after deployment. There may be a better way to achieve this, so only add this if the build requires it. --- ghc-6.10.2.orig/libraries/Cabal/Distribution/Simple/Setup.hs 2009-03-31 06:16:33.000000000 +1300 +++ ghc-6.10.2/libraries/Cabal/Distribution/Simple/Setup.hs 2009-06-18 15:54:37.000000000 +1200 @@ -106,6 +106,7 @@ import Distribution.Simple.InstallDirs ( InstallDirs(..), CopyDest(..), PathTemplate, toPathTemplate, fromPathTemplate ) +import Distribution.Simple.ToolChain import Data.List (sort) import Data.Char (isSpace) import Data.Monoid (Monoid(..)) @@ -261,6 +262,7 @@ configHcFlavor :: Flag CompilerFlavor, -- ^The \"flavor\" of the compiler, sugh as GHC or Hugs. configHcPath :: Flag FilePath, -- ^given compiler location configHcPkg :: Flag FilePath, -- ^given hc-pkg location + configToolChain :: ToolChain, -- ^toolchain for cross compile configVanillaLib :: Flag Bool, -- ^Enable vanilla library configProfLib :: Flag Bool, -- ^Enable profiling in the library configSharedLib :: Flag Bool, -- ^Build shared library @@ -320,6 +322,21 @@ ++ programConfigurationOptions progConf showOrParseArgs configProgramArgs (\v fs -> fs { configProgramArgs = v }) +stringArg :: Monoid b => ArgPlaceHolder -> ReadE b -> (b -> [String]) + -> MkOptDescr (a -> b) (b -> a -> a) a +stringArg ad mkflag showflag sf lf d get set = + ReqArg d (sf,lf) ad (fmap (\a b -> set a b) mkflag) (showflag . get) + +toolchainOption :: String -- ^ option name + -> (ToolChain -> String) -- ^ get function + -> (String -> ToolChain -> ToolChain) -- ^ set function + -> OptionField ConfigFlags +toolchainOption name get set = + option "" [name] + ("set "++name++" - default="++get defaultToolChain) + (get . configToolChain) + (\v flags -> flags { configToolChain = set v (configToolChain flags) }) + (stringArg "OPT" (succeedReadE id) (\x -> [x])) configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags] configureOptions showOrParseArgs = @@ -344,6 +361,15 @@ "give the path to the package tool" configHcPkg (\v flags -> flags { configHcPkg = v }) (reqArgFlag "PATH") + + ,toolchainOption "target-gcc" targetGCC (\v tc -> tc {targetGCC = v}) + ,toolchainOption "target-ld" targetLD (\v tc -> tc {targetLD = v}) + ,toolchainOption "target-ar" targetAR (\v tc -> tc {targetAR = v}) + ,toolchainOption "target-ranlib" targetRANLIB (\v tc -> tc {targetRANLIB = v}) + ,toolchainOption "target-strip" targetSTRIP (\v tc -> tc {targetSTRIP = v}) + ,toolchainOption "target-cppflags" targetCPPFLAGS (\v tc -> tc {targetCPPFLAGS = v}) + ,toolchainOption "target-cflags" targetCFLAGS (\v tc -> tc {targetCFLAGS = v}) + ,toolchainOption "target-ldflags" targetLDFLAGS (\v tc -> tc {targetLDFLAGS = v}) ] ++ map liftInstallDirs installDirsOptions ++ [option "b" ["scratchdir"] @@ -536,6 +562,7 @@ configPrograms = error "FIXME: remove configPrograms", configProgramPaths = mempty, configProgramArgs = mempty, + configToolChain = defaultToolChain, configHcFlavor = mempty, configHcPath = mempty, configHcPkg = mempty, @@ -565,6 +592,7 @@ configPrograms = configPrograms b, configProgramPaths = combine configProgramPaths, configProgramArgs = combine configProgramArgs, + configToolChain = configToolChain b, configHcFlavor = combine configHcFlavor, configHcPath = combine configHcPath, configHcPkg = combine configHcPkg,