Commit 176bfd4d authored by Zhen Zhang's avatar Zhen Zhang Committed by Andrey Mokhov

Add DESTDIR to command line arguments (#397)

parent c413722e
......@@ -111,7 +111,7 @@ To build a GHC source distribution tarball, run Hadrian with the `sdist-ghc` tar
To build and install GHC artifacts, run the `install` target.
By default, the artifacts will be installed to `<prefix>` on your system. For example,
`ghc` will be installed to `/usr/local/bin`. By modifying `defaultDestDir` in `UserSettings.hs`,
`ghc` will be installed to `/usr/local/bin`. By setting flag `--install-destdir=[DESTDIR]`,
you can install things to non-system path `DESTDIR/<prefix>` instead.
#### Testing
......
module CommandLine (
optDescrs, cmdLineArgsMap, cmdBuildHaddock, cmdFlavour, cmdIntegerSimple,
cmdProgressColour, cmdProgressInfo, cmdSkipConfigure, cmdSplitObjects
cmdProgressColour, cmdProgressInfo, cmdSkipConfigure, cmdSplitObjects,
cmdInstallDestDir
) where
import Data.Either
......@@ -14,6 +15,7 @@ import System.Environment
-- | All arguments that can be passed to Hadrian via the command line.
data CommandLineArgs = CommandLineArgs
{ buildHaddock :: Bool
, installDestDir :: Maybe String
, flavour :: Maybe String
, integerSimple :: Bool
, progressColour :: UseColour
......@@ -27,6 +29,7 @@ defaultCommandLineArgs :: CommandLineArgs
defaultCommandLineArgs = CommandLineArgs
{ buildHaddock = False
, flavour = Nothing
, installDestDir = Nothing
, integerSimple = False
, progressColour = Auto
, progressInfo = Normal
......@@ -39,6 +42,9 @@ readBuildHaddock = Right $ \flags -> flags { buildHaddock = True }
readFlavour :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readFlavour ms = Right $ \flags -> flags { flavour = lower <$> ms }
readInstallDestDir :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readInstallDestDir ms = Right $ \flags -> flags { installDestDir = ms }
readIntegerSimple :: Either String (CommandLineArgs -> CommandLineArgs)
readIntegerSimple = Right $ \flags -> flags { integerSimple = True }
......@@ -80,6 +86,8 @@ optDescrs =
"Build flavour (Default, Devel1, Devel2, Perf, Prof, Quick or Quickest)."
, Option [] ["haddock"] (NoArg readBuildHaddock)
"Generate Haddock documentation."
, Option [] ["install-destdir"] (OptArg readInstallDestDir "DESTDIR")
"Installation destination directory."
, Option [] ["integer-simple"] (NoArg readIntegerSimple)
"Build GHC with integer-simple library."
, Option [] ["progress-colour"] (OptArg readProgressColour "MODE")
......@@ -107,6 +115,9 @@ cmdLineArgs = userSetting defaultCommandLineArgs
cmdBuildHaddock :: Action Bool
cmdBuildHaddock = buildHaddock <$> cmdLineArgs
cmdInstallDestDir :: Action (Maybe String)
cmdInstallDestDir = installDestDir <$> cmdLineArgs
cmdFlavour :: Action (Maybe String)
cmdFlavour = flavour <$> cmdLineArgs
......
......@@ -60,6 +60,7 @@ getLibExecDir = (-/- "bin") <$> installGhcLibDir
installLibExecScripts :: Action ()
installLibExecScripts = do
libExecDir <- getLibExecDir
destDir <- getDestDir
installDirectory (destDir ++ libExecDir)
forM_ libExecScripts $ \script -> do
installScript script (destDir ++ libExecDir)
......@@ -72,6 +73,7 @@ installLibExecScripts = do
installLibExecs :: Action ()
installLibExecs = do
libExecDir <- getLibExecDir
destDir <- getDestDir
installDirectory (destDir ++ libExecDir)
forM_ installBinPkgs $ \pkg -> do
withLatestBuildStage pkg $ \stage -> do
......@@ -88,6 +90,7 @@ installBins :: Action ()
installBins = do
binDir <- setting InstallBinDir
libDir <- installGhcLibDir
destDir <- getDestDir
installDirectory (destDir ++ binDir)
win <- windowsHost
when win $
......@@ -153,6 +156,7 @@ installPackages = do
ghcLibDir <- installGhcLibDir
binDir <- setting InstallBinDir
destDir <- getDestDir
-- Install package.conf
let installedPackageConf = destDir ++ ghcLibDir -/- "package.conf.d"
......@@ -271,6 +275,7 @@ installPackages = do
installCommonLibs :: Action ()
installCommonLibs = do
ghcLibDir <- installGhcLibDir
destDir <- getDestDir
installLibsTo inplaceLibCopyTargets (destDir ++ ghcLibDir)
-- ref: ghc.mk
......@@ -296,6 +301,7 @@ includeHSubdirs = [".", "rts", "rts/prof", "rts/storage", "stg"]
installIncludes :: Action ()
installIncludes = do
ghclibDir <- installGhcLibDir
destDir <- getDestDir
let ghcheaderDir = ghclibDir -/- "include"
installDirectory (destDir ++ ghcheaderDir)
forM_ includeHSubdirs $ \dir -> do
......
......@@ -2,7 +2,7 @@ module Settings (
getArgs, getPackages, getLibraryWays, getRtsWays, flavour, knownPackages,
findKnownPackage, getPkgData, getPkgDataList, isLibrary, stagePackages,
builderPath, getBuilderPath, isSpecified, latestBuildStage, programPath,
programContext, integerLibraryName, destDir, stage1Only, buildDll0
programContext, integerLibraryName, getDestDir, stage1Only, buildDll0
) where
import Context
......@@ -103,7 +103,6 @@ programPath context@Context {..} = do
stage1Only :: Bool
stage1Only = defaultStage1Only
-- TODO: Set this from command line
-- | Install's DESTDIR setting.
destDir :: FilePath
destDir = defaultDestDir
getDestDir :: Action FilePath
getDestDir = fromMaybe "" <$> cmdInstallDestDir
......@@ -62,6 +62,7 @@ rtsPackageArgs = package rts ? do
ffiIncludeDir <- getSetting FfiIncludeDir
ffiLibraryDir <- getSetting FfiLibDir
ghclibDir <- expr installGhcLibDir
destDir <- expr getDestDir
let cArgs =
[ arg "-Irts"
, arg $ "-I" ++ path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment