Targets.hs 3.91 KB
Newer Older
1
module Targets (
2 3
    targetDirectory,
    knownPackages,
Andrey Mokhov's avatar
Andrey Mokhov committed
4
    customPackageSettings,
5
    integerLibraryName,
6 7 8 9
    array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
    deepseq, directory, filepath, ghcPrim, haskeline, hoopl, hpc,
    integerLibrary, parallel, pretty, primitive, process, stm, templateHaskell,
    terminfo, time, transformers, unix, win32, xhtml
10
    ) where
11

12
import Base hiding (arg, args)
13
import Package
Andrey Mokhov's avatar
Andrey Mokhov committed
14 15
import Switches
import Expression
16
import Settings.Util
Andrey Mokhov's avatar
Andrey Mokhov committed
17
import Oracles.Builder
18

19 20 21 22 23
-- 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
24
-- TODO: This is currently not user configurable. Is this right?
25 26
targetDirectory :: Stage -> Package -> FilePath
targetDirectory stage package
Andrey Mokhov's avatar
Andrey Mokhov committed
27
    | package == compiler = "stage" ++ show (fromEnum stage + 1)
28 29
    | stage   == Stage0   = "dist-boot"
    | otherwise           = "dist-install"
Andrey Mokhov's avatar
Andrey Mokhov committed
30

31 32 33 34 35 36 37
-- These are all packages we know about. Build rules will be generated for
-- all of them. However, not all of these packages will be built. For example,
-- package 'win32' is built only on Windows.
-- Settings/Packages.hs defines default conditions for building each package,
-- which can be overridden in UserSettings.hs.
knownPackages :: [Package]
knownPackages =
Andrey Mokhov's avatar
Andrey Mokhov committed
38 39 40 41
    [ array, base, binPackageDb, binary, bytestring, cabal, compiler
    , containers, deepseq, directory, filepath, ghcPrim, haskeline
    , hoopl, hpc, integerLibrary, parallel, pretty, primitive, process
    , stm, templateHaskell, terminfo, time, transformers, unix, win32, xhtml ]
42

43
-- Package definitions
Andrey Mokhov's avatar
Andrey Mokhov committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
array           = library  "array"
base            = library  "base"
binPackageDb    = library  "bin-package-db"
binary          = library  "binary"
bytestring      = library  "bytestring"
cabal           = library  "Cabal/Cabal" `setCabal` "Cabal.cabal"
compiler        = topLevel "compiler"    `setCabal` "ghc.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"
72

73 74 75 76 77 78 79 80 81
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
Andrey Mokhov's avatar
Andrey Mokhov committed
82 83 84
    IntegerGmp    -> "integer-gmp.cabal"
    IntegerGmp2   -> "integer-gmp.cabal" -- Indeed, why make life easier?
    IntegerSimple -> "integer-simple.cabal"
85

Andrey Mokhov's avatar
Andrey Mokhov committed
86
customPackageSettings :: Settings
87
customPackageSettings = mconcat
Andrey Mokhov's avatar
Andrey Mokhov committed
88
    [ package integerLibrary ?
89
      mconcat [ windowsHost ? builder GhcCabal ?
90
                arg "--configure-option=--with-intree-gmp"
91 92 93
              , appendCcArgs ["-Ilibraries/integer-gmp2/gmp"] ]

    , package base ?
94
      builder GhcCabal ? arg ("--flags=" ++ integerLibraryName)
95 96

    , package ghcPrim ?
97
      builder GhcCabal ? arg "--flag=include-ghc-prim" ]
98

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