Remove unused cCONTEXT_DIFF
[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_CONFIG_HS)
42 compiler/stage2/package-data.mk : $(compiler_CONFIG_HS)
43 compiler/stage3/package-data.mk : $(compiler_CONFIG_HS)
44 endif
45
46 $(compiler_CONFIG_HS) : mk/config.mk mk/project.mk
47         "$(RM)" $(RM_OPTS) $@
48         @echo "Creating $@ ... "
49         @echo "module Config where" >>$@
50         @echo "cProjectName          :: String" >> $@
51         @echo "cProjectName          = \"$(ProjectName)\"" >> $@
52         @echo "cProjectVersion       :: String" >> $@
53         @echo "cProjectVersion       = \"$(ProjectVersion)\"" >> $@
54         @echo "cProjectVersionInt    :: String" >> $@
55         @echo "cProjectVersionInt    = \"$(ProjectVersionInt)\"" >> $@
56         @echo "cProjectPatchLevel    :: String" >> $@
57         @echo "cProjectPatchLevel    = \"$(ProjectPatchLevel)\"" >> $@
58         @echo "cBooterVersion        :: String" >> $@
59         @echo "cBooterVersion        = \"$(GhcVersion)\"" >> $@
60         @echo "cStage                :: String" >> $@
61         @echo "cStage                = show (STAGE :: Int)" >> $@
62         @echo "cIntegerLibrary       :: String" >> $@
63         @echo "cIntegerLibrary       = \"$(INTEGER_LIBRARY)\"" >> $@
64         @echo "cSplitObjs            :: String" >> $@
65         @echo "cSplitObjs            = \"$(SupportsSplitObjs)\"" >> $@
66         @echo "cGhcWithInterpreter   :: String" >> $@
67         @echo "cGhcWithInterpreter   = \"$(GhcWithInterpreter)\"" >> $@
68         @echo "cGhcWithNativeCodeGen :: String" >> $@
69         @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $@
70         @echo "cGhcWithSMP           :: String" >> $@
71         @echo "cGhcWithSMP           = \"$(GhcWithSMP)\"" >> $@
72         @echo "cGhcRTSWays           :: String" >> $@
73         @echo "cGhcRTSWays           = \"$(GhcRTSWays)\"" >> $@
74         @echo "cGhcUnregisterised    :: String" >> $@
75         @echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $@
76         @echo "cGhcEnableTablesNextToCode :: String" >> $@
77         @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $@
78         @echo "cLeadingUnderscore    :: String" >> $@
79         @echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $@
80         @echo "cRAWCPP_FLAGS         :: String" >> $@
81         @echo "cRAWCPP_FLAGS         = \"$(RAWCPP_FLAGS)\"" >> $@
82         @echo "cGCC                  :: String" >> $@
83         @echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $@
84         @echo "cMKDLL                :: String" >> $@
85         @echo "cMKDLL                = \"$(BLD_DLL)\"" >> $@
86         @echo "cLdIsGNULd            :: String" >> $@
87         @echo "cLdIsGNULd            = \"$(LdIsGNULd)\"" >> $@
88         @echo "cLD_X                 :: String" >> $@
89         @echo "cLD_X                 = \"$(LD_X)\"" >> $@
90         @echo "cGHC_DRIVER_DIR       :: String" >> $@
91         @echo "cGHC_DRIVER_DIR       = \"$(GHC_DRIVER_DIR)\"" >> $@
92         @echo "cGHC_TOUCHY_PGM       :: String" >> $@
93         @echo "cGHC_TOUCHY_PGM       = \"$(GHC_TOUCHY_PGM)\"" >> $@
94         @echo "cGHC_TOUCHY_DIR       :: String" >> $@
95         @echo "cGHC_TOUCHY_DIR       = \"$(GHC_TOUCHY_DIR)\"" >> $@
96         @echo "cGHC_UNLIT_PGM        :: String" >> $@
97         @echo "cGHC_UNLIT_PGM        = \"$(GHC_UNLIT_PGM)\"" >> $@
98         @echo "cGHC_UNLIT_DIR        :: String" >> $@
99         @echo "cGHC_UNLIT_DIR        = \"$(GHC_UNLIT_DIR)\"" >> $@
100         @echo "cGHC_MANGLER_PGM      :: String" >> $@
101         @echo "cGHC_MANGLER_PGM      = \"$(GHC_MANGLER_PGM)\"" >> $@
102         @echo "cGHC_MANGLER_DIR      :: String" >> $@
103         @echo "cGHC_MANGLER_DIR      = \"$(GHC_MANGLER_DIR)\"" >> $@
104         @echo "cGHC_SPLIT_PGM        :: String" >> $@
105         @echo "cGHC_SPLIT_PGM        = \"$(GHC_SPLIT_PGM)\"" >> $@
106         @echo "cGHC_SPLIT_DIR        :: String" >> $@
107         @echo "cGHC_SPLIT_DIR        = \"$(GHC_SPLIT_DIR)\"" >> $@
108         @echo "cGHC_SYSMAN_PGM       :: String" >> $@
109         @echo "cGHC_SYSMAN_PGM       = \"$(GHC_SYSMAN)\"" >> $@
110         @echo "cGHC_SYSMAN_DIR       :: String" >> $@
111         @echo "cGHC_SYSMAN_DIR       = \"$(GHC_SYSMAN_DIR)\"" >> $@
112         @echo "cGHC_PERL             :: String" >> $@
113         @echo "cGHC_PERL             = \"$(GHC_PERL)\"" >> $@
114         @echo "cUSER_WAY_NAMES       :: String" >> $@
115         @echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $@
116         @echo "cUSER_WAY_OPTS        :: String" >> $@
117         @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $@
118         @echo "cDEFAULT_TMPDIR       :: String" >> $@
119         @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $@
120         @echo "cRelocatableBuild     :: Bool"                 >> $@
121 ifeq "$(RelocatableBuild)" "YES"
122         @echo "cRelocatableBuild     = True"                  >> $@
123 else
124         @echo "cRelocatableBuild     = False"                 >> $@
125 endif
126         @echo "cLibFFI               :: Bool"                 >> $@
127 ifeq "$(UseLibFFIForAdjustors)" "YES"
128         @echo "cLibFFI               = True"                  >> $@
129 else
130         @echo "cLibFFI               = False"                 >> $@
131 endif
132         @echo done.
133
134 $(eval $(call clean-target,compiler,config_hs,$(compiler_CONFIG_HS)))
135
136 # -----------------------------------------------------------------------------
137 # Create platform includes
138
139 # Here we generate a little header file containing CPP symbols that GHC
140 # uses to determine which platform it is building on/for.  The platforms
141 # can differ between stage1 and stage2 if we're cross-compiling, so we
142 # need one of these header files per stage.
143
144 PLATFORM_H = ghc_boot_platform.h
145
146 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
147         "$(RM)" $(RM_OPTS) $@
148         @echo "Creating $@..."
149         @echo "#ifndef __PLATFORM_H__"  >$@
150         @echo "#define __PLATFORM_H__" >>$@
151         @echo >> $@
152         @echo "#define BuildPlatform_NAME  \"$(BUILDPLATFORM)\"" >> $@
153         @echo "#define HostPlatform_NAME   \"$(HOSTPLATFORM)\"" >> $@
154         @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
155         @echo >> $@
156         @echo "#define $(BuildPlatform_CPP)_BUILD       1" >> $@
157         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
158         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
159         @echo >> $@
160         @echo "#define $(BuildArch_CPP)_BUILD_ARCH      1" >> $@
161         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
162         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
163         @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
164         @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
165         @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
166         @echo >> $@
167         @echo "#define $(BuildOS_CPP)_BUILD_OS          1" >> $@
168         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
169         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
170         @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
171         @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
172         @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
173 ifeq "$(HostOS_CPP)" "irix"
174         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
175         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
176         @echo "#endif                                    " >> $@  
177 endif
178         @echo >> $@
179         @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR  1" >> $@
180         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
181         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
182         @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
183         @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
184         @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
185         @echo >> $@
186         @echo "#endif /* __PLATFORM_H__ */"          >> $@
187         @echo "Done."
188
189 # For stage2 and above, the BUILD platform is the HOST of stage1, and
190 # the HOST platform is the TARGET of stage1.  The TARGET remains the same
191 # (stage1 is the cross-compiler, not stage2).
192 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
193         "$(RM)" $(RM_OPTS) $@
194         @echo "Creating $@..."
195         @echo "#ifndef __PLATFORM_H__"  >$@
196         @echo "#define __PLATFORM_H__" >>$@
197         @echo >> $@
198         @echo "#define BuildPlatform_NAME  \"$(HOSTPLATFORM)\"" >> $@
199         @echo "#define HostPlatform_NAME   \"$(TARGETPLATFORM)\"" >> $@
200         @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
201         @echo >> $@
202         @echo "#define $(HostPlatform_CPP)_BUILD        1" >> $@
203         @echo "#define $(TargetPlatform_CPP)_HOST               1" >> $@
204         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
205         @echo >> $@
206         @echo "#define $(HostArch_CPP)_BUILD_ARCH       1" >> $@
207         @echo "#define $(TargetArch_CPP)_HOST_ARCH      1" >> $@
208         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
209         @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
210         @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
211         @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
212         @echo >> $@
213         @echo "#define $(HostOS_CPP)_BUILD_OS           1" >> $@
214         @echo "#define $(TargetOS_CPP)_HOST_OS          1" >> $@
215         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
216         @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
217         @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
218         @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
219 ifeq "$(HostOS_CPP)" "irix"
220         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
221         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
222         @echo "#endif                                    " >> $@  
223 endif
224         @echo >> $@
225         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR   1" >> $@
226         @echo "#define $(TargetVendor_CPP)_HOST_VENDOR  1" >> $@
227         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
228         @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
229         @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
230         @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
231         @echo >> $@
232         @echo "#endif /* __PLATFORM_H__ */"          >> $@
233         @echo "Done."
234
235 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
236         "$(CP)" $< $@
237
238 # ----------------------------------------------------------------------------
239 #               Generate supporting stuff for prelude/PrimOp.lhs 
240 #               from prelude/primops.txt
241
242 # XXX: these should go in stage1/stage2/stage3
243 PRIMOP_BITS = compiler/primop-data-decl.hs-incl        \
244               compiler/primop-tag.hs-incl              \
245               compiler/primop-list.hs-incl             \
246               compiler/primop-has-side-effects.hs-incl \
247               compiler/primop-out-of-line.hs-incl      \
248               compiler/primop-commutable.hs-incl       \
249               compiler/primop-needs-wrapper.hs-incl    \
250               compiler/primop-can-fail.hs-incl         \
251               compiler/primop-strictness.hs-incl       \
252               compiler/primop-primop-info.hs-incl
253
254 compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
255 compiler_CPP_OPTS += ${GhcCppOpts}
256
257 $(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
258         $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
259
260 $(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS)))
261
262 ifneq "$(BootingFromHc)" "YES"
263 compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
264         "$(GENPRIMOP_INPLACE)" --data-decl          < $< > $@
265 compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
266         "$(GENPRIMOP_INPLACE)" --primop-tag         < $< > $@
267 compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
268         "$(GENPRIMOP_INPLACE)" --primop-list        < $< > $@
269 compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
270         "$(GENPRIMOP_INPLACE)" --has-side-effects   < $< > $@
271 compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
272         "$(GENPRIMOP_INPLACE)" --out-of-line        < $< > $@
273 compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
274         "$(GENPRIMOP_INPLACE)" --commutable         < $< > $@
275 compiler/primop-needs-wrapper.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
276         "$(GENPRIMOP_INPLACE)" --needs-wrapper      < $< > $@
277 compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
278         "$(GENPRIMOP_INPLACE)" --can-fail           < $< > $@
279 compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
280         "$(GENPRIMOP_INPLACE)" --strictness         < $< > $@
281 compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
282         "$(GENPRIMOP_INPLACE)" --primop-primop-info < $< > $@
283
284 # Usages aren't used any more; but the generator 
285 # can still generate them if we want them back
286 compiler/primop-usage.hs-incl: $(PRIMOPS_TXT)
287         "$(GENPRIMOP_INPLACE)" --usage              < $< > $@
288 endif
289
290 # -----------------------------------------------------------------------------
291 # Configuration
292
293 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
294 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
295 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
296
297 ifeq "$(GhcWithNativeCodeGen)" "YES"
298 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
299 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
300 endif
301
302 ifeq "$(GhcWithInterpreter)" "YES"
303 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
304
305 ifeq "$(BuildSharedLibs)" "YES"
306 compiler_stage2_CONFIGURE_OPTS += --enable-shared
307 # If we are going to use dynamic libraries instead of .o files for ghci,
308 # we will need to always retain CAFs in the compiler.
309 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
310 # function which sets the keepCAFs flag for the RTS before any Haskell
311 # code is run.
312 compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs
313 endif
314
315 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
316 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
317 # or not?
318 # XXX This should logically be a CPP option, but there doesn't seem to
319 # be a flag for that
320 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
321 endif
322
323 # Should the debugger commands be enabled?
324 ifeq "$(GhciWithDebugger)" "YES"
325 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
326 endif
327
328 endif
329
330 ifeq "$(GhcWithNativeCodeGen)" "NO"
331 # XXX This should logically be a CPP option, but there doesn't seem to
332 # be a flag for that
333 compiler_CONFIGURE_OPTS += --ghc-option=-DOMIT_NATIVE_CODEGEN
334 endif
335
336 ifeq "$(TargetOS_CPP)" "openbsd"
337 compiler_CONFIGURE_OPTS += --ld-options=-E
338 endif
339
340 ifeq "$(GhcUnregisterised)" "NO"
341 ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux"
342 # needed for generating proper relocation in large binaries: trac #856
343 compiler_CONFIGURE_OPTS += --ld-option=-Wl,--relax
344 endif
345 endif
346
347 # We need to turn on profiling either if we have been asked to
348 # (GhcLibProfiled = YES) or if we want GHC itself to be compiled with
349 # profiling enabled (GhcProfiled = YES).
350 ifneq "$(GhcLibProfiled) $(GhcProfiled)" "NO NO"
351 compiler_stage2_CONFIGURE_OPTS += --enable-library-profiling
352 # And if we're profiling GHC then we want lots of SCCs.
353 # We also don't want to waste time building the non-profiling library,
354 # either normally or for ghci. Unfortunately this means that we have to
355 # tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
356 # exist.
357 ifeq "$(GhcProfiled)" "YES"
358 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
359 compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
360 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
361 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
362 endif
363 endif
364
365 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
366 # The #include is vital for the via-C route with older compilers, else the C
367 # compiler doesn't realise that the stcall foreign imports are indeed
368 # stdcall, and doesn't generate the Foo@8 name for them
369 # It's only important for older compilers, and in fact newer compilers
370 # will give a warning if the -#include flag is used. We therefore only
371 # do it for stage1, and only for < 6.11.
372 ifeq "$(ghc_ge_611)" "NO"
373 compiler_stage1_CONFIGURE_OPTS += --ghc-option='-\#include'    \
374                           --ghc-option='"<windows.h>"' \
375                           --ghc-option='-\#include'    \
376                           --ghc-option='"<process.h>"'
377 endif
378 endif
379
380 # ghc_strlen percolates through so many modules that it is easier to get its
381 # prototype via a global option instead of a myriad of per-file OPTIONS.
382 # Again, this is only done for older compilers.
383 ifeq "$(ghc_ge_611)" "NO"
384 compiler_stage1_CONFIGURE_OPTS += --ghc-options='-\#include "cutils.h"'
385 endif
386
387 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
388
389 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
390 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
391 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
392 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
393
394 compiler_stage1_CONFIGURE_OPTS += --ghc-options='$(GhcStage1HcOpts)'
395 compiler_stage2_CONFIGURE_OPTS += --ghc-options='$(GhcStage2HcOpts)'
396 compiler_stage3_CONFIGURE_OPTS += --ghc-options='$(GhcStage3HcOpts)'
397
398 compiler/stage1/package-data.mk : compiler/ghc.mk
399 compiler/stage2/package-data.mk : compiler/ghc.mk
400 compiler/stage3/package-data.mk : compiler/ghc.mk
401
402 # -----------------------------------------------------------------------------
403 # And build the package
404
405 compiler_PACKAGE = ghc
406
407 # Note [fiddle-stage1-version]
408 # The version of the GHC package changes every day, since the
409 # patchlevel is the current date.  We don't want to force
410 # recompilation of the entire compiler when this happens, so for stage
411 # 1 we omit the patchlevel from the version number.  For stage 2 we
412 # have to include the patchlevel since this is the package we install,
413 # however.
414 #
415 # Note: we also have to tweak the version number of the package itself
416 # when it gets registered; see Note [munge-stage1-package-config]
417 # below.
418 # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
419 # then we don't want to remove it
420 ifneq "$(CLEANING)" "YES"
421 ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
422 compiler_stage1_VERSION_MUNGED = YES
423 endif
424 endif
425
426 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
427 define compiler_PACKAGE_MAGIC
428 compiler_stage1_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
429 endef
430
431 # Don't register the non-munged package
432 compiler_stage1_REGISTER_PACKAGE = NO
433
434 endif
435
436 # haddocking only happens for stage2
437 compiler_stage1_DO_HADDOCK = NO
438 compiler_stage3_DO_HADDOCK = NO
439
440 # Don't do splitting for the GHC package, it takes too long and
441 # there's not much benefit.
442 compiler_stage1_SplitObjs = NO
443 compiler_stage2_SplitObjs = NO
444 compiler_stage3_SplitObjs = NO
445
446 # For now, bindists always use stage 2
447 ifneq "$(BINDIST)" "YES"
448 # stage 1 is enabled unless $(stage) is set to something other than 1
449 ifeq "$(filter-out 1,$(stage))" ""
450 $(eval $(call build-package,compiler,stage1,0))
451 endif
452 endif
453
454 # stage 2 is enabled unless $(stage) is set to something other than 2
455 ifeq "$(filter-out 2,$(stage))" ""
456 $(eval $(call build-package,compiler,stage2,1))
457 endif
458
459 ifneq "$(BINDIST)" "YES"
460 # stage 3 has to be requested explicitly with stage=3
461 ifeq "$(stage)" "3"
462 $(eval $(call build-package,compiler,stage3,2))
463 endif
464
465 compiler_stage2_TAGS_HC_OPTS = -package ghc
466 $(eval $(call tags-package,compiler,stage2))
467
468 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
469 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
470 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
471
472 $(compiler_stage1_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
473 $(compiler_stage2_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
474 $(compiler_stage3_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
475
476 # Every Constants.o object file depends on includes/GHCConstants.h:
477 $(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS) includes/HaskellConstants.hs))
478
479 # Every PrimOp.o object file depends on $(PRIMOP_BITS):
480 $(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS)))
481
482 # GHC itself doesn't know about the above dependencies, so we have to
483 # switch off the recompilation checker for those modules:
484 compiler/prelude/PrimOps_HC_OPTS += -fforce-recomp
485 compiler/main/Constants_HC_OPTS  += -fforce-recomp
486
487 # Note [munge-stage1-package-config]
488 # Strip the date/patchlevel from the version of stage1.  See Note
489 # [fiddle-stage1-version] above.
490 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
491 compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
492         sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
493             -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
494             -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
495           < $< > $@
496         "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
497
498 $(compiler_stage1_v_LIB) : compiler/stage1/inplace-pkg-config-munged
499 endif
500
501 endif
502