Generic library rules (#571)
[ghc.git] / src / Rules / Configure.hs
1 module Rules.Configure (configureRules) where
2
3 import qualified System.Info.Extra as System
4
5 import Base
6 import Builder
7 import CommandLine
8 import Context
9 import GHC
10 import Target
11 import Utilities
12
13 configureRules :: Rules ()
14 configureRules = do
15 -- TODO: consider other files we should track here (rts/rts.cabal etc)
16 [configFile, "settings", configH, "compiler/ghc.cabal"] &%> \outs -> do
17 skip <- not <$> cmdConfigure
18 if skip
19 then unlessM (doesFileExist configFile) $
20 error $ "Configuration file " ++ configFile ++ " is missing.\n"
21 ++ "Run the configure script manually or let Hadrian run it "
22 ++ "automatically by passing the flag --configure."
23 else do
24 -- We cannot use windowsHost here due to a cyclic dependency.
25 when System.isWindows $ do
26 putBuild "| Checking for Windows tarballs..."
27 quietly $ cmd ["bash", "mk/get-win32-tarballs.sh", "download", System.arch]
28 let srcs = map (<.> "in") outs
29 context = vanillaContext Stage0 compiler
30 need srcs
31 build $ target context (Configure ".") srcs outs
32
33 ["configure", configH <.> "in"] &%> \_ -> do
34 skip <- not <$> cmdConfigure
35 if skip
36 then unlessM (doesFileExist "configure") $
37 error $ "The configure script is missing.\nRun the boot script "
38 ++ "manually let Hadrian run it automatically by passing the "
39 ++ "flag --configure."
40 else do
41 need ["configure.ac"]
42 putBuild "| Running boot..."
43 verbosity <- getVerbosity
44 quietly $ cmd [EchoStdout (verbosity >= Loud)] "python3 boot --hadrian"