summaryrefslogtreecommitdiff
path: root/utils/ghc-cabal/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ghc-cabal/Main.hs')
-rw-r--r--utils/ghc-cabal/Main.hs49
1 files changed, 28 insertions, 21 deletions
diff --git a/utils/ghc-cabal/Main.hs b/utils/ghc-cabal/Main.hs
index 991b2b80b6..9a76d6b93d 100644
--- a/utils/ghc-cabal/Main.hs
+++ b/utils/ghc-cabal/Main.hs
@@ -34,26 +34,24 @@ main :: IO ()
main = do hSetBuffering stdout LineBuffering
args <- getArgs
case args of
- "hscolour" : distDir : dir : args' ->
- runHsColour distDir dir args'
+ "hscolour" : dir : distDir : args' ->
+ runHsColour dir distDir args'
"check" : dir : [] ->
doCheck dir
- "copy" : strip : directory : distDir
- : myDestDir : myPrefix : myLibdir : myDocdir
+ "copy" : dir : distDir
+ : strip : myDestDir : myPrefix : myLibdir : myDocdir
: args' ->
- doCopy strip directory distDir
- myDestDir myPrefix myLibdir myDocdir
+ doCopy dir distDir
+ strip myDestDir myPrefix myLibdir myDocdir
args'
- "register" : ghc : ghcpkg : topdir : directory : distDir
+ "register" : dir : distDir : ghc : ghcpkg : topdir
: myDestDir : myPrefix : myLibdir : myDocdir
: relocatableBuild : args' ->
- doRegister ghc ghcpkg topdir directory distDir
+ doRegister dir distDir ghc ghcpkg topdir
myDestDir myPrefix myLibdir myDocdir
relocatableBuild args'
- "configure" : args' -> case break (== "--") args' of
- (config_args, "--" : distdir : directories) ->
- mapM_ (generate config_args distdir) directories
- _ -> die syntax_error
+ "configure" : dir : distDir : dll0Modules : config_args ->
+ generate dir distDir dll0Modules config_args
"sdist" : dir : distDir : [] ->
doSdist dir distDir
["--version"] ->
@@ -124,7 +122,7 @@ doCheck directory
isFailure _ = True
runHsColour :: FilePath -> FilePath -> [String] -> IO ()
-runHsColour distdir directory args
+runHsColour directory distdir args
= withCurrentDirectory directory
$ defaultMainArgs ("hscolour" : "--builddir" : distdir : args)
@@ -132,9 +130,9 @@ doCopy :: FilePath -> FilePath
-> FilePath -> FilePath -> FilePath -> FilePath -> FilePath
-> [String]
-> IO ()
-doCopy strip directory distDir
- myDestDir myPrefix myLibdir myDocdir
- args
+doCopy directory distDir
+ strip myDestDir myPrefix myLibdir myDocdir
+ args
= withCurrentDirectory directory $ do
let copyArgs = ["copy", "--builddir", distDir]
++ (if null myDestDir
@@ -182,7 +180,7 @@ doRegister :: FilePath -> FilePath -> FilePath -> FilePath
-> FilePath -> FilePath -> FilePath -> FilePath -> FilePath
-> String -> [String]
-> IO ()
-doRegister ghc ghcpkg topdir directory distDir
+doRegister directory distDir ghc ghcpkg topdir
myDestDir myPrefix myLibdir myDocdir
relocatableBuildStr args
= withCurrentDirectory directory $ do
@@ -300,8 +298,8 @@ mangleLbi "compiler" "stage2" lbi
_ -> False
mangleLbi _ _ lbi = lbi
-generate :: [String] -> FilePath -> FilePath -> IO ()
-generate config_args distdir directory
+generate :: FilePath -> FilePath -> String -> [String] -> IO ()
+generate directory distdir dll0Modules config_args
= withCurrentDirectory directory
$ do let verbosity = normal
-- XXX We shouldn't just configure with the default flags
@@ -405,9 +403,12 @@ generate config_args distdir directory
wrappedLibraryDirs <- wrap libraryDirs
let variablePrefix = directory ++ '_':distdir
+ mods = map display modules
+ otherMods = map display (otherModules bi)
+ allMods = mods ++ otherMods
let xs = [variablePrefix ++ "_VERSION = " ++ display (pkgVersion (package pd)),
- variablePrefix ++ "_MODULES = " ++ unwords (map display modules),
- variablePrefix ++ "_HIDDEN_MODULES = " ++ unwords (map display (otherModules bi)),
+ variablePrefix ++ "_MODULES = " ++ unwords mods,
+ variablePrefix ++ "_HIDDEN_MODULES = " ++ unwords otherMods,
variablePrefix ++ "_SYNOPSIS =" ++ synopsis pd,
variablePrefix ++ "_HS_SRC_DIRS = " ++ unwords (hsSourceDirs bi),
variablePrefix ++ "_DEPS = " ++ unwords deps,
@@ -437,6 +438,7 @@ generate config_args distdir directory
variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions),
variablePrefix ++ "_DEP_LIB_DIRS_SINGLE_QUOTED = " ++ unwords wrappedLibraryDirs,
variablePrefix ++ "_DEP_LIB_DIRS_SEARCHPATH = " ++ mkSearchPath libraryDirs,
+ variablePrefix ++ "_DEP_LIB_REL_DIRS = " ++ unwords libraryRelDirs,
variablePrefix ++ "_DEP_LIB_REL_DIRS_SEARCHPATH = " ++ mkSearchPath libraryRelDirs,
variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries),
variablePrefix ++ "_DEP_LD_OPTS = " ++ unwords (forDeps Installed.ldOptions),
@@ -450,6 +452,11 @@ generate config_args distdir directory
writeFile (distdir ++ "/haddock-prologue.txt") $
if null (description pd) then synopsis pd
else description pd
+ unless (null dll0Modules) $
+ do let dll0Mods = words dll0Modules
+ dllMods = allMods \\ dll0Mods
+ dllModSets = map unwords [dll0Mods, dllMods]
+ writeFile (distdir ++ "/dll-split") $ unlines dllModSets
where
escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) []
wrap = mapM wrap1