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 'import Distribution.System' >> $@
54 @echo '#include "ghc_boot_platform.h"' >> $@
56 @echo 'cBuildPlatformString :: String' >> $@
57 @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
58 @echo 'cHostPlatformString :: String' >> $@
59 @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
60 @echo 'cTargetPlatformString :: String' >> $@
61 @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
63 # Sync this with checkArch in configure.ac
64 @echo 'cTargetArch :: Arch' >> $@
65 @echo '#if i386_TARGET_ARCH' >> $@
66 @echo 'cTargetArch = I386' >> $@
67 @echo '#elif x86_64_TARGET_ARCH' >> $@
68 @echo 'cTargetArch = X86_64' >> $@
69 @echo '#elif powerpc_TARGET_ARCH' >> $@
70 @echo 'cTargetArch = PPC' >> $@
71 @echo '#elif powerpc64_TARGET_ARCH' >> $@
72 @echo 'cTargetArch = PPC64' >> $@
73 @echo '#elif sparc_TARGET_ARCH || sparc64_TARGET_ARCH' >> $@
74 @echo 'cTargetArch = Sparc' >> $@
75 @echo '#elif arm_TARGET_ARCH' >> $@
76 @echo 'cTargetArch = Arm' >> $@
77 @echo '#elif mips_TARGET_ARCH || mipseb_TARGET_ARCH || mipsel_TARGET_ARCH' >> $@
78 @echo 'cTargetArch = Mips' >> $@
80 @echo 'cTargetArch = SH' >> $@
81 @echo '#elif ia64_TARGET_ARCH' >> $@
82 @echo 'cTargetArch = IA64' >> $@
83 @echo '#elif s390_TARGET_ARCH' >> $@
84 @echo 'cTargetArch = S390' >> $@
85 @echo '#elif alpha_TARGET_ARCH' >> $@
86 @echo 'cTargetArch = Alpha' >> $@
87 @echo '#elif hppa_TARGET_ARCH || hppa1_1_TARGET_ARCH' >> $@
88 @echo 'cTargetArch = Hppa' >> $@
89 @echo '#elif rs6000_TARGET_ARCH' >> $@
90 @echo 'cTargetArch = Rs6000' >> $@
91 @echo '#elif m68k_TARGET_ARCH' >> $@
92 @echo 'cTargetArch = M68k' >> $@
93 @echo '#elif vax_TARGET_ARCH' >> $@
94 @echo 'cTargetArch = Vax' >> $@
96 @echo '#error Unknown target arch' >> $@
99 # Sync this with checkOS in configure.ac
100 @echo 'cTargetOS :: OS' >> $@
101 @echo '#if linux_TARGET_OS' >> $@
102 @echo 'cTargetOS = Linux' >> $@
103 @echo '#elif freebsd_TARGET_OS' >> $@
104 @echo 'cTargetOS = FreeBSD' >> $@
105 @echo '#elif netbsd_TARGET_OS' >> $@
106 @echo 'cTargetOS = NetBSD' >> $@
107 @echo '#elif openbsd_TARGET_OS' >> $@
108 @echo 'cTargetOS = OpenBSD' >> $@
109 @echo '#elif dragonfly_TARGET_OS' >> $@
110 @echo 'cTargetOS = OtherOS "dragonfly"' >> $@
111 @echo '#elif osf1_TARGET_OS' >> $@
112 @echo 'cTargetOS = OtherOS "osf"' >> $@
113 @echo '#elif osf3_TARGET_OS' >> $@
114 @echo 'cTargetOS = OtherOS "osf"' >> $@
115 @echo '#elif hpux_TARGET_OS' >> $@
116 @echo 'cTargetOS = HPUX' >> $@
117 @echo '#elif linuxaout_TARGET_OS' >> $@
118 @echo 'cTargetOS = Linux' >> $@
119 @echo '#elif kfreebsdgnu_TARGET_OS' >> $@
120 @echo 'cTargetOS = OtherOS "kfreebsdgnu"' >> $@
121 @echo '#elif freebsd2_TARGET_OS' >> $@
122 @echo 'cTargetOS = FreeBSD' >> $@
123 @echo '#elif solaris2_TARGET_OS' >> $@
124 @echo 'cTargetOS = Solaris' >> $@
125 @echo '#elif cygwin32_TARGET_OS' >> $@
126 @echo 'cTargetOS = Windows' >> $@
127 @echo '#elif mingw32_TARGET_OS' >> $@
128 @echo 'cTargetOS = Windows' >> $@
129 @echo '#elif darwin_TARGET_OS' >> $@
130 @echo 'cTargetOS = OSX' >> $@
131 @echo '#elif gnu_TARGET_OS' >> $@
132 @echo 'cTargetOS = OtherOS "gnu"' >> $@
133 @echo '#elif nextstep2_TARGET_OS' >> $@
134 @echo 'cTargetOS = OtherOS "nextstep"' >> $@
135 @echo '#elif nextstep3_TARGET_OS' >> $@
136 @echo 'cTargetOS = OtherOS "nextstep"' >> $@
137 @echo '#elif sunos4_TARGET_OS' >> $@
138 @echo 'cTargetOS = Solaris' >> $@
139 @echo '#elif ultrix_TARGET_OS' >> $@
140 @echo 'cTargetOS = OtherOS "ultrix"' >> $@
141 @echo '#elif irix_TARGET_OS' >> $@
142 @echo 'cTargetOS = IRIX' >> $@
143 @echo '#elif aix_TARGET_OS' >> $@
144 @echo 'cTargetOS = AIX' >> $@
145 @echo '#elif haiku_TARGET_OS' >> $@
146 @echo 'cTargetOS = OtherOS "haiku"' >> $@
148 @echo '#error Unknown target OS' >> $@
151 @echo 'cProjectName :: String' >> $@
152 @echo 'cProjectName = "$(ProjectName)"' >> $@
153 @echo 'cProjectVersion :: String' >> $@
154 @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
155 @echo 'cProjectVersionInt :: String' >> $@
156 @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
157 @echo 'cProjectPatchLevel :: String' >> $@
158 @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
159 @echo 'cBooterVersion :: String' >> $@
160 @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
161 @echo 'cStage :: String' >> $@
162 @echo 'cStage = show (STAGE :: Int)' >> $@
163 @echo 'cGccLinkerOpts :: [String]' >> $@
164 @echo 'cGccLinkerOpts = words "$(CONF_GCC_LINKER_OPTS_STAGE$*)"' >> $@
165 @echo 'cLdLinkerOpts :: [String]' >> $@
166 @echo 'cLdLinkerOpts = words "$(CONF_LD_LINKER_OPTS_STAGE$*)"' >> $@
167 @echo 'cIntegerLibrary :: String' >> $@
168 @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
169 @echo 'cSupportsSplitObjs :: String' >> $@
170 @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
171 @echo 'cGhcWithInterpreter :: String' >> $@
172 @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
173 @echo 'cGhcWithNativeCodeGen :: String' >> $@
174 @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
175 @echo 'cGhcWithSMP :: String' >> $@
176 @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
177 @echo 'cGhcRTSWays :: String' >> $@
178 @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
179 @echo 'cGhcUnregisterised :: String' >> $@
180 @echo 'cGhcUnregisterised = "$(GhcUnregisterised)"' >> $@
181 @echo 'cGhcEnableTablesNextToCode :: String' >> $@
182 @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
183 @echo 'cLeadingUnderscore :: String' >> $@
184 @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
185 @echo 'cRAWCPP_FLAGS :: String' >> $@
186 @echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@
187 @echo 'cMKDLL :: String' >> $@
188 @echo 'cMKDLL = "$(BLD_DLL)"' >> $@
189 @echo 'cLdIsGNULd :: String' >> $@
190 @echo 'cLdIsGNULd = "$(LdIsGNULd)"' >> $@
191 @echo 'cLdHasBuildId :: String' >> $@
192 @echo 'cLdHasBuildId = "$(LdHasBuildId)"' >> $@
193 @echo 'cLD_X :: String' >> $@
194 @echo 'cLD_X = "$(LD_X)"' >> $@
195 @echo 'cGHC_DRIVER_DIR :: String' >> $@
196 @echo 'cGHC_DRIVER_DIR = "$(GHC_DRIVER_DIR)"' >> $@
197 @echo 'cGHC_TOUCHY_PGM :: String' >> $@
198 @echo 'cGHC_TOUCHY_PGM = "$(GHC_TOUCHY_PGM)"' >> $@
199 @echo 'cGHC_TOUCHY_DIR :: String' >> $@
200 @echo 'cGHC_TOUCHY_DIR = "$(GHC_TOUCHY_DIR)"' >> $@
201 @echo 'cGHC_UNLIT_PGM :: String' >> $@
202 @echo 'cGHC_UNLIT_PGM = "$(GHC_UNLIT_PGM)"' >> $@
203 @echo 'cGHC_UNLIT_DIR :: String' >> $@
204 @echo 'cGHC_UNLIT_DIR = "$(GHC_UNLIT_DIR)"' >> $@
205 @echo 'cGHC_SPLIT_PGM :: String' >> $@
206 @echo 'cGHC_SPLIT_PGM = "$(GHC_SPLIT_PGM)"' >> $@
207 @echo 'cGHC_SPLIT_DIR :: String' >> $@
208 @echo 'cGHC_SPLIT_DIR = "$(GHC_SPLIT_DIR)"' >> $@
209 @echo 'cGHC_SYSMAN_PGM :: String' >> $@
210 @echo 'cGHC_SYSMAN_PGM = "$(GHC_SYSMAN)"' >> $@
211 @echo 'cGHC_SYSMAN_DIR :: String' >> $@
212 @echo 'cGHC_SYSMAN_DIR = "$(GHC_SYSMAN_DIR)"' >> $@
213 @echo 'cDEFAULT_TMPDIR :: String' >> $@
214 @echo 'cDEFAULT_TMPDIR = "$(DEFAULT_TMPDIR)"' >> $@
215 @echo 'cRelocatableBuild :: Bool' >> $@
216 ifeq "$(RelocatableBuild)" "YES"
217 @echo 'cRelocatableBuild = True' >> $@
219 @echo 'cRelocatableBuild = False' >> $@
221 @echo 'cLibFFI :: Bool' >> $@
222 ifeq "$(UseLibFFIForAdjustors)" "YES"
223 @echo 'cLibFFI = True' >> $@
225 @echo 'cLibFFI = False' >> $@
229 # XXX 2010-08-19: This is a legacy clean. Remove later.
230 $(eval $(call clean-target,compiler,config_hs,compiler/main/Config.hs))
232 # -----------------------------------------------------------------------------
233 # Create platform includes
235 # Here we generate a little header file containing CPP symbols that GHC
236 # uses to determine which platform it is building on/for. The platforms
237 # can differ between stage1 and stage2 if we're cross-compiling, so we
238 # need one of these header files per stage.
240 PLATFORM_H = ghc_boot_platform.h
242 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
243 "$(RM)" $(RM_OPTS) $@
244 @echo "Creating $@..."
245 @echo "#ifndef __PLATFORM_H__" >> $@
246 @echo "#define __PLATFORM_H__" >> $@
248 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
249 @echo "#define HostPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
250 @echo "#define TargetPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
252 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
253 @echo "#define $(BuildPlatform_CPP)_HOST 1" >> $@
254 @echo "#define $(HostPlatform_CPP)_TARGET 1" >> $@
256 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
257 @echo "#define $(BuildArch_CPP)_HOST_ARCH 1" >> $@
258 @echo "#define $(HostArch_CPP)_TARGET_ARCH 1" >> $@
259 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
260 @echo "#define HOST_ARCH \"$(BuildArch_CPP)\"" >> $@
261 @echo "#define TARGET_ARCH \"$(HostArch_CPP)\"" >> $@
263 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
264 @echo "#define $(BuildOS_CPP)_HOST_OS 1" >> $@
265 @echo "#define $(HostOS_CPP)_TARGET_OS 1" >> $@
266 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
267 @echo "#define HOST_OS \"$(BuildOS_CPP)\"" >> $@
268 @echo "#define TARGET_OS \"$(HostOS_CPP)\"" >> $@
269 ifeq "$(HostOS_CPP)" "irix"
270 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
271 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
275 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
276 @echo "#define $(BuildVendor_CPP)_HOST_VENDOR 1" >> $@
277 @echo "#define $(HostVendor_CPP)_TARGET_VENDOR 1" >> $@
278 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
279 @echo "#define HOST_VENDOR \"$(BuildVendor_CPP)\"" >> $@
280 @echo "#define TARGET_VENDOR \"$(HostVendor_CPP)\"" >> $@
282 @echo "#endif /* __PLATFORM_H__ */" >> $@
285 # For stage2 and above, the BUILD platform is the HOST of stage1, and
286 # the HOST platform is the TARGET of stage1. The TARGET remains the same
287 # (stage1 is the cross-compiler, not stage2).
288 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
289 "$(RM)" $(RM_OPTS) $@
290 @echo "Creating $@..."
291 @echo "#ifndef __PLATFORM_H__" >> $@
292 @echo "#define __PLATFORM_H__" >> $@
294 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
295 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
296 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
298 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
299 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
300 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
302 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
303 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
304 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
305 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
306 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
307 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
309 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
310 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
311 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
312 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
313 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
314 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
315 ifeq "$(TargetOS_CPP)" "irix"
316 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
317 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
321 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
322 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
323 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
324 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
325 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
326 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
328 @echo "#endif /* __PLATFORM_H__ */" >> $@
331 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
334 # ----------------------------------------------------------------------------
335 # Generate supporting stuff for prelude/PrimOp.lhs
336 # from prelude/primops.txt
338 # XXX: these should go in stage1/stage2/stage3
339 PRIMOP_BITS = compiler/primop-data-decl.hs-incl \
340 compiler/primop-tag.hs-incl \
341 compiler/primop-list.hs-incl \
342 compiler/primop-has-side-effects.hs-incl \
343 compiler/primop-out-of-line.hs-incl \
344 compiler/primop-commutable.hs-incl \
345 compiler/primop-needs-wrapper.hs-incl \
346 compiler/primop-can-fail.hs-incl \
347 compiler/primop-strictness.hs-incl \
348 compiler/primop-primop-info.hs-incl
350 compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
351 compiler_CPP_OPTS += ${GhcCppOpts}
353 $(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
354 $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
356 $(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS)))
358 ifneq "$(BootingFromHc)" "YES"
359 compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
360 "$(GENPRIMOP_INPLACE)" --data-decl < $< > $@
361 compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
362 "$(GENPRIMOP_INPLACE)" --primop-tag < $< > $@
363 compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
364 "$(GENPRIMOP_INPLACE)" --primop-list < $< > $@
365 compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
366 "$(GENPRIMOP_INPLACE)" --has-side-effects < $< > $@
367 compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
368 "$(GENPRIMOP_INPLACE)" --out-of-line < $< > $@
369 compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
370 "$(GENPRIMOP_INPLACE)" --commutable < $< > $@
371 compiler/primop-needs-wrapper.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
372 "$(GENPRIMOP_INPLACE)" --needs-wrapper < $< > $@
373 compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
374 "$(GENPRIMOP_INPLACE)" --can-fail < $< > $@
375 compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
376 "$(GENPRIMOP_INPLACE)" --strictness < $< > $@
377 compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
378 "$(GENPRIMOP_INPLACE)" --primop-primop-info < $< > $@
380 # Usages aren't used any more; but the generator
381 # can still generate them if we want them back
382 compiler/primop-usage.hs-incl: $(PRIMOPS_TXT)
383 "$(GENPRIMOP_INPLACE)" --usage < $< > $@
386 # -----------------------------------------------------------------------------
389 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
390 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
391 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
393 ifeq "$(GhcWithNativeCodeGen)" "YES"
394 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
395 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
398 ifeq "$(GhcWithInterpreter)" "YES"
399 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
401 ifeq "$(BuildSharedLibs)" "YES"
402 compiler_stage2_CONFIGURE_OPTS += --enable-shared
403 # If we are going to use dynamic libraries instead of .o files for ghci,
404 # we will need to always retain CAFs in the compiler.
405 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
406 # function which sets the keepCAFs flag for the RTS before any Haskell
408 compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs
411 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
412 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
414 # XXX This should logically be a CPP option, but there doesn't seem to
416 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
419 # Should the debugger commands be enabled?
420 ifeq "$(GhciWithDebugger)" "YES"
421 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
426 ifeq "$(TargetOS_CPP)" "openbsd"
427 compiler_CONFIGURE_OPTS += --ld-options=-E
430 ifeq "$(GhcUnregisterised)" "NO"
432 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
435 # If we're profiling GHC then we want lots of SCCs, so -auto-all
436 # We also don't want to waste time building the non-profiling library.
437 # Unfortunately this means that we have to tell ghc-pkg --force as it
438 # gets upset when libHSghc-6.9.a doesn't exist.
439 ifeq "$(GhcProfiled)" "YES"
440 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
441 # We seem to still build the vanilla libraries even if we say
442 # --disable-library-vanilla, but installation then fails, as Cabal
443 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
444 # their absence when we register the package. So for now, we just
445 # leave the vanilla libraries enabled.
446 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
447 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
450 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
452 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
453 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
454 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
455 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
457 compiler/stage1/package-data.mk : compiler/ghc.mk
458 compiler/stage2/package-data.mk : compiler/ghc.mk
459 compiler/stage3/package-data.mk : compiler/ghc.mk
461 # -----------------------------------------------------------------------------
462 # And build the package
464 compiler_PACKAGE = ghc
466 # Note [fiddle-stage1-version]
467 # The version of the GHC package changes every day, since the
468 # patchlevel is the current date. We don't want to force
469 # recompilation of the entire compiler when this happens, so for stage
470 # 1 we omit the patchlevel from the version number. For stage 2 we
471 # have to include the patchlevel since this is the package we install,
474 # Note: we also have to tweak the version number of the package itself
475 # when it gets registered; see Note [munge-stage1-package-config]
477 # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
478 # then we don't want to remove it
479 ifneq "$(CLEANING)" "YES"
480 ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
481 compiler_stage1_VERSION_MUNGED = YES
485 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
486 define compiler_PACKAGE_MAGIC
487 compiler_stage1_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
490 # Don't register the non-munged package
491 compiler_stage1_REGISTER_PACKAGE = NO
495 # haddocking only happens for stage2
496 compiler_stage1_DO_HADDOCK = NO
497 compiler_stage3_DO_HADDOCK = NO
499 # Don't do splitting for the GHC package, it takes too long and
500 # there's not much benefit.
501 compiler_stage1_SplitObjs = NO
502 compiler_stage2_SplitObjs = NO
503 compiler_stage3_SplitObjs = NO
505 # if stage is set to something other than "1" or "", disable stage 1
506 ifneq "$(filter-out 1,$(stage))" ""
507 compiler_stage1_NOT_NEEDED = YES
509 # if stage is set to something other than "2" or "", disable stage 2
510 ifneq "$(filter-out 2,$(stage))" ""
511 compiler_stage2_NOT_NEEDED = YES
513 # stage 3 has to be requested explicitly with stage=3
515 compiler_stage3_NOT_NEEDED = YES
517 $(eval $(call build-package,compiler,stage1,0))
518 $(eval $(call build-package,compiler,stage2,1))
519 $(eval $(call build-package,compiler,stage3,2))
521 # after build-package, because that adds --enable-library-for-ghci
522 # to compiler_stage*_CONFIGURE_OPTS:
523 # We don't build the GHCi library for the ghc package. We can load it
524 # the .a file instead, and as object splitting isn't on for the ghc
525 # package this isn't much slower.However, not building the package saves
526 # a significant chunk of disk space.
527 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
528 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
529 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
531 # after build-package, because that sets compiler_stage1_HC_OPTS:
532 compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
533 compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
534 compiler_stage3_HC_OPTS += $(GhcStage3HcOpts)
536 ifeq "$(GhcStage1DefaultNewCodegen)" "YES"
537 compiler_stage1_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
540 ifeq "$(GhcStage2DefaultNewCodegen)" "YES"
541 compiler_stage2_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
544 ifeq "$(GhcStage3DefaultNewCodegen)" "YES"
545 compiler_stage3_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
548 ifneq "$(BINDIST)" "YES"
550 compiler_stage2_TAGS_HC_OPTS = -package ghc
551 $(eval $(call tags-package,compiler,stage2))
553 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
554 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
555 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
557 $(compiler_stage1_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
558 $(compiler_stage2_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
559 $(compiler_stage3_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
561 # Every Constants.o object file depends on includes/GHCConstants.h:
562 $(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS) includes/HaskellConstants.hs))
564 # Every PrimOp.o object file depends on $(PRIMOP_BITS):
565 $(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS)))
567 # GHC itself doesn't know about the above dependencies, so we have to
568 # switch off the recompilation checker for those modules:
569 compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
570 compiler/main/Constants_HC_OPTS += -fforce-recomp
572 # Workaround for #4003 in GHC 6.12.2. It didn't happen in 6.12.1, and
573 # will be fixed in 6.12.3. Unfortunately we don't have a way to do
574 # this for just stage1 in the build system.
575 ifeq "$(GhcVersion)" "6.12.2"
576 compiler/hsSyn/HsLit_HC_OPTS += -fomit-interface-pragmas
579 # Note [munge-stage1-package-config]
580 # Strip the date/patchlevel from the version of stage1. See Note
581 # [fiddle-stage1-version] above.
582 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
583 compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
584 sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
585 -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
586 -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
588 "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
590 # We need to make sure the munged config is in the database before we
591 # try to configure ghc-bin
592 ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged