Targets.hs 4.23 KB
Newer Older
1
2
{-# LANGUAGE NoImplicitPrelude #-}
module Targets (
3
    targetWays, targetPackages, targetDirectories,
4
    customConfigureSettings,
5
6
7
8
    array, base, binPackageDb, binary, bytestring, cabal, containers, deepseq,
    directory, filepath, ghcPrim, haskeline, hoopl, hpc, integerLibrary,
    parallel, pretty, primitive, process, stm, templateHaskell, terminfo, time,
    transformers, unix, win32, xhtml
9
    ) where
10

11
import qualified Ways
12
13
import Base hiding (arg, args, Args)
import Switches
14
import Package
15
import Expression.Base
16

17
18
-- These are the packages we build
targetPackages :: Packages
19
targetPackages = msum
20
21
    [ stage Stage0 ? packagesStage0
    , stage Stage1 ? packagesStage1 ]
22

23
packagesStage0 :: Packages
24
packagesStage0 = msum
25
    [ fromList [ binPackageDb, binary, cabal, hoopl, hpc, transformers ]
26
    , not windowsHost && not (targetOs "ios") ? return terminfo ]
27

28
29
30
31
32
33
packagesStage1 :: Packages
packagesStage1 = msum
    [ packagesStage0
    , fromList [ array, base, bytestring, containers, deepseq, directory
               , filepath, ghcPrim, haskeline, integerLibrary, parallel
               , pretty, primitive, process, stm, templateHaskell, time ]
34
35
36
    , not windowsHost ? return unix
    , windowsHost     ? return win32
    , buildHaddock    ? return xhtml ]
37

38
39
40
-- Packages will be build these ways
targetWays :: Ways
targetWays = msum
41
42
43
    [                              return Ways.vanilla -- always build vanilla
    , notStage Stage0            ? return Ways.profiling
    , platformSupportsSharedLibs ? return Ways.dynamic ]
44

45
46
47
48
49
-- Build results will be placed into a target directory with the following
-- typical structure:
-- * build/           : contains compiled object code
-- * doc/             : produced by haddock
-- * package-data.mk  : contains output of ghc-cabal applied to pkgCabal
50
targetDirectories :: TargetDirs
51
targetDirectories =
52
53
    stage Stage0 ?? ( return $ TargetDir "dist-boot"
                    , return $ TargetDir "dist-install")
Andrey Mokhov's avatar
Andrey Mokhov committed
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
-- Package definitions
array, base, binPackageDb, binary, bytestring, cabal, containers, deepseq,
    directory, filepath, ghcPrim, haskeline, hoopl, hpc, integerLibrary,
    parallel, pretty, primitive, process, stm, templateHaskell, terminfo, time,
    transformers, unix, win32, xhtml :: Package

array           = library "array"
base            = library "base"
binPackageDb    = library "bin-package-db"
binary          = library "binary"
bytestring      = library "bytestring"
cabal           = library "Cabal/Cabal" `setCabal` "Cabal.cabal"
containers      = library "containers"
deepseq         = library "deepseq"
directory       = library "directory"
filepath        = library "filepath"
ghcPrim         = library "ghc-prim"
haskeline       = library "haskeline"
hoopl           = library "hoopl"
hpc             = library "hpc"
integerLibrary  = library integerLibraryName `setCabal` integerLibraryCabal
parallel        = library "parallel"
pretty          = library "pretty"
primitive       = library "primitive"
process         = library "process"
stm             = library "stm"
templateHaskell = library "template-haskell"
terminfo        = library "terminfo"
time            = library "time"
transformers    = library "transformers"
unix            = library "unix"
win32           = library "Win32"
xhtml           = library "xhtml"
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
integerLibraryName :: String
integerLibraryName = case integerLibraryImpl of
    IntegerGmp    -> "integer-gmp"
    IntegerGmp2   -> "integer-gmp2"
    IntegerSimple -> "integer-simple"

-- see Note [Cabal name weirdness]
integerLibraryCabal :: FilePath
integerLibraryCabal = case integerLibraryImpl of
        IntegerGmp    -> "integer-gmp.cabal"
        IntegerGmp2   -> "integer-gmp.cabal" -- Indeed, why make life easier?
        IntegerSimple -> "integer-simple.cabal"

-- Custom configure settings for packages
customConfigureSettings :: Settings
customConfigureSettings = msum
    [ package base    ? arg ("--flags=" ++ integerLibraryName)
    , package ghcPrim ? arg "--flag=include-ghc-prim"
    , package integerLibrary && windowsHost ?
        arg "--configure-option=--with-intree-gmp"
    ]

111
-- Note [Cabal name weirdness]
112
113
-- Find out if we can move the contents to just Cabal/
-- What is Cabal/cabal-install? Do we need it?
114
-- A related question about gmp2 -- let's rename the cabal file?