More build system changes; ghc-pkg is now built with Cabal
[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:: boot.stage.$(stage)
17
18 all:: build.stage.$(stage)
19
20 stage1 ::
21         $(MAKE) stage=1
22
23 stage2 ::
24         $(MAKE) stage=2
25
26 stage3 ::
27         $(MAKE) stage=3
28
29 clean distclean::
30         -$(CABAL) clean --distpref dist-stage1
31         -$(CABAL) clean --distpref dist-stage2
32         $(RM) -rf stage1-inplace
33         $(RM) -rf stage2-inplace
34
35 # XXX This should be defined somewhere more central
36 INPLACE_DATA_DIR = $(FPTOOLS_TOP_ABS)/inplace-datadir
37
38 CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
39
40 ifeq "$(GhcWithInterpreter)" "YES"
41 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
42 else
43 CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
44 endif
45
46 ifeq "$(GhcProfiled)" "YES"
47 CONFIGURE_FLAGS_STAGE2 += --enable-executable-profiling
48 endif
49 ifeq "$(GhcDebugged)" "YES"
50 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-debug
51 endif
52 ifeq "$(GhcThreaded)" "YES"
53 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
54 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
55 endif
56
57 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
58
59 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
60 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
61 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
62
63 # XXX In stage2+ we should really use the inplace ghc-pkg
64 # It works because installPackage doesn't actually use ghc-pkg, as there's
65 # no library to register
66
67 boot.stage.%:
68         $(CABAL) configure --distpref dist-stage$* \
69                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
70                            $(CONFIGURE_FLAGS_STAGE$*) \
71                            $(COMMON_CONFIGURE_FLAGS)
72
73 build.stage.%:
74         $(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
75         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
76                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \
77                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \
78                            '$$prefix/bin' \
79                            '$$prefix/lib' \
80                            '$$prefix/libexec' \
81                            '$$prefix/dynlib' \
82                            '$(INPLACE_DATA_DIR)' \
83                            '$$prefix/doc' \
84                            '$$prefix/html' \
85                            '$$prefix/haddock' \
86                            --distpref dist-stage$* \
87                            $(INSTALL_FLAGS)
88
89 # XXX For now we always install the stage 2 compiler
90 install:
91         $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
92                            '$(prefix)' '$(bindir)' '$(libdir)'            \
93                        '$(libexecdir)' '$(dynlibdir)' '$(datadir)'    \
94                        '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
95                            --distpref dist-stage2                         \
96                            $(INSTALL_FLAGS)
97
98 # XXX fix:
99 #binary-dist:
100 #       $(INSTALL_DIR)                      $(BIN_DIST_DIR)/utils/hsc2hs
101 #       $(INSTALL_DATA)    Makefile         $(BIN_DIST_DIR)/utils/hsc2hs/
102 #       $(INSTALL_DATA)    hsc2hs.sh        $(BIN_DIST_DIR)/utils/hsc2hs/
103 #       $(INSTALL_DATA)    $(INSTALL_DATAS) $(BIN_DIST_DIR)/utils/hsc2hs/
104 #       $(INSTALL_PROGRAM) $(HS_PROG)       $(BIN_DIST_DIR)/utils/hsc2hs/
105