Fix SPARC build, missing #include
[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
38 ifeq "$(CLEAN_ALL_STAGES)" "YES"
39 clean distclean maintainer-clean:: clean.stage.1 clean.stage.2 clean.stage.3
40 else
41 clean distclean maintainer-clean:: clean.stage.$(stage)
42 endif
43
44 ifeq "$(CLEAN_ALL_STAGES)" "YES"
45 distclean maintainer-clean::
46         $(RM) -f ghc-bin.cabal
47 endif
48
49 clean.stage.%:
50         $(RM) -rf stage$*-inplace
51 # This is a bit naughty. We ought to use:
52 #       -$(CABAL) clean --distpref dist-stage$*
53 # but that won't work if the Cabal file (a generated file) doesn't
54 # exist. So we do this instead:
55         $(RM) -rf dist-stage$*
56
57 CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
58
59 ifeq "$(GhcWithInterpreter)" "YES"
60 CONFIGURE_FLAGS_STAGE2PLUS += --flags=ghci
61 else
62 CONFIGURE_FLAGS_STAGE2PLUS += --flags=-ghci
63 endif
64
65 ifeq "$(GhcProfiled)" "YES"
66 CONFIGURE_FLAGS_STAGE2PLUS += --enable-executable-profiling
67 endif
68 ifeq "$(GhcDebugged)" "YES"
69 CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-debug
70 endif
71 ifeq "$(GhcThreaded)" "YES"
72 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
73 CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-threaded
74 endif
75
76 ifeq "$(BuildSharedLibs)" "YES"
77 CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-dynamic
78 endif
79
80 CONFIGURE_FLAGS_STAGE2 = $(CONFIGURE_FLAGS_STAGE2PLUS)
81 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2PLUS)
82
83 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
84 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
85 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
86 CONFIGURE_FLAGS_STAGE3 += --package-db $(STAGE3_PACKAGE_CONF)
87
88 CONFIGURE_FLAGS_STAGE1 += $(foreach flag, $(GhcStage1HcOpts), --ghc-option=$(flag))
89 CONFIGURE_FLAGS_STAGE2 += $(foreach flag, $(GhcStage2HcOpts), --ghc-option=$(flag))
90 CONFIGURE_FLAGS_STAGE3 += $(foreach flag, $(GhcStage3HcOpts), --ghc-option=$(flag))
91
92 BUILD_FLAGS += $(patsubst %, --ghc-option=%, $(SRC_HC_OPTS))
93 # Allow EXTRA_HC_OPTS to be used from the command line to add options 
94 # when building (e.g. -v)
95 BUILD_FLAGS += $(patsubst %, --ghc-option=%, $(EXTRA_HC_OPTS))
96
97 # XXX In stage2+ we should really use the inplace ghc-pkg
98 # It works because installPackage doesn't actually use ghc-pkg, as there's
99 # no library to register
100
101 ifeq "$(stage)" "1"
102 ifeq "$(ghc_ge_609)" "NO"
103 # GHC 6.9+ can handle cross-package recompilation checking, but
104 # we don't rely on the bootstrapping compiler being able to do this.
105 TOUCH_MAIN = $(RM) dist-stage1/build/ghc/ghc-tmp/Main.o
106 endif
107 endif
108
109 dist-stage1 dist-stage2 dist-stage3: dist-stage%: boot.stage.%
110
111 boot.stage.%:
112         $(CABAL) configure --distpref dist-stage$*         \
113                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
114                            $(CONFIGURE_FLAGS_STAGE$*)      \
115                            $(COMMON_CONFIGURE_FLAGS)       \
116                            --libsubdir=.                   \
117                            --datadir='$$libdir'            \
118                            --datasubdir=.
119
120 build.stage.%: dist-stage%
121         $(TOUCH_MAIN)
122         $(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
123         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
124                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
125                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
126                            '$$prefix'                                      \
127                            '$(INPLACE_DATA_DIR)'                           \
128                            '$$prefix/libexec'                              \
129                            '$$prefix/dynlib'                               \
130                            '$(INPLACE_DATA_DIR)'                           \
131                            '$$prefix/doc'                                  \
132                            '$$prefix/html'                                 \
133                            '$$prefix/haddock'                              \
134                            --distpref dist-stage$*                         \
135                            $(INPLACE_INSTALL_FLAGS)                        \
136                            $(INSTALL_FLAGS)
137
138 # XXX For now we always install the stage 2 compiler
139 install:
140         $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
141                            '$(prefix)' '$(bindir)' '$(libdir)'            \
142                        '$(libexecdir)' '$(dynlibdir)' '$(datadir)'    \
143                        '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
144                            --distpref dist-stage2                         \
145                            $(INSTALL_FLAGS)
146
147 html:
148         @:
149
150 install-docs:
151         @:
152
153 include $(TOP)/mk/bindist.mk
154 EXE_DIST_DIR = dist-stage2
155