1
# -----------------------------------------------------------------------------
3
# (c) 2009 The University of Glasgow
5
# This file is part of the GHC build system.
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
11
# -----------------------------------------------------------------------------
13
# -----------------------------------------------------------------------------
14
# For expressing extra dependencies on source files
16
define compiler-hs-dependency # args: $1 = module, $2 = dependency
18
$$(foreach stage,1 2 3,\
19
$$(foreach way,$$(compiler_stage$$(stage)_WAYS),\
20
compiler/stage$$(stage)/build/$1.$$($$(way)_osuf))) : $2
24
# -----------------------------------------------------------------------------
25
# Create compiler configuration
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
30
compiler_CONFIG_HS = compiler/main/Config.hs
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
38
compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
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
46
compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
48
@echo 'Creating $@ ... '
49
@echo '{-# LANGUAGE CPP #-}' >> $@
50
@echo 'module Config where' >> $@
52
@echo '#include "ghc_boot_platform.h"' >> $@
54
@echo 'cBuildPlatform :: String' >> $@
55
@echo 'cBuildPlatform = BuildPlatform_NAME' >> $@
56
@echo 'cHostPlatform :: String' >> $@
57
@echo 'cHostPlatform = HostPlatform_NAME' >> $@
58
@echo 'cTargetPlatform :: String' >> $@
59
@echo 'cTargetPlatform = TargetPlatform_NAME' >> $@
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 'cCcOpts :: [String]' >> $@
74
@echo 'cCcOpts = words "$(CONF_CC_OPTS_STAGE$*)"' >> $@
75
@echo 'cLdOpts :: [String]' >> $@
76
@echo 'cLdOpts = words "$(CONF_LD_OPTS_STAGE$*)"' >> $@
77
@echo 'cIntegerLibrary :: String' >> $@
78
@echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
79
@echo 'cSplitObjs :: String' >> $@
80
@echo 'cSplitObjs = "$(SupportsSplitObjs)"' >> $@
81
@echo 'cGhcWithInterpreter :: String' >> $@
82
@echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
83
@echo 'cGhcWithNativeCodeGen :: String' >> $@
84
@echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
85
@echo 'cGhcWithLlvmCodeGen :: String' >> $@
86
@echo 'cGhcWithLlvmCodeGen = "YES"' >> $@
87
@echo 'cGhcWithSMP :: String' >> $@
88
@echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
89
@echo 'cGhcRTSWays :: String' >> $@
90
@echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
91
@echo 'cGhcUnregisterised :: String' >> $@
92
@echo 'cGhcUnregisterised = "$(GhcUnregisterised)"' >> $@
93
@echo 'cGhcEnableTablesNextToCode :: String' >> $@
94
@echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
95
@echo 'cLeadingUnderscore :: String' >> $@
96
@echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
97
@echo 'cRAWCPP_FLAGS :: String' >> $@
98
@echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@
99
@echo 'cGCC :: String' >> $@
100
@echo 'cGCC = "$(WhatGccIsCalled)"' >> $@
101
@echo 'cMKDLL :: String' >> $@
102
@echo 'cMKDLL = "$(BLD_DLL)"' >> $@
103
@echo 'cLdIsGNULd :: String' >> $@
104
@echo 'cLdIsGNULd = "$(LdIsGNULd)"' >> $@
105
@echo 'cLD_X :: String' >> $@
106
@echo 'cLD_X = "$(LD_X)"' >> $@
107
@echo 'cGHC_DRIVER_DIR :: String' >> $@
108
@echo 'cGHC_DRIVER_DIR = "$(GHC_DRIVER_DIR)"' >> $@
109
@echo 'cGHC_TOUCHY_PGM :: String' >> $@
110
@echo 'cGHC_TOUCHY_PGM = "$(GHC_TOUCHY_PGM)"' >> $@
111
@echo 'cGHC_TOUCHY_DIR :: String' >> $@
112
@echo 'cGHC_TOUCHY_DIR = "$(GHC_TOUCHY_DIR)"' >> $@
113
@echo 'cGHC_UNLIT_PGM :: String' >> $@
114
@echo 'cGHC_UNLIT_PGM = "$(GHC_UNLIT_PGM)"' >> $@
115
@echo 'cGHC_UNLIT_DIR :: String' >> $@
116
@echo 'cGHC_UNLIT_DIR = "$(GHC_UNLIT_DIR)"' >> $@
117
@echo 'cGHC_MANGLER_PGM :: String' >> $@
118
@echo 'cGHC_MANGLER_PGM = "$(GHC_MANGLER_PGM)"' >> $@
119
@echo 'cGHC_MANGLER_DIR :: String' >> $@
120
@echo 'cGHC_MANGLER_DIR = "$(GHC_MANGLER_DIR)"' >> $@
121
@echo 'cGHC_SPLIT_PGM :: String' >> $@
122
@echo 'cGHC_SPLIT_PGM = "$(GHC_SPLIT_PGM)"' >> $@
123
@echo 'cGHC_SPLIT_DIR :: String' >> $@
124
@echo 'cGHC_SPLIT_DIR = "$(GHC_SPLIT_DIR)"' >> $@
125
@echo 'cGHC_SYSMAN_PGM :: String' >> $@
126
@echo 'cGHC_SYSMAN_PGM = "$(GHC_SYSMAN)"' >> $@
127
@echo 'cGHC_SYSMAN_DIR :: String' >> $@
128
@echo 'cGHC_SYSMAN_DIR = "$(GHC_SYSMAN_DIR)"' >> $@
129
@echo 'cGHC_PERL :: String' >> $@
130
@echo 'cGHC_PERL = "$(GHC_PERL)"' >> $@
131
@echo 'cDEFAULT_TMPDIR :: String' >> $@
132
@echo 'cDEFAULT_TMPDIR = "$(DEFAULT_TMPDIR)"' >> $@
133
@echo 'cRelocatableBuild :: Bool' >> $@
134
ifeq "$(RelocatableBuild)" "YES"
135
@echo 'cRelocatableBuild = True' >> $@
137
@echo 'cRelocatableBuild = False' >> $@
139
@echo 'cUseArchivesForGhci :: Bool' >> $@
140
ifeq "$(UseArchivesForGhci)" "YES"
141
@echo 'cUseArchivesForGhci = True' >> $@
143
@echo 'cUseArchivesForGhci = False' >> $@
145
@echo 'cLibFFI :: Bool' >> $@
146
ifeq "$(UseLibFFIForAdjustors)" "YES"
147
@echo 'cLibFFI = True' >> $@
149
@echo 'cLibFFI = False' >> $@
153
# XXX 2010-08-19: This is a legacy clean. Remove later.
154
$(eval $(call clean-target,compiler,config_hs,compiler/main/Config.hs))
156
# -----------------------------------------------------------------------------
157
# Create platform includes
159
# Here we generate a little header file containing CPP symbols that GHC
160
# uses to determine which platform it is building on/for. The platforms
161
# can differ between stage1 and stage2 if we're cross-compiling, so we
162
# need one of these header files per stage.
164
PLATFORM_H = ghc_boot_platform.h
166
compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
167
"$(RM)" $(RM_OPTS) $@
168
@echo "Creating $@..."
169
@echo "#ifndef __PLATFORM_H__" >> $@
170
@echo "#define __PLATFORM_H__" >> $@
172
@echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
173
@echo "#define HostPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
174
@echo "#define TargetPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
176
@echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
177
@echo "#define $(BuildPlatform_CPP)_HOST 1" >> $@
178
@echo "#define $(HostPlatform_CPP)_TARGET 1" >> $@
180
@echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
181
@echo "#define $(BuildArch_CPP)_HOST_ARCH 1" >> $@
182
@echo "#define $(HostArch_CPP)_TARGET_ARCH 1" >> $@
183
@echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
184
@echo "#define HOST_ARCH \"$(BuildArch_CPP)\"" >> $@
185
@echo "#define TARGET_ARCH \"$(HostArch_CPP)\"" >> $@
187
@echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
188
@echo "#define $(BuildOS_CPP)_HOST_OS 1" >> $@
189
@echo "#define $(HostOS_CPP)_TARGET_OS 1" >> $@
190
@echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
191
@echo "#define HOST_OS \"$(BuildOS_CPP)\"" >> $@
192
@echo "#define TARGET_OS \"$(HostOS_CPP)\"" >> $@
193
ifeq "$(HostOS_CPP)" "irix"
194
@echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
195
@echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
199
@echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
200
@echo "#define $(BuildVendor_CPP)_HOST_VENDOR 1" >> $@
201
@echo "#define $(HostVendor_CPP)_TARGET_VENDOR 1" >> $@
202
@echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
203
@echo "#define HOST_VENDOR \"$(BuildVendor_CPP)\"" >> $@
204
@echo "#define TARGET_VENDOR \"$(HostVendor_CPP)\"" >> $@
206
@echo "#endif /* __PLATFORM_H__ */" >> $@
209
# For stage2 and above, the BUILD platform is the HOST of stage1, and
210
# the HOST platform is the TARGET of stage1. The TARGET remains the same
211
# (stage1 is the cross-compiler, not stage2).
212
compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
213
"$(RM)" $(RM_OPTS) $@
214
@echo "Creating $@..."
215
@echo "#ifndef __PLATFORM_H__" >> $@
216
@echo "#define __PLATFORM_H__" >> $@
218
@echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
219
@echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
220
@echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
222
@echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
223
@echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
224
@echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
226
@echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
227
@echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
228
@echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
229
@echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
230
@echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
231
@echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
233
@echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
234
@echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
235
@echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
236
@echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
237
@echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
238
@echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
239
ifeq "$(TargetOS_CPP)" "irix"
240
@echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
241
@echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
245
@echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
246
@echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
247
@echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
248
@echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
249
@echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
250
@echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
252
@echo "#endif /* __PLATFORM_H__ */" >> $@
255
compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
258
# ----------------------------------------------------------------------------
259
# Generate supporting stuff for prelude/PrimOp.lhs
260
# from prelude/primops.txt
262
# XXX: these should go in stage1/stage2/stage3
263
PRIMOP_BITS = compiler/primop-data-decl.hs-incl \
264
compiler/primop-tag.hs-incl \
265
compiler/primop-list.hs-incl \
266
compiler/primop-has-side-effects.hs-incl \
267
compiler/primop-out-of-line.hs-incl \
268
compiler/primop-commutable.hs-incl \
269
compiler/primop-needs-wrapper.hs-incl \
270
compiler/primop-can-fail.hs-incl \
271
compiler/primop-strictness.hs-incl \
272
compiler/primop-primop-info.hs-incl
274
compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
275
compiler_CPP_OPTS += ${GhcCppOpts}
277
$(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
278
$(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
280
$(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS)))
282
ifneq "$(BootingFromHc)" "YES"
283
compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
284
"$(GENPRIMOP_INPLACE)" --data-decl < $< > $@
285
compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
286
"$(GENPRIMOP_INPLACE)" --primop-tag < $< > $@
287
compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
288
"$(GENPRIMOP_INPLACE)" --primop-list < $< > $@
289
compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
290
"$(GENPRIMOP_INPLACE)" --has-side-effects < $< > $@
291
compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
292
"$(GENPRIMOP_INPLACE)" --out-of-line < $< > $@
293
compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
294
"$(GENPRIMOP_INPLACE)" --commutable < $< > $@
295
compiler/primop-needs-wrapper.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
296
"$(GENPRIMOP_INPLACE)" --needs-wrapper < $< > $@
297
compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
298
"$(GENPRIMOP_INPLACE)" --can-fail < $< > $@
299
compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
300
"$(GENPRIMOP_INPLACE)" --strictness < $< > $@
301
compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
302
"$(GENPRIMOP_INPLACE)" --primop-primop-info < $< > $@
304
# Usages aren't used any more; but the generator
305
# can still generate them if we want them back
306
compiler/primop-usage.hs-incl: $(PRIMOPS_TXT)
307
"$(GENPRIMOP_INPLACE)" --usage < $< > $@
310
# -----------------------------------------------------------------------------
313
compiler_stage1_CONFIGURE_OPTS += --flags=stage1
314
compiler_stage2_CONFIGURE_OPTS += --flags=stage2
315
compiler_stage3_CONFIGURE_OPTS += --flags=stage3
317
ifeq "$(GhcWithNativeCodeGen)" "YES"
318
compiler_stage1_CONFIGURE_OPTS += --flags=ncg
319
compiler_stage2_CONFIGURE_OPTS += --flags=ncg
322
ifeq "$(GhcWithInterpreter)" "YES"
323
compiler_stage2_CONFIGURE_OPTS += --flags=ghci
325
ifeq "$(BuildSharedLibs)" "YES"
326
compiler_stage2_CONFIGURE_OPTS += --enable-shared
327
# If we are going to use dynamic libraries instead of .o files for ghci,
328
# we will need to always retain CAFs in the compiler.
329
# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
330
# function which sets the keepCAFs flag for the RTS before any Haskell
332
compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs
335
ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
336
# Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
338
# XXX This should logically be a CPP option, but there doesn't seem to
340
compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
343
# Should the debugger commands be enabled?
344
ifeq "$(GhciWithDebugger)" "YES"
345
compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
350
ifeq "$(GhcWithNativeCodeGen)" "NO"
351
# XXX This should logically be a CPP option, but there doesn't seem to
353
compiler_CONFIGURE_OPTS += --ghc-option=-DOMIT_NATIVE_CODEGEN
356
ifeq "$(TargetOS_CPP)" "openbsd"
357
compiler_CONFIGURE_OPTS += --ld-options=-E
360
ifeq "$(GhcUnregisterised)" "NO"
362
compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
365
# If we're profiling GHC then we want lots of SCCs, so -auto-all
366
# We also don't want to waste time building the non-profiling library,
367
# either normally or for ghci. Unfortunately this means that we have to
368
# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
370
ifeq "$(GhcProfiled)" "YES"
371
compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
372
# We seem to still build the vanilla libraries even if we say
373
# --disable-library-vanilla, but installation then fails, as Cabal
374
# doesn't copy the vanilla .hi files, but ghc-pkg complains about
375
# their absence when we register the package. So for now, we just
376
# leave the vanilla libraries enabled.
377
# compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
378
compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
379
compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
382
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
383
# The #include is vital for the via-C route with older compilers, else the C
384
# compiler doesn't realise that the stcall foreign imports are indeed
385
# stdcall, and doesn't generate the Foo@8 name for them
386
# It's only important for older compilers, and in fact newer compilers
387
# will give a warning if the -#include flag is used. We therefore only
388
# do it for stage1, and only for < 6.11.
389
ifeq "$(ghc_ge_611)" "NO"
390
compiler_stage1_CONFIGURE_OPTS += --ghc-option='-\#include' \
391
--ghc-option='"<windows.h>"' \
392
--ghc-option='-\#include' \
393
--ghc-option='"<process.h>"'
397
# ghc_strlen percolates through so many modules that it is easier to get its
398
# prototype via a global option instead of a myriad of per-file OPTIONS.
399
# Again, this is only done for older compilers.
400
ifeq "$(ghc_ge_611)" "NO"
401
compiler_stage1_CONFIGURE_OPTS += --ghc-options='-\#include "cutils.h"'
404
compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
406
compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
407
compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
408
compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
409
compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
411
compiler/stage1/package-data.mk : compiler/ghc.mk
412
compiler/stage2/package-data.mk : compiler/ghc.mk
413
compiler/stage3/package-data.mk : compiler/ghc.mk
415
# -----------------------------------------------------------------------------
416
# And build the package
418
compiler_PACKAGE = ghc
420
# Note [fiddle-stage1-version]
421
# The version of the GHC package changes every day, since the
422
# patchlevel is the current date. We don't want to force
423
# recompilation of the entire compiler when this happens, so for stage
424
# 1 we omit the patchlevel from the version number. For stage 2 we
425
# have to include the patchlevel since this is the package we install,
428
# Note: we also have to tweak the version number of the package itself
429
# when it gets registered; see Note [munge-stage1-package-config]
431
# The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
432
# then we don't want to remove it
433
ifneq "$(CLEANING)" "YES"
434
ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
435
compiler_stage1_VERSION_MUNGED = YES
439
ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
440
define compiler_PACKAGE_MAGIC
441
compiler_stage1_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
444
# Don't register the non-munged package
445
compiler_stage1_REGISTER_PACKAGE = NO
449
# haddocking only happens for stage2
450
compiler_stage1_DO_HADDOCK = NO
451
compiler_stage3_DO_HADDOCK = NO
453
# Don't do splitting for the GHC package, it takes too long and
454
# there's not much benefit.
455
compiler_stage1_SplitObjs = NO
456
compiler_stage2_SplitObjs = NO
457
compiler_stage3_SplitObjs = NO
459
# if stage is set to something other than "1" or "", disable stage 1
460
ifneq "$(filter-out 1,$(stage))" ""
461
compiler_stage1_NOT_NEEDED = YES
463
# if stage is set to something other than "2" or "", disable stage 2
464
ifneq "$(filter-out 2,$(stage))" ""
465
compiler_stage2_NOT_NEEDED = YES
467
# stage 3 has to be requested explicitly with stage=3
469
compiler_stage3_NOT_NEEDED = YES
471
$(eval $(call build-package,compiler,stage1,0))
472
$(eval $(call build-package,compiler,stage2,1))
473
$(eval $(call build-package,compiler,stage3,2))
475
# after build-package, because that sets compiler_stage1_HC_OPTS:
476
compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
477
compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
478
compiler_stage3_HC_OPTS += $(GhcStage3HcOpts)
480
ifneq "$(BINDIST)" "YES"
482
compiler_stage2_TAGS_HC_OPTS = -package ghc
483
$(eval $(call tags-package,compiler,stage2))
485
$(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
486
$(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
487
$(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
489
$(compiler_stage1_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
490
$(compiler_stage2_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
491
$(compiler_stage3_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
493
# Every Constants.o object file depends on includes/GHCConstants.h:
494
$(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS) includes/HaskellConstants.hs))
496
# Every PrimOp.o object file depends on $(PRIMOP_BITS):
497
$(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS)))
499
# GHC itself doesn't know about the above dependencies, so we have to
500
# switch off the recompilation checker for those modules:
501
compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
502
compiler/main/Constants_HC_OPTS += -fforce-recomp
504
# Workaround for #4003 in GHC 6.12.2. It didn't happen in 6.12.1, and
505
# will be fixed in 6.12.3. Unfortunately we don't have a way to do
506
# this for just stage1 in the build system.
507
ifeq "$(GhcVersion)" "6.12.2"
508
compiler/hsSyn/HsLit_HC_OPTS += -fomit-interface-pragmas
511
# Note [munge-stage1-package-config]
512
# Strip the date/patchlevel from the version of stage1. See Note
513
# [fiddle-stage1-version] above.
514
ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
515
compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
516
sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
517
-e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
518
-e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
520
"$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
522
$(compiler_stage1_v_LIB) : compiler/stage1/inplace-pkg-config-munged