Remove the Windows installer
[ghc.git] / compiler / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009-2012 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 # Create compiler configuration
15 #
16 # The 'echo' commands simply spit the values of various make variables
17 # into Config.hs, whence they can be compiled and used by GHC itself
18
19 # This is just to avoid generating a warning when generating deps
20 # involving RtsFlags.h
21 compiler_stage1_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
22 compiler_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
23 compiler_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
24
25 compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
26
27 # This package doesn't pass the Cabal checks because include-dirs
28 # points outside the source directory. This isn't a real problem, so
29 # we just skip the check.
30 compiler_NO_CHECK = YES
31
32 ifneq "$(BINDIST)" "YES"
33 compiler/stage1/package-data.mk : compiler/stage1/build/Config.hs
34 compiler/stage2/package-data.mk : compiler/stage2/build/Config.hs
35 compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs
36
37 compiler/stage1/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
38 compiler/stage2/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
39 compiler/stage3/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
40 compiler/stage1/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
41 compiler/stage2/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
42 compiler/stage3/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
43 compiler/stage1/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
44 compiler/stage2/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
45 compiler/stage3/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
46 endif
47
48 compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
49 $(call removeFiles,$@)
50 @echo 'Creating $@ ... '
51 @echo '{-# LANGUAGE CPP #-}' >> $@
52 @echo 'module Config where' >> $@
53 @echo >> $@
54 @echo '#include "ghc_boot_platform.h"' >> $@
55 @echo >> $@
56 @echo 'data IntegerLibrary = IntegerGMP | IntegerSimple' >> $@
57 @echo ' deriving Eq' >> $@
58 @echo >> $@
59 @echo 'cBuildPlatformString :: String' >> $@
60 @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
61 @echo 'cHostPlatformString :: String' >> $@
62 @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
63 @echo 'cTargetPlatformString :: String' >> $@
64 @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
65 @echo >> $@
66 @echo 'cProjectName :: String' >> $@
67 @echo 'cProjectName = "$(ProjectName)"' >> $@
68 @echo 'cProjectVersion :: String' >> $@
69 @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
70 @echo 'cProjectVersionInt :: String' >> $@
71 @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
72 @echo 'cProjectPatchLevel :: String' >> $@
73 @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
74 @echo 'cBooterVersion :: String' >> $@
75 @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
76 @echo 'cStage :: String' >> $@
77 @echo 'cStage = show (STAGE :: Int)' >> $@
78 @echo 'cIntegerLibrary :: String' >> $@
79 @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
80 @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
81 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
82 @echo 'cIntegerLibraryType = IntegerGMP' >> $@
83 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
84 @echo 'cIntegerLibraryType = IntegerSimple' >> $@
85 else ifneq "$(CLEANING)" "YES"
86 $(error Unknown integer library)
87 endif
88 @echo 'cSupportsSplitObjs :: String' >> $@
89 @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
90 @echo 'cGhcWithInterpreter :: String' >> $@
91 @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
92 @echo 'cGhcWithNativeCodeGen :: String' >> $@
93 @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
94 @echo 'cGhcWithSMP :: String' >> $@
95 @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
96 @echo 'cGhcRTSWays :: String' >> $@
97 @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
98 @echo 'cGhcEnableTablesNextToCode :: String' >> $@
99 @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
100 @echo 'cLeadingUnderscore :: String' >> $@
101 @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
102 @echo 'cRAWCPP_FLAGS :: String' >> $@
103 @echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@
104 @echo 'cGHC_UNLIT_PGM :: String' >> $@
105 @echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
106 @echo 'cGHC_SPLIT_PGM :: String' >> $@
107 @echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
108 @echo 'cLibFFI :: Bool' >> $@
109 ifeq "$(UseLibFFIForAdjustors)" "YES"
110 @echo 'cLibFFI = True' >> $@
111 else
112 @echo 'cLibFFI = False' >> $@
113 endif
114 @echo 'cDYNAMIC_GHC_PROGRAMS :: Bool' >> $@
115 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
116 @echo 'cDYNAMIC_GHC_PROGRAMS = True' >> $@
117 else
118 @echo 'cDYNAMIC_GHC_PROGRAMS = False' >> $@
119 endif
120 @echo done.
121
122 # -----------------------------------------------------------------------------
123 # Create platform includes
124
125 # Here we generate a little header file containing CPP symbols that GHC
126 # uses to determine which platform it is building on/for. The platforms
127 # can differ between stage1 and stage2 if we're cross-compiling, so we
128 # need one of these header files per stage.
129
130 PLATFORM_H = ghc_boot_platform.h
131
132 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
133 $(call removeFiles,$@)
134 @echo "Creating $@..."
135 @echo "#ifndef __PLATFORM_H__" >> $@
136 @echo "#define __PLATFORM_H__" >> $@
137 @echo >> $@
138 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
139 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
140 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
141 @echo >> $@
142 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
143 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
144 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
145 @echo >> $@
146 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
147 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
148 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
149 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
150 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
151 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
152 @echo >> $@
153 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
154 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
155 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
156 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
157 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
158 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
159 ifeq "$(TargetOS_CPP)" "irix"
160 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
161 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
162 @echo "#endif" >> $@
163 endif
164 @echo >> $@
165 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
166 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
167 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
168 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
169 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
170 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
171 @echo >> $@
172 @echo "#endif /* __PLATFORM_H__ */" >> $@
173 @echo "Done."
174
175 # For stage2 and above, the BUILD platform is the HOST of stage1, and
176 # the HOST platform is the TARGET of stage1. The TARGET remains the same
177 # (stage1 is the cross-compiler, not stage2).
178 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
179 $(call removeFiles,$@)
180 @echo "Creating $@..."
181 @echo "#ifndef __PLATFORM_H__" >> $@
182 @echo "#define __PLATFORM_H__" >> $@
183 @echo >> $@
184 @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
185 @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
186 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
187 @echo >> $@
188 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
189 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
190 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
191 @echo >> $@
192 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
193 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
194 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
195 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
196 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
197 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
198 @echo >> $@
199 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
200 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
201 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
202 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
203 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
204 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
205 ifeq "$(TargetOS_CPP)" "irix"
206 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
207 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
208 @echo "#endif" >> $@
209 endif
210 @echo >> $@
211 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
212 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
213 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
214 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
215 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
216 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
217 @echo >> $@
218 @echo "#endif /* __PLATFORM_H__ */" >> $@
219 @echo "Done."
220
221 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
222 "$(CP)" $< $@
223
224 # ----------------------------------------------------------------------------
225 # Generate supporting stuff for prelude/PrimOp.lhs
226 # from prelude/primops.txt
227
228 PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
229 primop-tag.hs-incl \
230 primop-list.hs-incl \
231 primop-has-side-effects.hs-incl \
232 primop-out-of-line.hs-incl \
233 primop-commutable.hs-incl \
234 primop-code-size.hs-incl \
235 primop-can-fail.hs-incl \
236 primop-strictness.hs-incl \
237 primop-fixity.hs-incl \
238 primop-primop-info.hs-incl
239
240 PRIMOP_BITS_STAGE1 = $(addprefix compiler/stage1/build/,$(PRIMOP_BITS_NAMES))
241 PRIMOP_BITS_STAGE2 = $(addprefix compiler/stage2/build/,$(PRIMOP_BITS_NAMES))
242 PRIMOP_BITS_STAGE3 = $(addprefix compiler/stage3/build/,$(PRIMOP_BITS_NAMES))
243
244 compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
245 compiler_CPP_OPTS += ${GhcCppOpts}
246
247 define preprocessCompilerFiles
248 # $0 = stage
249 compiler/stage$1/build/Parser.y: compiler/parser/Parser.y.pp
250 $$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -x c $$< | grep -v '^#pragma GCC' > $$@
251
252 compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
253 $$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
254
255 compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
256 "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
257 compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
258 "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
259 compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
260 "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
261 compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
262 "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
263 compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
264 "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
265 compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
266 "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
267 compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
268 "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
269 compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
270 "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
271 compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
272 "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
273 compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
274 "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
275 compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
276 "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
277
278 # Usages aren't used any more; but the generator
279 # can still generate them if we want them back
280 compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
281 "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
282
283 endef
284
285 $(eval $(call preprocessCompilerFiles,1))
286 $(eval $(call preprocessCompilerFiles,2))
287 $(eval $(call preprocessCompilerFiles,3))
288
289 # -----------------------------------------------------------------------------
290 # Configuration
291
292 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
293 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
294 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
295
296 ifeq "$(GhcWithNativeCodeGen)" "YES"
297 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
298 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
299 endif
300
301 ifeq "$(GhcWithInterpreter)" "YES"
302 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
303
304 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
305 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
306 # or not?
307 # XXX This should logically be a CPP option, but there doesn't seem to
308 # be a flag for that
309 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
310 endif
311
312 # Should the debugger commands be enabled?
313 ifeq "$(GhciWithDebugger)" "YES"
314 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
315 endif
316
317 endif
318
319 ifeq "$(TargetOS_CPP)" "openbsd"
320 compiler_CONFIGURE_OPTS += --ld-options=-E
321 endif
322
323 ifeq "$(GhcUnregisterised)" "NO"
324 else
325 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
326 endif
327
328 ifeq "$(GhcProfiled)" "YES"
329
330 # If we're profiling GHC then we want SCCs. However, adding -auto-all
331 # everywhere tends to give a hard-to-read profile, and adds lots of
332 # overhead. A better approach is to proceed top-down; identify the
333 # parts of the compiler of interest, and then add further cost centres
334 # as necessary. Turn on -auto-all for individual modules like this:
335
336 # compiler/main/DriverPipeline_HC_OPTS += -auto-all
337 compiler/main/GhcMake_HC_OPTS += -auto-all
338 compiler/main/GHC_HC_OPTS += -auto-all
339
340 # or alternatively add {-# OPTIONS_GHC -auto-all #-} to the top of
341 # modules you're interested in.
342
343 # We seem to still build the vanilla libraries even if we say
344 # --disable-library-vanilla, but installation then fails, as Cabal
345 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
346 # their absence when we register the package. So for now, we just
347 # leave the vanilla libraries enabled.
348 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
349 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
350 endif
351
352 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
353
354 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
355 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
356 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
357 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
358
359 compiler/stage1/package-data.mk : compiler/ghc.mk
360 compiler/stage2/package-data.mk : compiler/ghc.mk
361 compiler/stage3/package-data.mk : compiler/ghc.mk
362
363 # -----------------------------------------------------------------------------
364 # And build the package
365
366 compiler_PACKAGE = ghc
367
368 # Note [fiddle-stage1-version]
369 # The version of the GHC package changes every day, since the
370 # patchlevel is the current date. We don't want to force
371 # recompilation of the entire compiler when this happens, so for stage
372 # 1 we omit the patchlevel from the version number. For stage 2 we
373 # have to include the patchlevel since this is the package we install,
374 # however.
375 #
376 # Note: we also have to tweak the version number of the package itself
377 # when it gets registered; see Note [munge-stage1-package-config]
378 # below.
379 # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
380 # then we don't want to remove it
381 ifneq "$(CLEANING)" "YES"
382 ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
383 compiler_stage1_VERSION_MUNGED = YES
384 endif
385 endif
386
387 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
388 compiler_stage1_MUNGED_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
389 define compiler_PACKAGE_MAGIC
390 compiler_stage1_VERSION = $(compiler_stage1_MUNGED_VERSION)
391 endef
392
393 # Don't register the non-munged package
394 compiler_stage1_REGISTER_PACKAGE = NO
395
396 endif
397
398 # Don't do splitting for the GHC package, it takes too long and
399 # there's not much benefit.
400 compiler_stage1_SplitObjs = NO
401 compiler_stage2_SplitObjs = NO
402 compiler_stage3_SplitObjs = NO
403
404 # There are too many symbols in the ghc package for a Windows DLL.
405 # We therefore need to split some of the modules off into a separate
406 # DLL. This clump are the modules reachable from DynFlags:
407 compiler_stage2_dll0_START_MODULE = DynFlags
408 compiler_stage2_dll0_MODULES = Annotations Avail Bag BasicTypes Binary Bitmap BlockId BreakArray BufWrite ByteCodeAsm ByteCodeInstr ByteCodeItbls ByteCodeLink CLabel Class CmdLineParser Cmm CmmCallConv CmmExpr CmmInfo CmmMachOp CmmNode CmmType CmmUtils CoAxiom CodeGen.Platform CodeGen.Platform.ARM CodeGen.Platform.NoRegs CodeGen.Platform.PPC CodeGen.Platform.PPC_Darwin CodeGen.Platform.SPARC CodeGen.Platform.X86 CodeGen.Platform.X86_64 Coercion Config Constants CoreArity CoreFVs CoreSubst CoreSyn CoreTidy CoreUnfold CoreUtils CostCentre DataCon Demand Digraph DriverPhases DynFlags Encoding ErrUtils Exception FamInstEnv FastBool FastFunctions FastMutInt FastString FastTypes Fingerprint FiniteMap ForeignCall Hoopl Hoopl.Dataflow HsBinds HsDecls HsDoc HsExpr HsImpExp HsLit HsPat HsSyn HsTypes HsUtils HscTypes Id IdInfo IfaceSyn IfaceType InstEnv InteractiveEvalTypes Kind ListSetOps Literal Maybes MkCore MkGraph MkId Module MonadUtils Name NameEnv NameSet ObjLink OccName OccurAnal OptCoercion OrdList Outputable PackageConfig Packages Pair Panic Platform PlatformConstants PprCmm PprCmmDecl PprCmmExpr PprCore PrelNames PrelRules Pretty PrimOp RdrName Reg RegClass Rules SMRep Serialized SrcLoc StaticFlags StgCmmArgRep StgCmmClosure StgCmmEnv StgCmmLayout StgCmmMonad StgCmmProf StgCmmTicky StgCmmUtils StgSyn Stream StringBuffer TcEvidence TcType TyCon Type TypeRep TysPrim TysWiredIn Unify UniqFM UniqSet UniqSupply Unique Util Var VarEnv VarSet
409
410 compiler_stage2_dll0_HS_OBJS = \
411 $(patsubst %,compiler/stage2/build/%.$(dyn_osuf),$(subst .,/,$(compiler_stage2_dll0_MODULES)))
412
413 # if stage is set to something other than "1" or "", disable stage 1
414 ifneq "$(filter-out 1,$(stage))" ""
415 compiler_stage1_NOT_NEEDED = YES
416 endif
417 # if stage is set to something other than "2" or "", disable stage 2
418 ifneq "$(filter-out 2,$(stage))" ""
419 compiler_stage2_NOT_NEEDED = YES
420 endif
421 # stage 3 has to be requested explicitly with stage=3
422 ifneq "$(stage)" "3"
423 compiler_stage3_NOT_NEEDED = YES
424 endif
425 $(eval $(call build-package,compiler,stage1,0))
426 $(eval $(call build-package,compiler,stage2,1))
427 $(eval $(call build-package,compiler,stage3,2))
428
429 # We only want to turn keepCAFs on if we will be loading dynamic
430 # Haskell libraries with GHCi. We therefore filter the object file
431 # out for non-dynamic ways.
432 define keepCAFsForGHCiDynOnly
433 # $1 = stage
434 # $2 = way
435 ifeq "$$(findstring dyn, $1)" ""
436 compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.o,$$(compiler_stage$1_$2_C_OBJS))
437 endif
438 endef
439 $(foreach w,$(compiler_stage1_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,1,$w)))
440 $(foreach w,$(compiler_stage2_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,2,$w)))
441 $(foreach w,$(compiler_stage3_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,3,$w)))
442
443 # after build-package, because that adds --enable-library-for-ghci
444 # to compiler_stage*_CONFIGURE_OPTS:
445 # We don't build the GHCi library for the ghc package. We can load it
446 # the .a file instead, and as object splitting isn't on for the ghc
447 # package this isn't much slower.However, not building the package saves
448 # a significant chunk of disk space.
449 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
450 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
451 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
452
453 # after build-package, because that sets compiler_stage1_HC_OPTS:
454 compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
455 compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
456 compiler_stage3_HC_OPTS += $(GhcStage3HcOpts)
457
458 ifneq "$(BINDIST)" "YES"
459
460 compiler_stage2_TAGS_HC_OPTS = -package ghc
461 $(eval $(call tags-package,compiler,stage2))
462
463 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
464 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
465 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
466
467 COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
468 COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
469 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
470 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_TYPE)
471 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
472 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
473 COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
474
475 $(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1)
476 $(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2)
477 $(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3)
478
479 $(foreach way,$(compiler_stage1_WAYS),\
480 compiler/stage1/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE1)
481 $(foreach way,$(compiler_stage2_WAYS),\
482 compiler/stage2/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE2)
483 $(foreach way,$(compiler_stage3_WAYS),\
484 compiler/stage3/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE3)
485
486
487 # GHC itself doesn't know about the above dependencies, so we have to
488 # switch off the recompilation checker for that module:
489 compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
490
491 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
492 compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
493 endif
494
495 # LibFFI.hs #includes ffi.h
496 ifneq "$(UseSystemLibFFI)" "YES"
497 compiler/stage2/build/LibFFI.hs : $(libffi_HEADERS)
498 endif
499
500 # Note [munge-stage1-package-config]
501 # Strip the date/patchlevel from the version of stage1. See Note
502 # [fiddle-stage1-version] above.
503 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
504 compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
505 sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
506 -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
507 -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
508 < $< > $@
509 "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
510
511 # We need to make sure the munged config is in the database before we
512 # try to configure ghc-bin
513 ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged
514 endif
515
516 endif
517