Get building GHC itself with Cabal more-or-less working
[ghc-hetmet.git] / ghc / Makefile
1
2 TOP=..
3 include $(TOP)/mk/boilerplate.mk
4 include $(TOP)/mk/cabal-flags.mk
5
6 ifeq "$(stage)" ""
7 stage=1
8 endif
9
10 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
11 INSTALL_FLAGS =
12 else
13 INSTALL_FLAGS = --enable-shell-wrappers
14 endif
15
16 boot:
17         @:
18
19 all:: build.stage$(stage)
20
21 stage1 ::
22         $(MAKE) stage=1
23
24 stage2 ::
25         $(MAKE) stage=2
26
27 stage3 ::
28         $(MAKE) stage=3
29
30 clean distclean::
31         -$(CABAL) clean --distpref dist-stage1
32         -$(CABAL) clean --distpref dist-stage2
33         $(RM) -rf stage1-inplace
34         $(RM) -rf stage2-inplace
35
36 build.stage1:
37         $(CABAL) configure --distpref dist-stage1 \
38                            --flags=-ghci \
39                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
40                            $(USE_BOOT_CONFIGURE_FLAGS) \
41                            $(COMMON_CONFIGURE_FLAGS)
42         $(CABAL) build     --distpref dist-stage1 $(BUILD_FLAGS)
43         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
44                            $(FPTOOLS_TOP_ABS)/ghc/stage1-inplace \
45                            $(FPTOOLS_TOP_ABS)/ghc/stage1-inplace \
46                            '$$prefix/bin' \
47                            '$$prefix/lib' \
48                            '$$prefix/libexec' \
49                            '$$prefix/dynlib' \
50                            '$$prefix/data' \
51                            '$$prefix/doc' \
52                            '$$prefix/html' \
53                            '$$prefix/haddock' \
54                            --distpref dist-stage1 \
55                            $(INSTALL_FLAGS)
56
57 ifeq "$(GhcWithInterpreter)" "YES"
58 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
59 else
60 CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
61 endif
62
63 ifeq "$(GhcProfiled)" "YES"
64 CONFIGURE_FLAGS_STAGE2 += --enable-executable-profiling
65 endif
66 ifeq "$(GhcDebugged)" "YES"
67 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-debug
68 endif
69 ifeq "$(GhcThreaded)" "YES"
70 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
71 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
72 endif
73
74 # XXX In stage2 we should really use the inplace ghc-pkg
75 # It works because installPackage doesn't actually use ghc-pkg, as there's
76 # no library to register
77
78 build.stage2:
79         $(CABAL) configure --distpref dist-stage2 \
80                            $(CONFIGURE_FLAGS_STAGE2) \
81                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
82                            $(USE_STAGE1_CONFIGURE_FLAGS) \
83                            $(COMMON_CONFIGURE_FLAGS)
84         $(CABAL) build     --distpref dist-stage2 $(BUILD_FLAGS)
85         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
86                            $(FPTOOLS_TOP_ABS)/ghc/stage2-inplace \
87                            $(FPTOOLS_TOP_ABS)/ghc/stage2-inplace \
88                            '$$prefix/bin' \
89                            '$$prefix/lib' \
90                            '$$prefix/libexec' \
91                            '$$prefix/dynlib' \
92                            '$$prefix/data' \
93                            '$$prefix/doc' \
94                            '$$prefix/html' \
95                            '$$prefix/haddock' \
96                            --distpref dist-stage2 \
97                            $(INSTALL_FLAGS)
98
99 # XXX fix:
100 #binary-dist:
101 #       $(INSTALL_DIR)                      $(BIN_DIST_DIR)/utils/hsc2hs
102 #       $(INSTALL_DATA)    Makefile         $(BIN_DIST_DIR)/utils/hsc2hs/
103 #       $(INSTALL_DATA)    hsc2hs.sh        $(BIN_DIST_DIR)/utils/hsc2hs/
104 #       $(INSTALL_DATA)    $(INSTALL_DATAS) $(BIN_DIST_DIR)/utils/hsc2hs/
105 #       $(INSTALL_PROGRAM) $(HS_PROG)       $(BIN_DIST_DIR)/utils/hsc2hs/
106