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