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