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