ghc.mk: one module name per line
[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://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.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 # Note that GhcThreaded just reflects the Makefile variable setting.
115 # In particular, the stage1 compiler is never actually compiled with
116 # -threaded, but it will nevertheless have cGhcThreaded = True.
117 # The "+RTS --info" output will show what RTS GHC is really using.
118 @echo 'cGhcThreaded :: Bool' >> $@
119 ifeq "$(GhcThreaded)" "YES"
120 @echo 'cGhcThreaded = True' >> $@
121 else
122 @echo 'cGhcThreaded = False' >> $@
123 endif
124 @echo 'cGhcDebugged :: Bool' >> $@
125 ifeq "$(GhcDebugged)" "YES"
126 @echo 'cGhcDebugged = True' >> $@
127 else
128 @echo 'cGhcDebugged = False' >> $@
129 endif
130 @echo done.
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 | $$(dir $$@)/.
143 $(call removeFiles,$@)
144 @echo "Creating $@..."
145 @echo "#ifndef __PLATFORM_H__" >> $@
146 @echo "#define __PLATFORM_H__" >> $@
147 @echo >> $@
148 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
149 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
150 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
151 @echo >> $@
152 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
153 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
154 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
155 @echo >> $@
156 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
157 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
158 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
159 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
160 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
161 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
162 @echo >> $@
163 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
164 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
165 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
166 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
167 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
168 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
169 ifeq "$(TargetOS_CPP)" "irix"
170 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
171 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
172 @echo "#endif" >> $@
173 endif
174 @echo >> $@
175 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
176 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
177 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
178 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
179 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
180 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
181 @echo >> $@
182 @echo "#endif /* __PLATFORM_H__ */" >> $@
183 @echo "Done."
184
185 # For stage2 and above, the BUILD platform is the HOST of stage1, and
186 # the HOST platform is the TARGET of stage1. The TARGET remains the same
187 # (stage1 is the cross-compiler, not stage2).
188 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
189 $(call removeFiles,$@)
190 @echo "Creating $@..."
191 @echo "#ifndef __PLATFORM_H__" >> $@
192 @echo "#define __PLATFORM_H__" >> $@
193 @echo >> $@
194 @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
195 @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
196 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
197 @echo >> $@
198 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
199 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
200 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
201 @echo >> $@
202 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
203 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
204 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
205 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
206 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
207 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
208 @echo >> $@
209 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
210 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
211 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
212 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
213 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
214 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
215 ifeq "$(TargetOS_CPP)" "irix"
216 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
217 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
218 @echo "#endif" >> $@
219 endif
220 @echo >> $@
221 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
222 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
223 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
224 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
225 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
226 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
227 @echo >> $@
228 @echo "#endif /* __PLATFORM_H__ */" >> $@
229 @echo "Done."
230
231 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
232 "$(CP)" $< $@
233
234 # ----------------------------------------------------------------------------
235 # Generate supporting stuff for prelude/PrimOp.lhs
236 # from prelude/primops.txt
237
238 PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
239 primop-tag.hs-incl \
240 primop-list.hs-incl \
241 primop-has-side-effects.hs-incl \
242 primop-out-of-line.hs-incl \
243 primop-commutable.hs-incl \
244 primop-code-size.hs-incl \
245 primop-can-fail.hs-incl \
246 primop-strictness.hs-incl \
247 primop-fixity.hs-incl \
248 primop-primop-info.hs-incl \
249 primop-vector-uniques.hs-incl \
250 primop-vector-tys.hs-incl \
251 primop-vector-tys-exports.hs-incl \
252 primop-vector-tycons.hs-incl
253
254 PRIMOP_BITS_STAGE1 = $(addprefix compiler/stage1/build/,$(PRIMOP_BITS_NAMES))
255 PRIMOP_BITS_STAGE2 = $(addprefix compiler/stage2/build/,$(PRIMOP_BITS_NAMES))
256 PRIMOP_BITS_STAGE3 = $(addprefix compiler/stage3/build/,$(PRIMOP_BITS_NAMES))
257
258 compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
259 compiler_CPP_OPTS += ${GhcCppOpts}
260
261 define preprocessCompilerFiles
262 # $0 = stage
263 compiler/stage$1/build/Parser.y: compiler/parser/Parser.y.pp
264 $$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -x c $$< | grep -v '^#pragma GCC' > $$@
265
266 compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
267 $$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
268
269 compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
270 "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
271 compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
272 "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
273 compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
274 "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
275 compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
276 "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
277 compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
278 "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
279 compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
280 "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
281 compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
282 "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
283 compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
284 "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
285 compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
286 "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
287 compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
288 "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
289 compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
290 "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
291 compiler/stage$1/build/primop-vector-uniques.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
292 "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
293 compiler/stage$1/build/primop-vector-tys.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
294 "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
295 compiler/stage$1/build/primop-vector-tys-exports.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
296 "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
297 compiler/stage$1/build/primop-vector-tycons.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
298 "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
299
300 # Usages aren't used any more; but the generator
301 # can still generate them if we want them back
302 compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
303 "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
304
305 endef
306
307 $(eval $(call preprocessCompilerFiles,1))
308 $(eval $(call preprocessCompilerFiles,2))
309 $(eval $(call preprocessCompilerFiles,3))
310
311 # -----------------------------------------------------------------------------
312 # Configuration
313
314 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
315 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
316 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
317
318 ifeq "$(GhcThreaded)" "YES"
319 # We pass THREADED_RTS to the stage2 C files so that cbits/genSym.c will bring
320 # the threaded version of atomic_inc() into scope.
321 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS
322 endif
323
324 ifeq "$(GhcWithNativeCodeGen)" "YES"
325 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
326 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
327 endif
328
329 ifeq "$(GhcWithInterpreter)" "YES"
330 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
331
332 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
333 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
334 # or not?
335 # XXX This should logically be a CPP option, but there doesn't seem to
336 # be a flag for that
337 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
338 endif
339
340 # Should the debugger commands be enabled?
341 ifeq "$(GhciWithDebugger)" "YES"
342 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
343 endif
344
345 endif
346
347 ifeq "$(TargetOS_CPP)" "openbsd"
348 compiler_CONFIGURE_OPTS += --ld-options=-E
349 endif
350
351 ifeq "$(GhcUnregisterised)" "NO"
352 else
353 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
354 endif
355
356 # Careful optimisation of the parser: we don't want to throw everything
357 # at it, because that takes too long and doesn't buy much, but we do want
358 # to inline certain key external functions, so we instruct GHC not to
359 # throw away inlinings as it would normally do in -O0 mode.
360 compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas
361 # If we're bootstrapping the compiler during stage2, or we're being
362 # built by a GHC whose version is > 7.8, we need -fcmm-sink to be
363 # passed to the compiler. This is required on x86 to avoid the
364 # register allocator running out of stack slots when compiling this
365 # module with -fPIC -dynamic.
366 # See #8182 for all the details
367 ifeq "$(CMM_SINK_BOOTSTRAP_IS_NEEDED)" "YES"
368 compiler/stage1/build/Parser_HC_OPTS += -fcmm-sink
369 endif
370 # We also pass -fcmm-sink to every stage != 1
371 compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
372 compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
373
374
375 ifeq "$(GhcProfiled)" "YES"
376 # If we're profiling GHC then we want SCCs. However, adding -auto-all
377 # everywhere tends to give a hard-to-read profile, and adds lots of
378 # overhead. A better approach is to proceed top-down; identify the
379 # parts of the compiler of interest, and then add further cost centres
380 # as necessary. Turn on -auto-all for individual modules like this:
381
382 # compiler/main/DriverPipeline_HC_OPTS += -auto-all
383 compiler/main/GhcMake_HC_OPTS += -auto-all
384 compiler/main/GHC_HC_OPTS += -auto-all
385
386 # or alternatively add {-# OPTIONS_GHC -auto-all #-} to the top of
387 # modules you're interested in.
388
389 # We seem to still build the vanilla libraries even if we say
390 # --disable-library-vanilla, but installation then fails, as Cabal
391 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
392 # their absence when we register the package. So for now, we just
393 # leave the vanilla libraries enabled.
394 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
395 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
396 endif
397
398 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
399
400 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
401 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
402 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
403 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
404
405 compiler/stage1/package-data.mk : compiler/ghc.mk
406 compiler/stage2/package-data.mk : compiler/ghc.mk
407 compiler/stage3/package-data.mk : compiler/ghc.mk
408
409 # -----------------------------------------------------------------------------
410 # And build the package
411
412 compiler_PACKAGE = ghc
413
414 # Note [fiddle-stage1-version]
415 # The version of the GHC package changes every day, since the
416 # patchlevel is the current date. We don't want to force
417 # recompilation of the entire compiler when this happens, so for stage
418 # 1 we omit the patchlevel from the version number. For stage 2 we
419 # have to include the patchlevel since this is the package we install,
420 # however.
421 #
422 # Note: we also have to tweak the version number of the package itself
423 # when it gets registered; see Note [munge-stage1-package-config]
424 # below.
425 # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
426 # then we don't want to remove it
427 ifneq "$(CLEANING)" "YES"
428 ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
429 compiler_stage1_VERSION_MUNGED = YES
430 endif
431 endif
432
433 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
434 compiler_stage1_MUNGED_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
435 define compiler_PACKAGE_MAGIC
436 compiler_stage1_VERSION = $(compiler_stage1_MUNGED_VERSION)
437 endef
438
439 # Don't register the non-munged package
440 compiler_stage1_REGISTER_PACKAGE = NO
441
442 endif
443
444 # Don't do splitting for the GHC package, it takes too long and
445 # there's not much benefit.
446 compiler_stage1_SplitObjs = NO
447 compiler_stage2_SplitObjs = NO
448 compiler_stage3_SplitObjs = NO
449
450 # There are too many symbols in the ghc package for a Windows DLL.
451 # We therefore need to split some of the modules off into a separate
452 # DLL. This clump are the modules reachable from DynFlags:
453 compiler_stage2_dll0_START_MODULE = DynFlags
454 compiler_stage2_dll0_MODULES = \
455 Annotations \
456 Avail \
457 Bag \
458 BasicTypes \
459 BinIface \
460 Binary \
461 Bitmap \
462 BlockId \
463 BooleanFormula \
464 BreakArray \
465 BufWrite \
466 BuildTyCl \
467 ByteCodeAsm \
468 ByteCodeInstr \
469 ByteCodeItbls \
470 CLabel \
471 Class \
472 CmdLineParser \
473 Cmm \
474 CmmCallConv \
475 CmmExpr \
476 CmmInfo \
477 CmmMachOp \
478 CmmNode \
479 CmmType \
480 CmmUtils \
481 CoAxiom \
482 CodeGen.Platform \
483 CodeGen.Platform.ARM \
484 CodeGen.Platform.NoRegs \
485 CodeGen.Platform.PPC \
486 CodeGen.Platform.PPC_Darwin \
487 CodeGen.Platform.SPARC \
488 CodeGen.Platform.X86 \
489 CodeGen.Platform.X86_64 \
490 Coercion \
491 Config \
492 Constants \
493 CoreArity \
494 CoreFVs \
495 CoreLint \
496 CoreSubst \
497 CoreSyn \
498 CoreTidy \
499 CoreUnfold \
500 CoreUtils \
501 CostCentre \
502 DataCon \
503 Demand \
504 Digraph \
505 DriverPhases \
506 DsMonad \
507 DynFlags \
508 Encoding \
509 ErrUtils \
510 Exception \
511 ExtsCompat46 \
512 FamInstEnv \
513 FastBool \
514 FastFunctions \
515 FastMutInt \
516 FastString \
517 FastTypes \
518 Finder \
519 Fingerprint \
520 FiniteMap \
521 ForeignCall \
522 Hooks \
523 Hoopl \
524 Hoopl.Dataflow \
525 HsBinds \
526 HsDecls \
527 HsDoc \
528 HsExpr \
529 HsImpExp \
530 HsLit \
531 HsPat \
532 HsSyn \
533 HsTypes \
534 HsUtils \
535 HscTypes \
536 IOEnv \
537 Id \
538 IdInfo \
539 IfaceEnv \
540 IfaceSyn \
541 IfaceType \
542 InstEnv \
543 InteractiveEvalTypes \
544 Kind \
545 ListSetOps \
546 Literal \
547 LoadIface \
548 Maybes \
549 MkCore \
550 MkGraph \
551 MkId \
552 Module \
553 MonadUtils \
554 Name \
555 NameEnv \
556 NameSet \
557 OccName \
558 OccurAnal \
559 OptCoercion \
560 OrdList \
561 Outputable \
562 PackageConfig \
563 Packages \
564 Pair \
565 Panic \
566 PipelineMonad \
567 Platform \
568 PlatformConstants \
569 PprCmm \
570 PprCmmDecl \
571 PprCmmExpr \
572 PprCore \
573 PrelInfo \
574 PrelNames \
575 PrelRules \
576 Pretty \
577 PrimOp \
578 RdrName \
579 Reg \
580 RegClass \
581 Rules \
582 SMRep \
583 Serialized \
584 SrcLoc \
585 StaticFlags \
586 StgCmmArgRep \
587 StgCmmClosure \
588 StgCmmEnv \
589 StgCmmLayout \
590 StgCmmMonad \
591 StgCmmProf \
592 StgCmmTicky \
593 StgCmmUtils \
594 StgSyn \
595 Stream \
596 StringBuffer \
597 TcEvidence \
598 TcIface \
599 TcRnMonad \
600 TcRnTypes \
601 TcType \
602 TcTypeNats \
603 TrieMap \
604 TyCon \
605 Type \
606 TypeRep \
607 TysPrim \
608 TysWiredIn \
609 Unify \
610 UniqFM \
611 UniqSet \
612 UniqSupply \
613 Unique \
614 Util \
615 Var \
616 VarEnv \
617 VarSet
618
619 compiler_stage2_dll0_HS_OBJS = \
620 $(patsubst %,compiler/stage2/build/%.$(dyn_osuf),$(subst .,/,$(compiler_stage2_dll0_MODULES)))
621
622 # if stage is set to something other than "1" or "", disable stage 1
623 ifneq "$(filter-out 1,$(stage))" ""
624 compiler_stage1_NOT_NEEDED = YES
625 endif
626 # if stage is set to something other than "2" or "", disable stage 2
627 ifneq "$(filter-out 2,$(stage))" ""
628 compiler_stage2_NOT_NEEDED = YES
629 endif
630 # stage 3 has to be requested explicitly with stage=3
631 ifneq "$(stage)" "3"
632 compiler_stage3_NOT_NEEDED = YES
633 endif
634 $(eval $(call build-package,compiler,stage1,0))
635 $(eval $(call build-package,compiler,stage2,1))
636 $(eval $(call build-package,compiler,stage3,2))
637
638 # We only want to turn keepCAFs on if we will be loading dynamic
639 # Haskell libraries with GHCi. We therefore filter the object file
640 # out for non-dynamic ways.
641 define keepCAFsForGHCiDynOnly
642 # $1 = stage
643 # $2 = way
644 ifeq "$$(findstring dyn, $1)" ""
645 compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.o,$$(compiler_stage$1_$2_C_OBJS))
646 endif
647 endef
648 $(foreach w,$(compiler_stage1_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,1,$w)))
649 $(foreach w,$(compiler_stage2_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,2,$w)))
650 $(foreach w,$(compiler_stage3_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,3,$w)))
651
652 # after build-package, because that adds --enable-library-for-ghci
653 # to compiler_stage*_CONFIGURE_OPTS:
654 # We don't build the GHCi library for the ghc package. We can load it
655 # the .a file instead, and as object splitting isn't on for the ghc
656 # package this isn't much slower.However, not building the package saves
657 # a significant chunk of disk space.
658 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
659 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
660 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
661
662 # after build-package, because that sets compiler_stage1_HC_OPTS:
663 compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
664 compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
665 compiler_stage3_HC_OPTS += $(GhcStage3HcOpts)
666
667 ifneq "$(BINDIST)" "YES"
668
669 compiler_stage2_TAGS_HC_OPTS = -package ghc
670 $(eval $(call tags-package,compiler,stage2))
671
672 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
673 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
674 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
675
676 COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
677 COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
678 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
679 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_TYPE)
680 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
681 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
682 COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
683
684 $(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1)
685 $(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2)
686 $(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3)
687
688 $(foreach way,$(compiler_stage1_WAYS),\
689 compiler/stage1/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE1)
690 $(foreach way,$(compiler_stage2_WAYS),\
691 compiler/stage2/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE2)
692 $(foreach way,$(compiler_stage3_WAYS),\
693 compiler/stage3/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE3)
694
695
696 # GHC itself doesn't know about the above dependencies, so we have to
697 # switch off the recompilation checker for that module:
698 compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
699
700 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
701 compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
702 endif
703
704 # LibFFI.hs #includes ffi.h
705 ifneq "$(UseSystemLibFFI)" "YES"
706 compiler/stage2/build/LibFFI.hs : $(libffi_HEADERS)
707 endif
708
709 # Note [munge-stage1-package-config]
710 # Strip the date/patchlevel from the version of stage1. See Note
711 # [fiddle-stage1-version] above.
712 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
713 compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
714 sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
715 -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
716 -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
717 < $< > $@
718 "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
719
720 # We need to make sure the munged config is in the database before we
721 # try to configure ghc-bin
722 ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged
723 endif
724
725 endif
726