Implement forward substitution of constants in the Cmm mini-inliner
[ghc-hetmet.git] / compiler / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # -----------------------------------------------------------------------------
14 # For expressing extra dependencies on source files
15
16 define compiler-hs-dependency # args: $1 = module, $2 = dependency
17
18 $$(foreach stage,1 2 3,\
19  $$(foreach way,$$(compiler_stage$$(stage)_WAYS),\
20   compiler/stage$$(stage)/build/$1.$$($$(way)_osuf))) : $2
21
22 endef
23
24 # -----------------------------------------------------------------------------
25 # Create compiler configuration
26 #
27 # The 'echo' commands simply spit the values of various make variables
28 # into Config.hs, whence they can be compiled and used by GHC itself
29
30 compiler_CONFIG_HS = compiler/main/Config.hs
31
32 # This is just to avoid generating a warning when generating deps
33 # involving RtsFlags.h
34 compiler_stage1_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
35 compiler_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
36 compiler_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
37
38 compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
39
40 ifneq "$(BINDIST)" "YES"
41 compiler/stage1/package-data.mk : compiler/stage1/build/Config.hs
42 compiler/stage2/package-data.mk : compiler/stage2/build/Config.hs
43 compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs
44 endif
45
46 compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
47         "$(RM)" $(RM_OPTS) $@
48         @echo 'Creating $@ ... '
49         @echo '{-# LANGUAGE CPP #-}'                                        >> $@
50         @echo 'module Config where'                                         >> $@
51         @echo                                                               >> $@
52         @echo '#include "ghc_boot_platform.h"'                              >> $@
53         @echo                                                               >> $@
54         @echo 'cBuildPlatformString :: String'                              >> $@
55         @echo 'cBuildPlatformString = BuildPlatform_NAME'                   >> $@
56         @echo 'cHostPlatformString :: String'                               >> $@
57         @echo 'cHostPlatformString = HostPlatform_NAME'                     >> $@
58         @echo 'cTargetPlatformString :: String'                             >> $@
59         @echo 'cTargetPlatformString = TargetPlatform_NAME'                 >> $@
60         @echo                                                               >> $@
61         @echo 'cProjectName          :: String'                             >> $@
62         @echo 'cProjectName          = "$(ProjectName)"'                    >> $@
63         @echo 'cProjectVersion       :: String'                             >> $@
64         @echo 'cProjectVersion       = "$(ProjectVersion)"'                 >> $@
65         @echo 'cProjectVersionInt    :: String'                             >> $@
66         @echo 'cProjectVersionInt    = "$(ProjectVersionInt)"'              >> $@
67         @echo 'cProjectPatchLevel    :: String'                             >> $@
68         @echo 'cProjectPatchLevel    = "$(ProjectPatchLevel)"'              >> $@
69         @echo 'cBooterVersion        :: String'                             >> $@
70         @echo 'cBooterVersion        = "$(GhcVersion)"'                     >> $@
71         @echo 'cStage                :: String'                             >> $@
72         @echo 'cStage                = show (STAGE :: Int)'                 >> $@
73         @echo 'cGccLinkerOpts        :: [String]'                           >> $@
74         @echo 'cGccLinkerOpts        = words "$(CONF_GCC_LINKER_OPTS_STAGE$*)"' >> $@
75         @echo 'cLdLinkerOpts         :: [String]'                           >> $@
76         @echo 'cLdLinkerOpts         = words "$(CONF_LD_LINKER_OPTS_STAGE$*)"'  >> $@
77         @echo 'cIntegerLibrary       :: String'                             >> $@
78         @echo 'cIntegerLibrary       = "$(INTEGER_LIBRARY)"'                >> $@
79         @echo 'cSupportsSplitObjs    :: String'                             >> $@
80         @echo 'cSupportsSplitObjs    = "$(SupportsSplitObjs)"'              >> $@
81         @echo 'cGhcWithInterpreter   :: String'                             >> $@
82         @echo 'cGhcWithInterpreter   = "$(GhcWithInterpreter)"'             >> $@
83         @echo 'cGhcWithNativeCodeGen :: String'                             >> $@
84         @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"'           >> $@
85         @echo 'cGhcWithSMP           :: String'                             >> $@
86         @echo 'cGhcWithSMP           = "$(GhcWithSMP)"'                     >> $@
87         @echo 'cGhcRTSWays           :: String'                             >> $@
88         @echo 'cGhcRTSWays           = "$(GhcRTSWays)"'                     >> $@
89         @echo 'cGhcUnregisterised    :: String'                             >> $@
90         @echo 'cGhcUnregisterised    = "$(GhcUnregisterised)"'              >> $@
91         @echo 'cGhcEnableTablesNextToCode :: String'                        >> $@
92         @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
93         @echo 'cLeadingUnderscore    :: String'                             >> $@
94         @echo 'cLeadingUnderscore    = "$(LeadingUnderscore)"'              >> $@
95         @echo 'cRAWCPP_FLAGS         :: String'                             >> $@
96         @echo 'cRAWCPP_FLAGS         = "$(RAWCPP_FLAGS)"'                   >> $@
97         @echo 'cMKDLL                :: String'                             >> $@
98         @echo 'cMKDLL                = "$(BLD_DLL)"'                        >> $@
99         @echo 'cLdIsGNULd            :: String'                             >> $@
100         @echo 'cLdIsGNULd            = "$(LdIsGNULd)"'                      >> $@
101         @echo 'cLdHasBuildId         :: String'                             >> $@
102         @echo 'cLdHasBuildId         = "$(LdHasBuildId)"'                   >> $@
103         @echo 'cLD_X                 :: String'                             >> $@
104         @echo 'cLD_X                 = "$(LD_X)"'                           >> $@
105         @echo 'cGHC_DRIVER_DIR       :: String'                             >> $@
106         @echo 'cGHC_DRIVER_DIR       = "$(GHC_DRIVER_DIR)"'                 >> $@
107         @echo 'cGHC_TOUCHY_PGM       :: String'                             >> $@
108         @echo 'cGHC_TOUCHY_PGM       = "$(GHC_TOUCHY_PGM)"'                 >> $@
109         @echo 'cGHC_TOUCHY_DIR       :: String'                             >> $@
110         @echo 'cGHC_TOUCHY_DIR       = "$(GHC_TOUCHY_DIR)"'                 >> $@
111         @echo 'cGHC_UNLIT_PGM        :: String'                             >> $@
112         @echo 'cGHC_UNLIT_PGM        = "$(GHC_UNLIT_PGM)"'                  >> $@
113         @echo 'cGHC_UNLIT_DIR        :: String'                             >> $@
114         @echo 'cGHC_UNLIT_DIR        = "$(GHC_UNLIT_DIR)"'                  >> $@
115         @echo 'cGHC_SPLIT_PGM        :: String'                             >> $@
116         @echo 'cGHC_SPLIT_PGM        = "$(GHC_SPLIT_PGM)"'                  >> $@
117         @echo 'cGHC_SPLIT_DIR        :: String'                             >> $@
118         @echo 'cGHC_SPLIT_DIR        = "$(GHC_SPLIT_DIR)"'                  >> $@
119         @echo 'cGHC_SYSMAN_PGM       :: String'                             >> $@
120         @echo 'cGHC_SYSMAN_PGM       = "$(GHC_SYSMAN)"'                     >> $@
121         @echo 'cGHC_SYSMAN_DIR       :: String'                             >> $@
122         @echo 'cGHC_SYSMAN_DIR       = "$(GHC_SYSMAN_DIR)"'                 >> $@
123         @echo 'cDEFAULT_TMPDIR       :: String'                             >> $@
124         @echo 'cDEFAULT_TMPDIR       = "$(DEFAULT_TMPDIR)"'                 >> $@
125         @echo 'cRelocatableBuild     :: Bool'                               >> $@
126 ifeq "$(RelocatableBuild)" "YES"
127         @echo 'cRelocatableBuild     = True'                                >> $@
128 else
129         @echo 'cRelocatableBuild     = False'                               >> $@
130 endif
131         @echo 'cLibFFI               :: Bool'                               >> $@
132 ifeq "$(UseLibFFIForAdjustors)" "YES"
133         @echo 'cLibFFI               = True'                                >> $@
134 else
135         @echo 'cLibFFI               = False'                               >> $@
136 endif
137         @echo done.
138
139 # XXX 2010-08-19: This is a legacy clean. Remove later.
140 $(eval $(call clean-target,compiler,config_hs,compiler/main/Config.hs))
141
142 # -----------------------------------------------------------------------------
143 # Create platform includes
144
145 # Here we generate a little header file containing CPP symbols that GHC
146 # uses to determine which platform it is building on/for.  The platforms
147 # can differ between stage1 and stage2 if we're cross-compiling, so we
148 # need one of these header files per stage.
149
150 PLATFORM_H = ghc_boot_platform.h
151
152 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
153         "$(RM)" $(RM_OPTS) $@
154         @echo "Creating $@..."
155         @echo "#ifndef __PLATFORM_H__"                           >> $@
156         @echo "#define __PLATFORM_H__"                           >> $@
157         @echo                                                    >> $@
158         @echo "#define BuildPlatform_NAME  \"$(BUILDPLATFORM)\"" >> $@
159         @echo "#define HostPlatform_NAME   \"$(BUILDPLATFORM)\"" >> $@
160         @echo "#define TargetPlatform_NAME \"$(HOSTPLATFORM)\""  >> $@
161         @echo                                                    >> $@
162         @echo "#define $(BuildPlatform_CPP)_BUILD 1"             >> $@
163         @echo "#define $(BuildPlatform_CPP)_HOST 1"              >> $@
164         @echo "#define $(HostPlatform_CPP)_TARGET 1"             >> $@
165         @echo                                                    >> $@
166         @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1"            >> $@
167         @echo "#define $(BuildArch_CPP)_HOST_ARCH 1"             >> $@
168         @echo "#define $(HostArch_CPP)_TARGET_ARCH 1"            >> $@
169         @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\""          >> $@
170         @echo "#define HOST_ARCH \"$(BuildArch_CPP)\""           >> $@
171         @echo "#define TARGET_ARCH \"$(HostArch_CPP)\""          >> $@
172         @echo                                                    >> $@
173         @echo "#define $(BuildOS_CPP)_BUILD_OS 1"                >> $@
174         @echo "#define $(BuildOS_CPP)_HOST_OS 1"                 >> $@
175         @echo "#define $(HostOS_CPP)_TARGET_OS 1"                >> $@
176         @echo "#define BUILD_OS \"$(BuildOS_CPP)\""              >> $@
177         @echo "#define HOST_OS \"$(BuildOS_CPP)\""               >> $@
178         @echo "#define TARGET_OS \"$(HostOS_CPP)\""              >> $@
179 ifeq "$(HostOS_CPP)" "irix"
180         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS"                  >> $@
181         @echo "#define $(IRIX_MAJOR)_TARGET_OS 1"                >> $@
182         @echo "#endif"                                           >> $@
183 endif
184         @echo                                                    >> $@
185         @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1"        >> $@
186         @echo "#define $(BuildVendor_CPP)_HOST_VENDOR 1"         >> $@
187         @echo "#define $(HostVendor_CPP)_TARGET_VENDOR 1"        >> $@
188         @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\""      >> $@
189         @echo "#define HOST_VENDOR \"$(BuildVendor_CPP)\""       >> $@
190         @echo "#define TARGET_VENDOR \"$(HostVendor_CPP)\""      >> $@
191         @echo                                                    >> $@
192         @echo "#endif /* __PLATFORM_H__ */"                      >> $@
193         @echo "Done."
194
195 # For stage2 and above, the BUILD platform is the HOST of stage1, and
196 # the HOST platform is the TARGET of stage1.  The TARGET remains the same
197 # (stage1 is the cross-compiler, not stage2).
198 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
199         "$(RM)" $(RM_OPTS) $@
200         @echo "Creating $@..."
201         @echo "#ifndef __PLATFORM_H__"                            >> $@
202         @echo "#define __PLATFORM_H__"                            >> $@
203         @echo                                                     >> $@
204         @echo "#define BuildPlatform_NAME  \"$(BUILDPLATFORM)\""  >> $@
205         @echo "#define HostPlatform_NAME   \"$(HOSTPLATFORM)\""   >> $@
206         @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
207         @echo                                                     >> $@
208         @echo "#define $(BuildPlatform_CPP)_BUILD 1"              >> $@
209         @echo "#define $(HostPlatform_CPP)_HOST 1"                >> $@
210         @echo "#define $(TargetPlatform_CPP)_TARGET 1"            >> $@
211         @echo                                                     >> $@
212         @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1"             >> $@
213         @echo "#define $(HostArch_CPP)_HOST_ARCH 1"               >> $@
214         @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1"           >> $@
215         @echo "#define BUILD_ARCH \"$(HostArch_CPP)\""            >> $@
216         @echo "#define HOST_ARCH \"$(HostArch_CPP)\""             >> $@
217         @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\""         >> $@
218         @echo                                                     >> $@
219         @echo "#define $(HostOS_CPP)_BUILD_OS 1"                  >> $@
220         @echo "#define $(HostOS_CPP)_HOST_OS 1"                   >> $@
221         @echo "#define $(TargetOS_CPP)_TARGET_OS 1"               >> $@
222         @echo "#define BUILD_OS \"$(HostOS_CPP)\""                >> $@
223         @echo "#define HOST_OS \"$(HostOS_CPP)\""                 >> $@
224         @echo "#define TARGET_OS \"$(TargetOS_CPP)\""             >> $@
225 ifeq "$(TargetOS_CPP)" "irix"
226         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS"                   >> $@
227         @echo "#define $(IRIX_MAJOR)_TARGET_OS 1"                 >> $@
228         @echo "#endif"                                            >> $@
229 endif
230         @echo                                                     >> $@
231         @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1"         >> $@
232         @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1"           >> $@
233         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1"      >> $@
234         @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\""       >> $@
235         @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\""         >> $@
236         @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\""     >> $@
237         @echo                                                     >> $@
238         @echo "#endif /* __PLATFORM_H__ */"                       >> $@
239         @echo "Done."
240
241 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
242         "$(CP)" $< $@
243
244 # ----------------------------------------------------------------------------
245 #               Generate supporting stuff for prelude/PrimOp.lhs 
246 #               from prelude/primops.txt
247
248 # XXX: these should go in stage1/stage2/stage3
249 PRIMOP_BITS = compiler/primop-data-decl.hs-incl        \
250               compiler/primop-tag.hs-incl              \
251               compiler/primop-list.hs-incl             \
252               compiler/primop-has-side-effects.hs-incl \
253               compiler/primop-out-of-line.hs-incl      \
254               compiler/primop-commutable.hs-incl       \
255               compiler/primop-code-size.hs-incl        \
256               compiler/primop-can-fail.hs-incl         \
257               compiler/primop-strictness.hs-incl       \
258               compiler/primop-primop-info.hs-incl
259
260 compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
261 compiler_CPP_OPTS += ${GhcCppOpts}
262
263 $(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
264         $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
265
266 $(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS)))
267
268 ifneq "$(BootingFromHc)" "YES"
269 compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
270         "$(GENPRIMOP_INPLACE)" --data-decl          < $< > $@
271 compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
272         "$(GENPRIMOP_INPLACE)" --primop-tag         < $< > $@
273 compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
274         "$(GENPRIMOP_INPLACE)" --primop-list        < $< > $@
275 compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
276         "$(GENPRIMOP_INPLACE)" --has-side-effects   < $< > $@
277 compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
278         "$(GENPRIMOP_INPLACE)" --out-of-line        < $< > $@
279 compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
280         "$(GENPRIMOP_INPLACE)" --commutable         < $< > $@
281 compiler/primop-code-size.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
282         "$(GENPRIMOP_INPLACE)" --code-size          < $< > $@
283 compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
284         "$(GENPRIMOP_INPLACE)" --can-fail           < $< > $@
285 compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
286         "$(GENPRIMOP_INPLACE)" --strictness         < $< > $@
287 compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
288         "$(GENPRIMOP_INPLACE)" --primop-primop-info < $< > $@
289
290 # Usages aren't used any more; but the generator 
291 # can still generate them if we want them back
292 compiler/primop-usage.hs-incl: $(PRIMOPS_TXT)
293         "$(GENPRIMOP_INPLACE)" --usage              < $< > $@
294 endif
295
296 # -----------------------------------------------------------------------------
297 # Configuration
298
299 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
300 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
301 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
302
303 ifeq "$(GhcWithNativeCodeGen)" "YES"
304 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
305 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
306 endif
307
308 ifeq "$(GhcWithInterpreter)" "YES"
309 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
310
311 ifeq "$(BuildSharedLibs)" "YES"
312 compiler_stage2_CONFIGURE_OPTS += --enable-shared
313 # If we are going to use dynamic libraries instead of .o files for ghci,
314 # we will need to always retain CAFs in the compiler.
315 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
316 # function which sets the keepCAFs flag for the RTS before any Haskell
317 # code is run.
318 compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs
319 endif
320
321 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
322 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
323 # or not?
324 # XXX This should logically be a CPP option, but there doesn't seem to
325 # be a flag for that
326 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
327 endif
328
329 # Should the debugger commands be enabled?
330 ifeq "$(GhciWithDebugger)" "YES"
331 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
332 endif
333
334 endif
335
336 ifeq "$(TargetOS_CPP)" "openbsd"
337 compiler_CONFIGURE_OPTS += --ld-options=-E
338 endif
339
340 ifeq "$(GhcUnregisterised)" "NO"
341 else
342 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
343 endif
344
345 # If we're profiling GHC then we want lots of SCCs, so -auto-all
346 # We also don't want to waste time building the non-profiling library.
347 # Unfortunately this means that we have to tell ghc-pkg --force as it
348 # gets upset when libHSghc-6.9.a doesn't exist.
349 ifeq "$(GhcProfiled)" "YES"
350 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
351 # We seem to still build the vanilla libraries even if we say
352 # --disable-library-vanilla, but installation then fails, as Cabal
353 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
354 # their absence when we register the package. So for now, we just
355 # leave the vanilla libraries enabled.
356 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
357 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
358 endif
359
360 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
361
362 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
363 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
364 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
365 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
366
367 compiler/stage1/package-data.mk : compiler/ghc.mk
368 compiler/stage2/package-data.mk : compiler/ghc.mk
369 compiler/stage3/package-data.mk : compiler/ghc.mk
370
371 # -----------------------------------------------------------------------------
372 # And build the package
373
374 compiler_PACKAGE = ghc
375
376 # Note [fiddle-stage1-version]
377 # The version of the GHC package changes every day, since the
378 # patchlevel is the current date.  We don't want to force
379 # recompilation of the entire compiler when this happens, so for stage
380 # 1 we omit the patchlevel from the version number.  For stage 2 we
381 # have to include the patchlevel since this is the package we install,
382 # however.
383 #
384 # Note: we also have to tweak the version number of the package itself
385 # when it gets registered; see Note [munge-stage1-package-config]
386 # below.
387 # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
388 # then we don't want to remove it
389 ifneq "$(CLEANING)" "YES"
390 ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
391 compiler_stage1_VERSION_MUNGED = YES
392 endif
393 endif
394
395 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
396 define compiler_PACKAGE_MAGIC
397 compiler_stage1_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
398 endef
399
400 # Don't register the non-munged package
401 compiler_stage1_REGISTER_PACKAGE = NO
402
403 endif
404
405 # haddocking only happens for stage2
406 compiler_stage1_DO_HADDOCK = NO
407 compiler_stage3_DO_HADDOCK = NO
408
409 # Don't do splitting for the GHC package, it takes too long and
410 # there's not much benefit.
411 compiler_stage1_SplitObjs = NO
412 compiler_stage2_SplitObjs = NO
413 compiler_stage3_SplitObjs = NO
414
415 # if stage is set to something other than "1" or "", disable stage 1
416 ifneq "$(filter-out 1,$(stage))" ""
417 compiler_stage1_NOT_NEEDED = YES
418 endif
419 # if stage is set to something other than "2" or "", disable stage 2
420 ifneq "$(filter-out 2,$(stage))" ""
421 compiler_stage2_NOT_NEEDED = YES
422 endif
423 # stage 3 has to be requested explicitly with stage=3
424 ifneq "$(stage)" "3"
425 compiler_stage3_NOT_NEEDED = YES
426 endif
427 $(eval $(call build-package,compiler,stage1,0))
428 $(eval $(call build-package,compiler,stage2,1))
429 $(eval $(call build-package,compiler,stage3,2))
430
431 # after build-package, because that adds --enable-library-for-ghci
432 # to compiler_stage*_CONFIGURE_OPTS:
433 # We don't build the GHCi library for the ghc package. We can load it
434 # the .a file instead, and as object splitting isn't on for the ghc
435 # package this isn't much slower.However, not building the package saves
436 # a significant chunk of disk space.
437 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
438 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
439 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
440
441 # after build-package, because that sets compiler_stage1_HC_OPTS:
442 compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
443 compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
444 compiler_stage3_HC_OPTS += $(GhcStage3HcOpts)
445
446 ifeq "$(GhcStage1DefaultNewCodegen)" "YES"
447 compiler_stage1_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
448 endif
449
450 ifeq "$(GhcStage2DefaultNewCodegen)" "YES"
451 compiler_stage2_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
452 endif
453
454 ifeq "$(GhcStage3DefaultNewCodegen)" "YES"
455 compiler_stage3_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
456 endif
457
458 ifneq "$(BINDIST)" "YES"
459
460 compiler_stage2_TAGS_HC_OPTS = -package ghc
461 $(eval $(call tags-package,compiler,stage2))
462
463 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
464 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
465 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
466
467 $(compiler_stage1_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
468 $(compiler_stage2_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
469 $(compiler_stage3_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
470
471 # Every Constants.o object file depends on includes/GHCConstants.h:
472 $(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS) includes/HaskellConstants.hs))
473
474 # Every PrimOp.o object file depends on $(PRIMOP_BITS):
475 $(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS)))
476
477 # GHC itself doesn't know about the above dependencies, so we have to
478 # switch off the recompilation checker for those modules:
479 compiler/prelude/PrimOp_HC_OPTS  += -fforce-recomp
480 compiler/main/Constants_HC_OPTS  += -fforce-recomp
481
482 # Workaround for #4003 in GHC 6.12.2.  It didn't happen in 6.12.1, and
483 # will be fixed in 6.12.3.  Unfortunately we don't have a way to do
484 # this for just stage1 in the build system.
485 ifeq "$(GhcVersion)" "6.12.2"
486 compiler/hsSyn/HsLit_HC_OPTS     += -fomit-interface-pragmas
487 endif
488
489 # Note [munge-stage1-package-config]
490 # Strip the date/patchlevel from the version of stage1.  See Note
491 # [fiddle-stage1-version] above.
492 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
493 compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
494         sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
495             -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
496             -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
497           < $< > $@
498         "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
499
500 # We need to make sure the munged config is in the database before we
501 # try to configure ghc-bin
502 ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged
503 endif
504
505 endif
506