We need to give make some more clues
[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 # Don't strip the inplace versions, we might need to debug them
17 INPLACE_INSTALL_FLAGS += --disable-executable-stripping
18
19 boot:: boot.stage.$(stage)
20
21 all:: build.stage.$(stage)
22
23 rebuild ::
24         -$(CABAL) clean --distpref dist-stage$(stage)
25         $(RM) -rf stage$(stage)-inplace
26         $(MAKE) boot all
27
28 stage1 ::
29         $(MAKE) stage=1
30
31 stage2 ::
32         $(MAKE) stage=2
33
34 stage3 ::
35         $(MAKE) stage=3
36
37 ifeq "$(CLEAN_ALL_STAGES)" "YES"
38 clean distclean:: clean.stage.1 clean.stage.2 clean.stage.3
39 else
40 clean distclean:: clean.stage.$(stage)
41 endif
42
43 clean.stage.%:
44         -$(CABAL) clean --distpref dist-stage$*
45         $(RM) -rf stage$*-inplace
46
47 CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
48
49 ifeq "$(GhcWithInterpreter)" "YES"
50 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
51 else
52 CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
53 endif
54
55 ifeq "$(GhcProfiled)" "YES"
56 CONFIGURE_FLAGS_STAGE2 += --enable-executable-profiling
57 endif
58 ifeq "$(GhcDebugged)" "YES"
59 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-debug
60 endif
61 ifeq "$(GhcThreaded)" "YES"
62 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
63 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
64 endif
65
66 ifeq "$(BuildSharedLibs)" "YES"
67 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-dynamic
68 endif
69
70 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
71
72 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
73 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
74 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
75
76 # Allow EXTRA_HC_OPTS to be used from the command line to add options 
77 # when building (e.g. -v)
78 BUILD_FLAGS=$(patsubst %, --ghc-option=%, $(EXTRA_HC_OPTS))
79
80 # XXX In stage2+ we should really use the inplace ghc-pkg
81 # It works because installPackage doesn't actually use ghc-pkg, as there's
82 # no library to register
83
84 ifeq "$(stage)" "1"
85 ifeq "$(ghc_ge_609)" "NO"
86 # GHC 6.9+ can handle cross-package recompilation checking, but
87 # we don't rely on the bootstrapping compiler being able to do this.
88 TOUCH_MAIN = $(RM) dist-stage1/build/ghc/ghc-tmp/Main.o
89 endif
90 endif
91
92 dist-stage1 dist-stage2 dist-stage3: dist-stage%: boot.stage.%
93
94 boot.stage.%:
95         $(CABAL) configure --distpref dist-stage$*         \
96                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
97                            $(CONFIGURE_FLAGS_STAGE$*)      \
98                            $(COMMON_CONFIGURE_FLAGS)       \
99                            --libsubdir=.                   \
100                            --datadir='$$libdir'            \
101                            --datasubdir=.
102
103 build.stage.%: dist-stage%
104         $(TOUCH_MAIN)
105         $(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
106         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
107                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
108                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
109                            '$$prefix'                                      \
110                            '$(INPLACE_DATA_DIR)'                           \
111                            '$$prefix/libexec'                              \
112                            '$$prefix/dynlib'                               \
113                            '$(INPLACE_DATA_DIR)'                           \
114                            '$$prefix/doc'                                  \
115                            '$$prefix/html'                                 \
116                            '$$prefix/haddock'                              \
117                            --distpref dist-stage$*                         \
118                            $(INPLACE_INSTALL_FLAGS)                        \
119                            $(INSTALL_FLAGS)
120
121 # XXX For now we always install the stage 2 compiler
122 install:
123         $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
124                            '$(prefix)' '$(bindir)' '$(libdir)'            \
125                        '$(libexecdir)' '$(dynlibdir)' '$(datadir)'    \
126                        '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
127                            --distpref dist-stage2                         \
128                            $(INSTALL_FLAGS)
129
130 include $(TOP)/mk/bindist.mk
131 EXE_DIST_DIR = dist-stage$(stage)
132