allow EXTRA_HC_OPTS to be used from the command-line
[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 rebuild ::
21         -$(CABAL) clean --distpref dist-stage$(stage)
22         $(RM) -rf stage$(stage)-inplace
23         $(MAKE) boot all
24
25 stage1 ::
26         $(MAKE) stage=1
27
28 stage2 ::
29         $(MAKE) stage=2
30
31 stage3 ::
32         $(MAKE) stage=3
33
34 clean distclean::
35         -$(CABAL) clean --distpref dist-stage1
36         -$(CABAL) clean --distpref dist-stage2
37         -$(CABAL) clean --distpref dist-stage3
38         $(RM) -rf stage1-inplace
39         $(RM) -rf stage2-inplace
40         $(RM) -rf stage3-inplace
41
42 # XXX This should be defined somewhere more central
43 INPLACE_DATA_DIR = $(FPTOOLS_TOP_ABS)/inplace-datadir
44
45 CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
46
47 ifeq "$(GhcWithInterpreter)" "YES"
48 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
49 else
50 CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
51 endif
52
53 ifeq "$(GhcProfiled)" "YES"
54 CONFIGURE_FLAGS_STAGE2 += --enable-executable-profiling
55 endif
56 ifeq "$(GhcDebugged)" "YES"
57 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-debug
58 endif
59 ifeq "$(GhcThreaded)" "YES"
60 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
61 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
62 endif
63
64 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
65
66 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
67 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
68 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
69
70 # Allow EXTRA_HC_OPTS to be used from the command line to add options 
71 # when building (e.g. -v)
72 BUILD_FLAGS=$(patsubst %, --ghc-option=%, $(EXTRA_HC_OPTS))
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 boot.stage.%:
79         $(CABAL) configure --distpref dist-stage$*         \
80                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
81                            $(CONFIGURE_FLAGS_STAGE$*)      \
82                            $(COMMON_CONFIGURE_FLAGS)       \
83                            --libsubdir=.                   \
84                            --datadir='$$libdir'            \
85                            --datasubdir=.
86
87 build.stage.%:
88         $(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
89         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
90                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
91                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
92                            '$$prefix'                                      \
93                            '$(INPLACE_DATA_DIR)'                           \
94                            '$$prefix/libexec'                              \
95                            '$$prefix/dynlib'                               \
96                            '$(INPLACE_DATA_DIR)'                           \
97                            '$$prefix/doc'                                  \
98                            '$$prefix/html'                                 \
99                            '$$prefix/haddock'                              \
100                            --distpref dist-stage$*                         \
101                            $(INSTALL_FLAGS)
102
103 # XXX For now we always install the stage 2 compiler
104 install:
105         $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
106                            '$(prefix)' '$(bindir)' '$(libdir)'            \
107                        '$(libexecdir)' '$(dynlibdir)' '$(libdir)'     \
108                        '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
109                            --distpref dist-stage2                         \
110                            $(INSTALL_FLAGS)
111
112 # XXX fix:
113 #binary-dist:
114 #       $(INSTALL_DIR)                      $(BIN_DIST_DIR)/utils/hsc2hs
115 #       $(INSTALL_DATA)    Makefile         $(BIN_DIST_DIR)/utils/hsc2hs/
116 #       $(INSTALL_DATA)    hsc2hs.sh        $(BIN_DIST_DIR)/utils/hsc2hs/
117 #       $(INSTALL_DATA)    $(INSTALL_DATAS) $(BIN_DIST_DIR)/utils/hsc2hs/
118 #       $(INSTALL_PROGRAM) $(HS_PROG)       $(BIN_DIST_DIR)/utils/hsc2hs/
119