312ab05bbe60c72cab496695b77db374e80245f5
[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 Eugh, can we do this better? The problem is making extra-gcc-opts
36 # infdable on both Linux and Windows. I guess this will go away when we
37 # drop the mangler?
38 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
39 SET_DATA_SUBDIR = --datasubdir=.
40 INPLACE_DATA_DIR = '$$prefix'
41 else
42 SET_DATA_SUBDIR =
43 INPLACE_DATA_DIR = '$$prefix/data'
44 endif
45
46 CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
47
48 ifeq "$(GhcWithInterpreter)" "YES"
49 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
50 else
51 CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
52 endif
53
54 ifeq "$(GhcProfiled)" "YES"
55 CONFIGURE_FLAGS_STAGE2 += --enable-executable-profiling
56 endif
57 ifeq "$(GhcDebugged)" "YES"
58 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-debug
59 endif
60 ifeq "$(GhcThreaded)" "YES"
61 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
62 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
63 endif
64
65 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
66
67 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
68 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
69 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
70
71 # XXX In stage2+ we should really use the inplace ghc-pkg
72 # It works because installPackage doesn't actually use ghc-pkg, as there's
73 # no library to register
74
75 boot.stage.%:
76         $(CABAL) configure --distpref dist-stage$* \
77                            $(SET_DATA_SUBDIR) \
78                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
79                            $(CONFIGURE_FLAGS_STAGE$*) \
80                            $(COMMON_CONFIGURE_FLAGS)
81
82 build.stage.%:
83         $(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
84         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
85                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \
86                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \
87                            '$$prefix/bin' \
88                            '$$prefix/lib' \
89                            '$$prefix/libexec' \
90                            '$$prefix/dynlib' \
91                            $(INPLACE_DATA_DIR) \
92                            '$$prefix/doc' \
93                            '$$prefix/html' \
94                            '$$prefix/haddock' \
95                            --distpref dist-stage$* \
96                            $(INSTALL_FLAGS)
97
98 # XXX For now we always install the stage 2 compiler
99 install:
100         $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
101                            '$(prefix)' '$(bindir)' '$(libdir)'            \
102                        '$(libexecdir)' '$(dynlibdir)' '$(datadir)'    \
103                        '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
104                            --distpref dist-stage2                         \
105                            $(INSTALL_FLAGS)
106
107 # XXX fix:
108 #binary-dist:
109 #       $(INSTALL_DIR)                      $(BIN_DIST_DIR)/utils/hsc2hs
110 #       $(INSTALL_DATA)    Makefile         $(BIN_DIST_DIR)/utils/hsc2hs/
111 #       $(INSTALL_DATA)    hsc2hs.sh        $(BIN_DIST_DIR)/utils/hsc2hs/
112 #       $(INSTALL_DATA)    $(INSTALL_DATAS) $(BIN_DIST_DIR)/utils/hsc2hs/
113 #       $(INSTALL_PROGRAM) $(HS_PROG)       $(BIN_DIST_DIR)/utils/hsc2hs/
114