Implement the Strict language extension
[ghc.git] / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009-2013 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 # ToDo List.
14 #
15 # * remove old Makefiles, add new stubs for building in subdirs
16 # * docs/Makefile
17 # * docs/storage-mgmt/Makefile
18 # * docs/vh/Makefile
19 # * rts/dotnet/Makefile
20 # * utils/Makefile
21 # * add Makefiles for the rest of the utils/ programs that aren't built
22 # by default (need to exclude them from 'make all' too)
23
24 # Possible cleanups:
25 #
26 # * per-source-file dependencies instead of one .depend file?
27 # * eliminate undefined variables, and use --warn-undefined-variables?
28 # * put outputs from different ways in different subdirs of distdir/build,
29 # then we don't have to use -osuf/-hisuf. We would have to install
30 # them in different places too, so we'd need ghc-pkg support for packages
31 # of different ways.
32 # * make PACKAGES_STAGE1 generated by './configure' or './boot'?
33 # * we should use a directory of package.conf files rather than a single
34 # file for the inplace package database, so that we can express
35 # dependencies more accurately. Otherwise it's possible to get into
36 # a state where the package database is out of date, and the build
37 # system doesn't know.
38
39 # Approximate build order.
40 #
41 # The actual build order is defined by dependencies, and the phase
42 # ordering used to ensure correct ordering of makefile-generation; see
43 # http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
44 #
45 # * With bootstrapping compiler:
46 # o Build utils/ghc-cabal
47 # o Build utils/ghc-pkg
48 # o Build utils/hsc2hs
49 # o Build utils/genprimopcode
50 # o Build utils/deriveConstants
51 # * For each package:
52 # o configure, generate package-data.mk and inplace-pkg-config
53 # o register each package into inplace/lib/package.conf
54 # * build libffi (if not disabled by --with-system-libffi)
55 # * With bootstrapping compiler:
56 # o Build libraries/{filepath,hpc,Cabal}
57 # o Build compiler (stage 1)
58 # * With stage 1 compiler:
59 # o Build libraries/*
60 # o Build rts
61 # o Build utils/* (except haddock)
62 # o Build compiler (stage 2)
63 # * With stage 2 compiler:
64 # o Build utils/haddock
65 # o Build compiler (stage 3) (optional)
66 # * With haddock:
67 # o libraries/*
68 # o compiler
69
70 .PHONY: default all haddock
71
72 # We need second expansion for the way we handle directories, so that
73 # | $$$$(dir $$$$@)/.
74 # expands to the directory of a rule that uses a % pattern.
75 .SECONDEXPANSION:
76
77 default : all
78
79
80 ##################################################
81 # Check that we have a new enough 'make'
82
83 HAVE_EVAL := NO
84 $(eval HAVE_EVAL := YES)
85
86 ifeq "$(HAVE_EVAL)" "NO"
87 $(error Your make does not support eval. You need GNU make >= 3.81)
88 endif
89
90 ifeq "$(abspath /)" ""
91 $(error Your make does not support abspath. You need GNU make >= 3.81)
92 endif
93 ##################################################
94
95
96 # Catch make if it runs away into an infinite loop
97 ifeq "$(MAKE_RESTARTS)" ""
98 else ifeq "$(MAKE_RESTARTS)" "1"
99 else
100 $(error Make has restarted itself $(MAKE_RESTARTS) times; is there a makefile bug? See http://ghc.haskell.org/trac/ghc/wiki/Building/Troubleshooting#Makehasrestarteditself3timesisthereamakefilebug for details)
101 endif
102
103 # -----------------------------------------------------------------------------
104 # Misc GNU make utils
105
106 nothing=
107 space=$(nothing) $(nothing)
108 comma=,
109
110 # -----------------------------------------------------------------------------
111 # Makefile debugging
112 #
113 # to see the effective value used for a Makefile variable, do
114 # make show VALUE=MY_VALUE
115 #
116
117 show:
118 @echo '$(VALUE)="$($(VALUE))"'
119
120 # echo is used by the nightly builders to query the build system for
121 # information.
122 # Using printf means that we don't get a trailing newline. We escape
123 # backslashes and double quotes in the string to protect them from the
124 # shell, and percent signs to protect them from printf.
125 echo:
126 @printf "$(subst %,%%,$(subst ",\",$(subst \,\\\\,$($(VALUE)))))"
127
128 # -----------------------------------------------------------------------------
129 # Include subsidiary build-system bits
130
131 include mk/tree.mk
132
133 ifneq "$(CLEANING)" "YES"
134 include mk/config.mk
135 ifeq "$(ProjectVersion)" ""
136 $(error Please run ./configure first)
137 endif
138 endif
139
140 include mk/ways.mk
141 include mk/warnings.mk
142
143 # (Optional) build-specific configuration
144 include mk/custom-settings.mk
145 SRC_CC_OPTS += -Wall
146 SRC_HC_OPTS += -Wall
147 # Don't add -Werror to GhcStage1HcOpts, because otherwise validate may
148 # unnecessarily fail during the stage1 build when booting with an older
149 # compiler.
150 # It would be better to only exclude certain warnings from becoming errors
151 # (e.g. '-Werror -Wno-error=unused-imports -Wno-error=...'), but -Wno-error
152 # isn't supported yet (https://ghc.haskell.org/trac/ghc/wiki/Design/Warnings).
153 SRC_CC_OPTS += $(WERROR)
154 GhcStage2HcOpts += $(WERROR)
155 GhcLibHcOpts += $(WERROR)
156
157 # -----------------------------------------------------------------------------
158 # Check for inconsistent settings, after reading mk/build.mk.
159 # Although mk/config.mk should always contain consistent settings (set by
160 # configure), mk/build.mk can contain pretty much anything.
161
162 ifneq "$(CLEANING)" "YES"
163
164 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
165 ifeq "$(findstring dyn,$(GhcLibWays))" ""
166 $(error dyn is not in $$(GhcLibWays), but $$(DYNAMIC_GHC_PROGRAMS) is YES)
167 endif
168 else
169 ifeq "$(findstring v,$(GhcLibWays))" ""
170 $(error v is not in $$(GhcLibWays), and $$(DYNAMIC_GHC_PROGRAMS) is not YES)
171 endif
172 endif
173
174 ifeq "$(GhcProfiled)" "YES"
175 ifeq "$(findstring p,$(GhcLibWays))" ""
176 $(error p is not in $$(GhcLibWays), and $$(GhcProfiled) is YES)
177 endif
178 endif
179
180 ifeq "$(BUILD_SPHINX_HTML)" "YES"
181 ifeq "$(SPHINXBUILD)" ""
182 $(error BUILD_SPHINX_HTML=YES, but `sphinx-build` was not found. \
183 Create a file `mk/validate.mk` containing `BUILD_SPHINX_HTML=NO` \
184 (when validating), or install `sphinx-build` and rerun `./configure`. \
185 See https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation)
186 endif
187 endif
188
189 ifeq "$(BUILD_SPHINX_PDF)" "YES"
190 ifeq "$(XELATEX)" ""
191 $(error BUILD_SPHINX_PDF=YES, but `xelatex` was not found. \
192 Install `xelatex`, then rerun `./configure`. \
193 See https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation)
194 endif
195 endif
196
197 ifeq "$(HSCOLOUR_SRCS)" "YES"
198 ifeq "$(HSCOLOUR_CMD)" ""
199 $(error HSCOLOUR_SRCS=YES, but HSCOLOUR_CMD is empty. \
200 Run `cabal install hscolour`, then rerun `./configure`. \
201 See https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation)
202 endif
203 endif
204
205 endif # CLEANING
206
207 # -----------------------------------------------------------------------------
208
209 ifeq "$(phase)" ""
210 phase = final
211 endif
212
213 # -----------------------------------------------------------------------------
214 # Utility definitions
215
216 include rules/prof.mk
217 include rules/trace.mk
218 include rules/library-path.mk
219 include rules/add-dependency.mk
220 include rules/make-command.mk
221 include rules/pretty_commands.mk
222
223 # -----------------------------------------------------------------------------
224 # Macros for standard targets
225
226 include rules/all-target.mk
227 include rules/clean-target.mk
228
229 # -----------------------------------------------------------------------------
230 # The inplace tree
231
232 $(eval $(call clean-target,root,inplace,inplace/bin inplace/lib))
233
234 # -----------------------------------------------------------------------------
235 # Whether to build dependencies or not
236
237 # When we're just doing 'make clean' or 'make show', then we don't need
238 # to build dependencies.
239
240 ifeq "$(CLEANING)" "YES"
241 NO_INCLUDE_DEPS = YES
242 NO_INCLUDE_PKGDATA = YES
243 endif
244 ifneq "$(findstring bootstrapping-files,$(MAKECMDGOALS))" ""
245 NO_INCLUDE_DEPS = YES
246 NO_INCLUDE_PKGDATA = YES
247 endif
248 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
249 NO_INCLUDE_DEPS = YES
250 # We want package-data.mk for show
251 endif
252
253 # -----------------------------------------------------------------------------
254 # Ways
255
256 include rules/way-prelims.mk
257
258 $(foreach way,$(ALL_WAYS),\
259 $(eval $(call way-prelims,$(way))))
260
261 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
262 GHCI_WAY = dyn
263 HADDOCK_WAY = dyn
264 else
265 GHCI_WAY = v
266 HADDOCK_WAY = v
267 endif
268
269 WINDOWS_DYN_PROG_RTS := rts
270 ifeq "$(GhcThreaded)" "YES"
271 WINDOWS_DYN_PROG_RTS := $(WINDOWS_DYN_PROG_RTS)_thr
272 endif
273 ifeq "$(GhcDebugged)" "YES"
274 WINDOWS_DYN_PROG_RTS := $(WINDOWS_DYN_PROG_RTS)_debug
275 endif
276 WINDOWS_DYN_PROG_RTS := $(WINDOWS_DYN_PROG_RTS)_dyn_LIB_FILE
277
278 # -----------------------------------------------------------------------------
279 # Compilation Flags
280
281 include rules/distdir-opts.mk
282 include rules/distdir-way-opts.mk
283
284 # -----------------------------------------------------------------------------
285 # Finding source files and object files
286
287 include rules/hs-sources.mk
288 include rules/c-sources.mk
289 include rules/includes-sources.mk
290 include rules/hs-objs.mk
291 include rules/c-objs.mk
292 include rules/cmm-objs.mk
293
294 # -----------------------------------------------------------------------------
295 # Suffix rules
296
297 # Suffix rules cause "make clean" to fail on Windows (trac #3233)
298 # so we don't make any when cleaning.
299 ifneq "$(CLEANING)" "YES"
300 include rules/hs-suffix-rules-srcdir.mk
301 include rules/hs-suffix-way-rules-srcdir.mk
302 include rules/hs-suffix-way-rules.mk
303 include rules/hi-rule.mk
304 include rules/c-suffix-rules.mk
305 include rules/cmm-suffix-rules.mk
306 endif
307
308 # -----------------------------------------------------------------------------
309 # Building package-data.mk files from .cabal files
310
311 include rules/package-config.mk
312
313 # -----------------------------------------------------------------------------
314 # Building dependencies
315
316 include rules/dependencies.mk
317 include rules/build-dependencies.mk
318 include rules/include-dependencies.mk
319
320 # -----------------------------------------------------------------------------
321 # Build package-data.mk files
322
323 include rules/build-package-data.mk
324
325 # -----------------------------------------------------------------------------
326 # Build and install a program
327
328 include rules/build-prog.mk
329 include rules/shell-wrapper.mk
330
331 # -----------------------------------------------------------------------------
332 # Build a perl script
333
334 include rules/build-perl.mk
335
336 # -----------------------------------------------------------------------------
337 # Build a package
338
339 include rules/build-package.mk
340 include rules/build-package-way.mk
341 include rules/haddock.mk
342 include rules/tags-package.mk
343 include rules/foreachLibrary.mk
344
345 # -----------------------------------------------------------------------------
346 # Registering hand-written package descriptions (used in rts)
347
348 include rules/manual-package-config.mk
349
350 # -----------------------------------------------------------------------------
351 # Docs
352
353 include rules/sphinx.mk
354
355 # -----------------------------------------------------------------------------
356 # Making bindists and sdists
357
358 include rules/bindist.mk
359 include rules/sdist-ghc-file.mk
360
361 # -----------------------------------------------------------------------------
362 # Directories
363
364 # Don't try to delete directories:
365 .PRECIOUS: %/.
366
367 # Create build directories on demand. NB. the | below: this indicates
368 # that $(MKDIRHIER) is an order-only dependency, which means that this
369 # rule fires after building mkdirhier, but we won't try to recreate
370 # directories if mkdirhier changes.
371 %/. : | $(MKDIRHIER)
372 "$(MKDIRHIER)" $@
373
374 # -----------------------------------------------------------------------------
375 # Lax dependencies
376
377 ifeq "$(LAX_DEPENDENCIES)" "YES"
378 LAX_DEPS_FOLLOW = |
379 else
380 LAX_DEPS_FOLLOW =
381 endif
382
383 # This is a bit of a hack. When LAX_DEPS_FOLLOW is | some rules end up
384 # looking like
385 # target: a | b | c
386 # The first | signals the start of the order-only dependencies, but make
387 # treats the second | as a dependency. So we need to tell make how to
388 # build that dependency.
389
390 .PHONY: |
391 | :
392 @:
393
394 # -----------------------------------------------------------------------------
395 # Packages to build
396 # The lists of packages that we *actually* going to build in each stage:
397 #
398 # $(PACKAGES_STAGE0)
399 # $(PACKAGES_STAGE1)
400 # $(PACKAGES_STAGE2)
401 #
402 # Note that we need to add them to these variables in dependency
403 # order, as this is the order that they get configured in.
404
405 ifeq "$(CLEANING)" "YES"
406
407 define addLibraryForCleaning
408 # We just add all packages to both the stage 0 and stage 1 lists.
409 # Stage 2 gets cleaned in the same way as stage 1, so no need to
410 # add it there.
411 PACKAGES_STAGE0 += $1
412 PACKAGES_STAGE1 += $1
413 endef
414 $(eval $(call foreachLibrary,addLibraryForCleaning))
415
416 else # CLEANING
417
418 # Packages that are built by stage0. These packages are dependencies of
419 # programs such as GHC and ghc-pkg, that we do not assume the stage0
420 # compiler already has installed (or up-to-date enough).
421
422 PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot hoopl transformers template-haskell
423 ifeq "$(Windows_Host)" "NO"
424 ifneq "$(HostOS_CPP)" "ios"
425 PACKAGES_STAGE0 += terminfo
426 endif
427 endif
428
429 PACKAGES_STAGE1 += ghc-prim
430 PACKAGES_STAGE1 += $(INTEGER_LIBRARY)
431 PACKAGES_STAGE1 += base
432 PACKAGES_STAGE1 += filepath
433 PACKAGES_STAGE1 += array
434 PACKAGES_STAGE1 += deepseq
435 PACKAGES_STAGE1 += bytestring
436 PACKAGES_STAGE1 += containers
437
438 ifeq "$(Windows_Host)" "YES"
439 PACKAGES_STAGE1 += Win32
440 endif
441 PACKAGES_STAGE1 += time
442 ifeq "$(Windows_Host)" "NO"
443 PACKAGES_STAGE1 += unix
444 endif
445
446 PACKAGES_STAGE1 += directory
447 PACKAGES_STAGE1 += process
448 PACKAGES_STAGE1 += hpc
449 PACKAGES_STAGE1 += pretty
450 PACKAGES_STAGE1 += binary
451 PACKAGES_STAGE1 += Cabal/Cabal
452 PACKAGES_STAGE1 += ghc-boot
453 PACKAGES_STAGE1 += template-haskell
454 PACKAGES_STAGE1 += hoopl
455 PACKAGES_STAGE1 += transformers
456
457 ifeq "$(HADDOCK_DOCS)" "YES"
458 PACKAGES_STAGE1 += xhtml
459 endif
460
461 ifeq "$(Windows_Target)" "NO"
462 ifneq "$(TargetOS_CPP)" "ios"
463 PACKAGES_STAGE1 += terminfo
464 endif
465 endif
466 PACKAGES_STAGE1 += haskeline
467
468 # See Note [No stage2 packages when CrossCompiling or Stage1Only].
469 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
470 ifeq "$(CrossCompiling) $(Stage1Only)" "NO NO"
471 define addExtraPackage
472 ifeq "$2" "-"
473 # Do nothing; this package is already handled above
474 else ifeq "$2" "dph"
475 ifeq "$$(BUILD_DPH) $$(GhcProfiled)" "YES NO"
476 # The DPH packages need TH, which is incompatible with a profiled GHC.
477 PACKAGES_STAGE2 += $1
478 endif
479 else ifeq "$2" "extra"
480 ifeq "$$(BUILD_EXTRA_PKGS)" "YES"
481 PACKAGES_STAGE2 += $1
482 endif
483 else
484 $$(error Unknown package tag: $2)
485 endif
486 endef
487 $(eval $(call foreachLibrary,addExtraPackage))
488 endif
489
490 # We install all packages that we build.
491 INSTALL_PACKAGES := $(addprefix libraries/,$(PACKAGES_STAGE1))
492 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
493 ifneq "$(Stage1Only)" "YES"
494 INSTALL_PACKAGES += compiler
495 endif
496 INSTALL_PACKAGES += $(addprefix libraries/,$(PACKAGES_STAGE2))
497
498 endif # CLEANING
499
500 # -------------------------------------------
501 # Note [Dependencies between package-data.mk files].
502
503 # We cannot run ghc-cabal to configure a package until we have
504 # configured and registered all of its dependencies. So the following
505 # hack forces all the configure steps to happen in exactly the following order:
506 #
507 # $(PACKAGES_STAGE1) ghc(stage2) $(PACKAGES_STAGE2)
508 #
509 # Ideally we should use the correct dependencies here to allow more
510 # parallelism, but we don't know the dependencies until we've
511 # generated the package-data.mk files.
512 define fixed_pkg_dep
513 libraries/$1/$2/package-data.mk : $$(fixed_pkg_prev)
514 fixed_pkg_prev:=libraries/$1/$2/package-data.mk
515 endef
516
517 ifneq "$(BINDIST)" "YES"
518 fixed_pkg_prev=
519 $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
520
521 # Intermezzo: utils that we build with the stage1 compiler. They depend on
522 # the stage1 packages, so we have to make sure those packages get configured
523 # and registered before we can start with these. Note that they don't depend on
524 # eachother, so we can configure them in parallel.
525 utils/ghc-pwd/dist-install/package-data.mk: $(fixed_pkg_prev)
526 utils/ghc-cabal/dist-install/package-data.mk: $(fixed_pkg_prev)
527 utils/hpc/dist-install/package-data.mk: $(fixed_pkg_prev)
528 utils/ghc-pkg/dist-install/package-data.mk: $(fixed_pkg_prev)
529 utils/hsc2hs/dist-install/package-data.mk: $(fixed_pkg_prev)
530 utils/compare_sizes/dist-install/package-data.mk: $(fixed_pkg_prev)
531 utils/runghc/dist-install/package-data.mk: $(fixed_pkg_prev)
532
533 # the GHC package doesn't live in libraries/, so we add its dependency manually:
534 compiler/stage2/package-data.mk: $(fixed_pkg_prev)
535
536 # and continue with PACKAGES_STAGE2, which depend on GHC:
537 fixed_pkg_prev:=compiler/stage2/package-data.mk
538 $(foreach pkg,$(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
539
540 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
541 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
542
543 # Utils that we build with the stage2 compiler.
544 # They depend on the ghc library and some other libraries, but depending on
545 # the ghc library's package-data.mk is sufficient, as that in turn depends on
546 # all the other libraries' package-data.mk files.
547 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
548 utils/ghctags/dist-install/package-data.mk: compiler/stage2/package-data.mk
549 utils/check-api-annotations/dist-install/package-data.mk: compiler/stage2/package-data.mk
550 utils/mkUserGuidePart/dist/package-data.mk: compiler/stage2/package-data.mk
551
552 # add the final package.conf dependency: ghc-prim depends on RTS
553 libraries/ghc-prim/dist-install/package-data.mk : rts/dist/package.conf.inplace
554 endif
555
556 # --------------------------------
557 # Misc package-related settings
558
559 # Run Haddock for the packages that will be installed. We need to handle
560 # compiler specially due to the different dist directory name.
561 $(foreach p,$(INSTALL_PACKAGES),$(eval $p_dist-install_DO_HADDOCK = YES))
562 compiler_stage2_DO_HADDOCK = YES
563
564 BOOT_PKG_CONSTRAINTS := \
565 $(foreach d,$(PACKAGES_STAGE0),\
566 $(foreach p,$(basename $(notdir $(wildcard libraries/$d/*.cabal))),\
567 --constraint "$p == $(shell grep -i "^Version:" libraries/$d/$p.cabal | sed "s/[^0-9.]//g")"))
568
569 # The actual .a and .so/.dll files: needed for dependencies.
570 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_v_LIB))
571 ifeq "$(BuildSharedLibs)" "YES"
572 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_dyn_LIB))
573 endif
574 BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB))
575
576 # ----------------------------------------
577 # Special magic for the ghc-prim package
578
579 # We want the ghc-prim package to include the GHC.Prim module when it
580 # is registered, but not when it is built, because GHC.Prim is not a
581 # real source module, it is built-in to GHC. The old build system did
582 # this using Setup.hs, but we can't do that here, so we have a flag to
583 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
584 # remains compatible with the old build system for the time being).
585 # GHC.Prim module in the ghc-prim package with a flag:
586 #
587 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
588
589 # And then we strip it out again before building the package:
590 define libraries/ghc-prim_PACKAGE_MAGIC
591 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
592 endef
593
594 PRIMOPS_TXT_STAGE1 = compiler/stage1/build/primops.txt
595
596 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
597 "$(genprimopcode_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
598
599 # Required so that Haddock documents the primops.
600 libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
601
602 # ----------------------------------------
603 # Special magic for the integer package
604
605 ifneq "$(CLEANING)" "YES"
606 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
607 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-gmp
608 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
609 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
610 else
611 $(error Unknown integer library: $(INTEGER_LIBRARY))
612 endif
613 endif
614
615 # -----------------------------------------------------------------------------
616 # Include build instructions from all subdirs
617 BUILD_DIRS += utils/mkdirhier
618 BUILD_DIRS += utils/touchy
619 BUILD_DIRS += utils/unlit
620 BUILD_DIRS += utils/hp2ps
621 BUILD_DIRS += driver/split
622 BUILD_DIRS += utils/genprimopcode
623 BUILD_DIRS += driver
624 BUILD_DIRS += driver/ghci
625 BUILD_DIRS += driver/ghc
626 BUILD_DIRS += driver/haddock
627 BUILD_DIRS += libffi
628 BUILD_DIRS += utils/deriveConstants
629 BUILD_DIRS += includes
630 BUILD_DIRS += rts
631 BUILD_DIRS += bindisttest
632 BUILD_DIRS += utils/genapply
633
634 # When cleaning, don't add any library packages to BUILD_DIRS. We include
635 # ghc.mk files for all BUILD_DIRS, but they don't exist until after running
636 # `./boot`. Running `make clean` before anything else, as well as running
637 # `make maintainer-clean` twice, should work.
638 ifneq "$(CLEANING)" "YES"
639 # These are deliberately in reverse order, so as to ensure that
640 # there is no need to have them in dependency order. That's important
641 # because it's tricky to ensure that they are in dependency order when
642 # cross-compiling, as some packages may only be in PACKAGES_STAGE0
643 # or PACKAGES_STAGE1.
644 BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE2))
645 BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1))
646 BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0)))
647 ifeq "$(BUILD_DPH)" "YES"
648 # Note: `$(eval $(call foreachLibrary,addExtraPackage))` above adds the
649 # packages listed in `libraries/dph/ghc-packages` (e.g. dph-base) to
650 # PACKAGES_STAGE2. But not 'libraries/dph' itself (it doesn't have a cabal
651 # file). Since it does have a ghc.mk file, we add it to BUILD_DIRS here.
652 BUILD_DIRS += $(wildcard libraries/dph)
653 endif
654 endif
655
656 BUILD_DIRS += libraries/integer-gmp/gmp
657 BUILD_DIRS += utils/haddock
658 BUILD_DIRS += utils/haddock/doc
659 BUILD_DIRS += compiler
660 BUILD_DIRS += utils/hsc2hs
661 BUILD_DIRS += utils/ghc-pkg
662 BUILD_DIRS += utils/testremove
663 BUILD_DIRS += utils/ghctags
664 BUILD_DIRS += utils/check-api-annotations
665 BUILD_DIRS += utils/dll-split
666 BUILD_DIRS += utils/ghc-pwd
667 BUILD_DIRS += utils/ghc-cabal
668 BUILD_DIRS += utils/hpc
669 BUILD_DIRS += utils/runghc
670 BUILD_DIRS += ghc
671 BUILD_DIRS += utils/mkUserGuidePart
672 BUILD_DIRS += docs/users_guide
673 BUILD_DIRS += utils/count_lines
674 BUILD_DIRS += utils/compare_sizes
675
676 # ----------------------------------------------
677 # Actually include the sub-ghc.mk's
678
679 ifeq "$(CLEANING)" "YES"
680 # Don't exclude any BUILD_DIRS when cleaning. When you for example build
681 # haddock once, but later set HADDOCK_DOCS back to NO, then 'make clean'
682 # should still clean the haddock directory.
683 else # CLEANING
684 ifeq "$(BINDIST)" "YES"
685 BUILD_DIRS := $(filter-out utils/mkdirhier,$(BUILD_DIRS))
686 BUILD_DIRS := $(filter-out utils/genprimopcode,$(BUILD_DIRS))
687 BUILD_DIRS := $(filter-out bindisttest,$(BUILD_DIRS))
688 BUILD_DIRS := $(filter-out utils/genapply,$(BUILD_DIRS))
689 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
690 endif
691 ifeq "$(HADDOCK_DOCS)" "NO"
692 BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
693 BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
694 endif
695 ifeq "$(BUILD_SPHINX_HTML) $(BUILD_SPHINX_PDF)" "NO NO NO"
696 # Don't to build this little utility if we're not building the User's Guide.
697 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
698 endif
699 ifeq "$(Windows_Host)" "NO"
700 BUILD_DIRS := $(filter-out utils/touchy,$(BUILD_DIRS))
701 endif
702 ifeq "$(GhcUnregisterised)" "YES"
703 BUILD_DIRS := $(filter-out driver/split,$(BUILD_DIRS))
704 endif
705 ifeq "$(GhcWithInterpreter)" "NO"
706 # runghc is just GHCi in disguise
707 BUILD_DIRS := $(filter-out utils/runghc,$(BUILD_DIRS))
708 endif
709 ifneq "$(INTEGER_LIBRARY)" "integer-gmp"
710 BUILD_DIRS := $(filter-out libraries/integer-gmp/gmp,$(BUILD_DIRS))
711 endif
712 ifneq "$(CrossCompiling) $(Stage1Only)" "NO NO"
713 # See Note [No stage2 packages when CrossCompiling or Stage1Only].
714 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
715 BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
716 BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
717 BUILD_DIRS := $(filter-out utils/ghctags,$(BUILD_DIRS))
718 BUILD_DIRS := $(filter-out utils/check-api-annotations,$(BUILD_DIRS))
719 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
720 endif
721 endif # CLEANING
722
723 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
724
725 # A useful pseudo-target (must be after the include above, because it needs
726 # the value of things like $(libraries/base_dist-install_v_LIB).
727 .PHONY: stage1_libs
728 stage1_libs : $(ALL_STAGE1_LIBS)
729
730 # ----------------------------------------------
731 # Per-package compiler flags
732 #
733 # If you want to add per-package compiler flags, see `mk/warnings.mk`.
734
735 # Add $(GhcLib(Extra)HcOpts) to all package builds
736 $(foreach pkg,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
737 $(foreach pkg,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_EXTRA_HC_OPTS += $$(GhcLibExtraHcOpts)))
738
739 # Add $(GhcBootLib(Extra)HcOpts) to all stage0 package builds
740 $(foreach pkg,$(PACKAGES_STAGE0),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
741 $(foreach pkg,$(PACKAGES_STAGE0),$(eval libraries/$(pkg)_dist-boot_EXTRA_HC_OPTS += $$(GhcBootLibExtraHcOpts)))
742
743 # -----------------------------------------------------------------------------
744 # Bootstrapping libraries
745
746 # We need to build a few libraries with the installed GHC, since GHC itself
747 # and some of the tools depend on them:
748
749 ifneq "$(BINDIST)" "YES"
750
751 ifneq "$(BOOTSTRAPPING_CONF)" ""
752 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
753 $(shell "$(GHC_PKG)" init $(BOOTSTRAPPING_CONF))
754 endif
755 endif
756
757 $(eval $(call clean-target,root,bootstrapping_conf,$(BOOTSTRAPPING_CONF)))
758
759 # register the boot packages in strict sequence, because running
760 # multiple ghc-pkgs in parallel doesn't work (registrations may get
761 # lost).
762 fixed_pkg_prev=
763 $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
764 # ghc-pkg, unlike other utils that we build with the stage0 compiler (TODO: is
765 # this really true?), depends on several boot packages (e.g. Cabal and
766 # ghc-boot). They need to be configured before ghc-pkg, so we add a
767 # dependency between their package-data.mk files. See also Note
768 # [Dependencies between package-data.mk files].
769 utils/ghc-pkg/dist/package-data.mk: $(fixed_pkg_prev)
770 compiler/stage1/package-data.mk: $(fixed_pkg_prev)
771 endif
772
773 ifneq "$(BINDIST)" "YES"
774 # Make sure we have all the GHCi libs by the time we've built
775 # ghc-stage2. DPH includes a bit of Template Haskell which needs the
776 # GHCi libs, and we don't have a better way to express that dependency.
777 #
778 GHCI_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_GHCI_LIB)) \
779 $(compiler_stage2_GHCI_LIB)
780
781 ifeq "$(UseArchivesForGhci)" "NO"
782 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(GHCI_LIBS)
783 endif
784
785 ifeq "$(UseArchivesForGhci)" "YES"
786 GHCI_lib_way = v
787 else
788 GHCI_lib_way = GHCI
789 endif
790
791 # Deps for TH uses in libraries
792 $(foreach way, $(GhcLibWays),$(eval \
793 libraries/vector/dist-install/build/Data/Vector/Fusion/Stream/Monadic.$($(way)_osuf): \
794 $(libraries/primitive_dist-install_$(GHCI_lib_way)_LIB) \
795 ))
796 endif
797
798 # -----------------------------------------------
799 # Haddock-related bits
800
801 # Build the Haddock contents and index
802 ifeq "$(HADDOCK_DOCS)" "YES"
803 libraries/dist-haddock/index.html: $(haddock_INPLACE) $(ALL_HADDOCK_FILES)
804 cd libraries && sh gen_contents_index --intree
805 ifeq "$(phase)" "final"
806 $(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
807 endif
808 INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
809 endif
810
811 # -----------------------------------------------------------------------------
812 # Creating a local mingw copy on Windows
813
814 ifeq "$(Windows_Host)" "YES"
815
816 install : install_mingw
817 .PHONY: install_mingw
818 install_mingw : $(INPLACE_MINGW)
819 "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
820
821 install : install_perl
822 .PHONY: install_perl
823 install_perl : $(INPLACE_PERL)
824 "$(CP)" -Rp $(INPLACE_PERL) $(prefix)
825
826 endif # Windows_Host
827
828 ifneq "$(BINDIST)" "YES"
829 $(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \
830 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
831 endif # BINDIST
832
833 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
834 $(PRIMOPS_TXT_STAGE1) $$(genprimopcode_INPLACE) \
835 | $$(dir $$@)/.
836 "$(genprimopcode_INPLACE)" --make-haskell-source < $< > $@
837
838 .PHONY: tags
839 tags: tags_compiler
840
841 .PHONY: TAGS
842 TAGS: TAGS_compiler
843
844 # -----------------------------------------------------------------------------
845 # Installation
846
847 install: install_libs install_packages install_libexecs \
848 install_bins install_topdirs
849 ifeq "$(HADDOCK_DOCS)" "YES"
850 install: install_docs
851 endif
852
853 define installLibsTo
854 # $1 = libraries to install
855 # $2 = directory to install to
856 #
857 # The .dll case calls STRIP_CMD explicitly, instead of `install -s`, because
858 # on Win64, "install -s" calls a strip that doesn't understand 64bit binaries.
859 # For some reason, this means the DLLs end up non-executable, which means
860 # executables that use them just segfault.
861 $(INSTALL_DIR) $2
862 for i in $1; do \
863 case $$i in \
864 *.a) \
865 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $2; \
866 $(RANLIB_CMD) $2/`basename $$i` ;; \
867 *.dll) \
868 $(INSTALL_PROGRAM) $(INSTALL_OPTS) $$i $2 ; \
869 $(STRIP_CMD) $2/`basename $$i` ;; \
870 *.so) \
871 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $2 ;; \
872 *.dylib) \
873 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $2;; \
874 *) \
875 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $2; \
876 esac; \
877 done
878 endef
879
880 install_bins: $(INSTALL_BINS) $(INSTALL_SCRIPTS)
881 $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
882 for i in $(INSTALL_BINS); do \
883 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(bindir)" ; \
884 done
885 for i in $(INSTALL_SCRIPTS); do \
886 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i "$(DESTDIR)$(bindir)" ; \
887 done
888
889 install_libs: $(INSTALL_LIBS)
890 $(call installLibsTo, $(INSTALL_LIBS), "$(DESTDIR)$(ghclibdir)")
891
892 install_libexecs: $(INSTALL_LIBEXECS)
893 ifeq "$(INSTALL_LIBEXECS)" ""
894 @:
895 else
896 $(INSTALL_DIR) "$(DESTDIR)$(ghclibexecdir)/bin"
897 for i in $(INSTALL_LIBEXECS); do \
898 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(ghclibexecdir)/bin"; \
899 done
900 # We rename ghc-stage2, so that the right program name is used in error
901 # messages etc.
902 "$(MV)" "$(DESTDIR)$(ghclibexecdir)/bin/ghc-stage$(INSTALL_GHC_STAGE)" "$(DESTDIR)$(ghclibexecdir)/bin/ghc"
903 endif
904
905 install_topdirs: $(INSTALL_TOPDIR_BINS) $(INSTALL_TOPDIR_SCRIPTS)
906 $(INSTALL_DIR) "$(DESTDIR)$(topdir)"
907 for i in $(INSTALL_TOPDIR_BINS); do \
908 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(topdir)"; \
909 done
910 for i in $(INSTALL_TOPDIR_SCRIPTS); do \
911 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i "$(DESTDIR)$(topdir)"; \
912 done
913
914 install_docs: $(INSTALL_DOCS)
915 $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
916 ifneq "$(INSTALL_DOCS)" ""
917 for i in $(INSTALL_DOCS); do \
918 $(INSTALL_DOC) $(INSTALL_OPTS) $$i "$(DESTDIR)$(docdir)"; \
919 done
920 endif
921 $(INSTALL_DIR) "$(DESTDIR)$(docdir)/html"
922 $(INSTALL_DOC) $(INSTALL_OPTS) docs/index.html "$(DESTDIR)$(docdir)/html"
923 ifneq "$(INSTALL_LIBRARY_DOCS)" ""
924 $(INSTALL_DIR) "$(DESTDIR)$(docdir)/html/libraries"
925 for i in $(INSTALL_LIBRARY_DOCS); do \
926 $(INSTALL_DOC) $(INSTALL_OPTS) $$i "$(DESTDIR)$(docdir)/html/libraries/"; \
927 done
928 $(INSTALL_DATA) $(INSTALL_OPTS) libraries/prologue.txt "$(DESTDIR)$(docdir)/html/libraries/"
929 $(INSTALL_SCRIPT) $(INSTALL_OPTS) libraries/gen_contents_index "$(DESTDIR)$(docdir)/html/libraries/"
930 endif
931 ifneq "$(INSTALL_HTML_DOC_DIRS)" ""
932 for i in $(INSTALL_HTML_DOC_DIRS); do \
933 $(INSTALL_DIR) "$(DESTDIR)$(docdir)/html/`basename $$i`"; \
934 for f in $$i/*; do \
935 # We filter out the directories so install doesn't choke on them \
936 if test -f $$f; then \
937 $(INSTALL_DOC) $(INSTALL_OPTS) "$$f" "$(DESTDIR)$(docdir)/html/`basename $$i`"; \
938 fi \
939 done \
940 done
941 endif
942
943 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
944
945 # Install packages in the right order, so that ghc-pkg doesn't complain.
946 # Also, install ghc-pkg first.
947 ifeq "$(Windows_Host)" "NO"
948 INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc
949 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc-pkg
950 else
951 INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
952 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
953 endif
954
955 # Set the INSTALL_DISTDIR_p for each package; compiler is special
956 $(foreach p,$(filter-out compiler,$(INSTALL_PACKAGES)),\
957 $(eval INSTALL_DISTDIR_$p = dist-install))
958 INSTALL_DISTDIR_compiler = stage2
959
960 # Now we can do the installation
961 install_packages: install_libexecs
962 install_packages: rts/dist/package.conf.install
963 $(INSTALL_DIR) "$(DESTDIR)$(topdir)"
964 $(call removeTrees,"$(INSTALLED_PACKAGE_CONF)")
965 $(INSTALL_DIR) "$(INSTALLED_PACKAGE_CONF)"
966 $(INSTALL_DIR) "$(DESTDIR)$(topdir)/rts"
967 $(call installLibsTo, $(RTS_INSTALL_LIBS), "$(DESTDIR)$(topdir)/rts")
968 $(foreach p, $(INSTALL_PACKAGES), \
969 $(call make-command, \
970 "$(ghc-cabal_INPLACE)" copy \
971 $p $(INSTALL_DISTDIR_$p) \
972 "$(STRIP_CMD)" \
973 '$(DESTDIR)' \
974 '$(prefix)' \
975 '$(ghclibdir)' \
976 '$(docdir)/html/libraries' \
977 '$(GhcLibWays)'))
978 "$(INSTALLED_GHC_PKG_REAL)" --force --global-package-db "$(INSTALLED_PACKAGE_CONF)" update rts/dist/package.conf.install
979 $(foreach p, $(INSTALL_PACKAGES), \
980 $(call make-command, \
981 "$(ghc-cabal_INPLACE)" register \
982 $p $(INSTALL_DISTDIR_$p) \
983 "$(INSTALLED_GHC_REAL)" \
984 "$(INSTALLED_GHC_PKG_REAL)" \
985 "$(DESTDIR)$(topdir)" \
986 '$(DESTDIR)' \
987 '$(prefix)' \
988 '$(ghclibdir)' \
989 '$(docdir)/html/libraries' \
990 $(RelocatableBuild)))
991 # when we install the packages above, ghc-pkg obeys umask when creating
992 # the package.conf files, but for everything else we specify the
993 # permissions. We therefore now fix the permissions of package.cache.
994 # This means "sudo make install" does the right thing even if it runs
995 # with an 077 umask.
996 for f in '$(INSTALLED_PACKAGE_CONF)'/*; do $(CREATE_DATA) "$$f"; done
997
998 # -----------------------------------------------------------------------------
999 # Binary distributions
1000
1001 ifneq "$(CLEANING)" "YES"
1002 # This rule seems to hold some files open on Windows which prevents
1003 # cleaning, perhaps due to the $(wildcard).
1004
1005 $(eval $(call bindist-list,.,\
1006 LICENSE \
1007 README \
1008 INSTALL \
1009 configure config.sub config.guess install-sh \
1010 settings.in \
1011 packages \
1012 Makefile \
1013 mk/config.mk.in \
1014 $(INPLACE_BIN)/mkdirhier \
1015 utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
1016 utils/ghc-pwd/dist-install/build/tmp/ghc-pwd \
1017 $(BINDIST_WRAPPERS) \
1018 $(BINDIST_PERL_SOURCES) \
1019 $(BINDIST_LIBS) \
1020 $(BINDIST_HI) \
1021 $(BINDIST_EXTRAS) \
1022 $(includes_H_FILES) \
1023 $(includes_DERIVEDCONSTANTS) \
1024 $(includes_GHCCONSTANTS) \
1025 $(libffi_HEADERS) \
1026 $(INSTALL_LIBEXECS) \
1027 $(INSTALL_LIBEXEC_SCRIPTS) \
1028 $(INSTALL_TOPDIR_BINS) \
1029 $(INSTALL_TOPDIR_SCRIPTS) \
1030 $(INSTALL_BINS) \
1031 $(INSTALL_SCRIPTS) \
1032 $(INSTALL_MANPAGES) \
1033 $(INSTALL_DOCS) \
1034 $(INSTALL_LIBRARY_DOCS) \
1035 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
1036 docs/index.html \
1037 compiler/stage2/doc \
1038 $(wildcard libraries/*/dist-install/doc/) \
1039 $(wildcard libraries/*/*/dist-install/doc/) \
1040 $(filter-out settings,$(INSTALL_LIBS)) \
1041 $(RTS_INSTALL_LIBS) \
1042 $(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
1043 mk/project.mk \
1044 mk/install.mk.in \
1045 bindist.mk \
1046 libraries/gen_contents_index \
1047 libraries/prologue.txt \
1048 $(wildcard libraries/dph/LICENSE \
1049 libraries/dph/ghc-packages \
1050 libraries/dph/ghc-packages2 \
1051 libraries/dph/ghc-stage2-package) \
1052 ))
1053 endif
1054 # mk/project.mk gets an absolute path, so we manually include it in
1055 # the bindist with a relative path
1056
1057 BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
1058
1059 unix-binary-dist-prep:
1060 $(call removeTrees,bindistprep/)
1061 "$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
1062 set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
1063 echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
1064 echo "BUILD_SPHINX_HTML = $(BUILD_SPHINX_HTML)" >> $(BIN_DIST_MK)
1065 echo "BUILD_SPHINX_PDF = $(BUILD_SPHINX_PDF)" >> $(BIN_DIST_MK)
1066 echo "BUILD_MAN = $(BUILD_MAN)" >> $(BIN_DIST_MK)
1067 echo "override ghc-cabal_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" >> $(BIN_DIST_MK)
1068 echo "UseSystemLibFFI = $(UseSystemLibFFI)" >> $(BIN_DIST_MK)
1069 cd $(BIN_DIST_PREP_DIR) && autoreconf
1070 $(call removeFiles,$(BIN_DIST_PREP_TAR))
1071 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
1072 # tree then we want to include the real file, not a symlink to it
1073 cd bindistprep && "$(TAR_CMD)" hcf - -T ../bindist-list | $(TAR_COMP_CMD) -c > ../$(BIN_DIST_PREP_TAR_COMP)
1074
1075 windows-binary-dist-prep:
1076 $(call removeTrees,bindistprep/)
1077 $(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
1078 cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | $(TAR_COMP_CMD) -c > ../$(BIN_DIST_PREP_TAR_COMP)
1079
1080 # tryTimes tries to run its third argument multiple times, until it
1081 # succeeds. Don't call it directly; call try10Times instead.
1082 # The first and second argument to tryTimes are lists of values.
1083 # The length of the first argument is the number of times we have
1084 # already tried. The length of the second argument is the number more
1085 # times we will try.
1086 tryTimes = $(if $2, \
1087 { echo 'Try $(words x $1): $3' ; $3 ; } || \
1088 $(call tryTimes,x $1,$(wordlist 2,$(words $2),$2),$3), \
1089 )
1090
1091 # Try to run the argument 10 times. If all 10 fail, fail.
1092 try10Times = $(call tryTimes,,x x x x x x x x x x,$1) { echo Failed; false; }
1093
1094 .PHONY: publish-binary-dist
1095 publish-binary-dist:
1096 $(call try10Times,$(PublishCp) $(BIN_DIST_TAR_COMP) $(PublishLocation)/dist)
1097
1098 ifeq "$(mingw32_TARGET_OS)" "1"
1099 DOCDIR_TO_PUBLISH = $(BIN_DIST_INST_DIR)/doc
1100 else
1101 DOCDIR_TO_PUBLISH = $(BIN_DIST_INST_DIR)/share/doc/ghc
1102 endif
1103
1104 .PHONY: publish-docs
1105 publish-docs:
1106 $(call try10Times,$(PublishCp) -r $(DOCDIR_TO_PUBLISH)/* $(PublishLocation)/docs)
1107
1108 # -----------------------------------------------------------------------------
1109 # Source distributions
1110
1111 # Do it like this:
1112 #
1113 # $ ./boot
1114 # $ ./configure
1115 # $ make sdist
1116 #
1117
1118 # A source dist is built from a (partial) build tree, because we
1119 # require some extra files not contained in a git checkout: the
1120 # output from Happy and Alex, for example.
1121 #
1122 # The steps performed by 'make sdist' are as follows:
1123 # - build those extra files
1124 # - create a complete link-tree of the current build tree in /tmp
1125 # - run 'make distclean' on that tree
1126 # - remove a bunch of other files that we know shouldn't be in the dist
1127
1128 #
1129 # Directory in which we're going to build the src dist
1130 #
1131 SRC_DIST_ROOT = sdistprep
1132 SRC_DIST_BASE_NAME = ghc-$(ProjectVersion)
1133
1134 SRC_DIST_GHC_NAME = ghc-$(ProjectVersion)-src
1135 SRC_DIST_GHC_ROOT = $(SRC_DIST_ROOT)/ghc
1136 SRC_DIST_GHC_DIR = $(SRC_DIST_GHC_ROOT)/$(SRC_DIST_BASE_NAME)
1137 SRC_DIST_GHC_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_GHC_NAME).tar.$(TAR_COMP_EXT)
1138
1139 SRC_DIST_WINDOWS_TARBALLS_NAME = ghc-$(ProjectVersion)-windows-extra-src
1140 SRC_DIST_WINDOWS_TARBALLS_ROOT = $(SRC_DIST_ROOT)/windows-tarballs
1141 SRC_DIST_WINDOWS_TARBALLS_DIR = $(SRC_DIST_WINDOWS_TARBALLS_ROOT)/$(SRC_DIST_BASE_NAME)
1142 SRC_DIST_WINDOWS_TARBALLS_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_WINDOWS_TARBALLS_NAME).tar.$(TAR_COMP_EXT)
1143
1144 SRC_DIST_TESTSUITE_NAME = ghc-$(ProjectVersion)-testsuite
1145 SRC_DIST_TESTSUITE_ROOT = $(SRC_DIST_ROOT)/testsuite-ghc
1146 SRC_DIST_TESTSUITE_DIR = $(SRC_DIST_TESTSUITE_ROOT)/$(SRC_DIST_BASE_NAME)
1147 SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME).tar.$(TAR_COMP_EXT)
1148
1149 #
1150 # Files to include in source distributions
1151 #
1152 SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \
1153 utils docs rts compiler ghc driver libraries libffi-tarballs
1154 SRC_DIST_GHC_FILES += \
1155 configure.ac config.guess config.sub configure \
1156 aclocal.m4 README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \
1157 install-sh settings.in VERSION GIT_COMMIT_ID \
1158 boot packages ghc.mk MAKEHELP.md
1159
1160 .PHONY: VERSION
1161 VERSION:
1162 @if test -f $@ && test "`cat $@`" = "$(ProjectVersion)"; \
1163 then echo "$@ needs no update"; \
1164 else echo "update $@ ($(ProjectVersion))"; echo "$(ProjectVersion)" > $@; fi
1165
1166 .PHONY: GIT_COMMIT_ID
1167 GIT_COMMIT_ID:
1168 @if test -d .git && test "`git rev-parse HEAD`" != "$(ProjectGitCommitId)"; then \
1169 echo "******************************************************************************"; \
1170 echo "Stale ProjectGitCommitId (=$(ProjectGitCommitId)) detected!"; \
1171 echo "'git rev-parse HEAD' says: `git rev-parse HEAD`"; \
1172 echo "Please re-run './configure' before creating source-distribution"; \
1173 echo "******************************************************************************"; \
1174 exit 1; \
1175 fi
1176 @if test -f $@ && test "`cat $@`" = "$(ProjectGitCommitId)"; \
1177 then echo "$@ needs no update"; \
1178 else echo "update $@ ($(ProjectGitCommitId))"; echo -n "$(ProjectGitCommitId)" > $@; fi
1179
1180 sdist-ghc-prep-tree : VERSION GIT_COMMIT_ID
1181
1182 # Extra packages which shouldn't be in the source distribution: see #8801
1183 EXTRA_PACKAGES=parallel stm random primitive vector dph
1184
1185 .PHONY: sdist-ghc-prep-tree
1186 sdist-ghc-prep-tree :
1187 $(call removeTrees,$(SRC_DIST_GHC_ROOT))
1188 $(call removeFiles,$(SRC_DIST_GHC_TARBALL))
1189 mkdir -p $(SRC_DIST_ROOT)
1190 mkdir -p $(SRC_DIST_GHC_ROOT)
1191 mkdir -p $(SRC_DIST_GHC_DIR)
1192 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_DIRS); do mkdir -p $$i; ( cd $$i && lndir $(TOP)/$$i ); done
1193 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_FILES); do $(LN_S) $(TOP)/$$i .; done
1194 cd $(SRC_DIST_GHC_DIR) && $(MAKE) distclean
1195 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/tarballs/)
1196 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/stamp/)
1197 $(call removeTrees,$(SRC_DIST_GHC_DIR)/compiler/stage[123])
1198 $(call removeFiles,$(SRC_DIST_GHC_DIR)/mk/build.mk)
1199 for i in $(EXTRA_PACKAGES); do $(RM) $(RM_OPTS_REC) $(SRC_DIST_GHC_DIR)/libraries/$$i/; done
1200 cd $(SRC_DIST_GHC_DIR) && "$(FIND)" $(SRC_DIST_GHC_DIRS) \( -name .git -o -name "autom4te*" -o -name "*~" -o -name "\#*" -o -name ".\#*" -o -name "log" -o -name "*-SAVE" -o -name "*.orig" -o -name "*.rej" \) -print | "$(XARGS)" $(XARGS_OPTS) "$(RM)" $(RM_OPTS_REC)
1201
1202 # Add files generated by alex and happy.
1203 # These rules depend on sdist-ghc-prep-tree.
1204 $(eval $(call sdist-ghc-file,compiler,stage2,cmm,CmmLex,x))
1205 $(eval $(call sdist-ghc-file,compiler,stage2,cmm,CmmParse,y))
1206 $(eval $(call sdist-ghc-file,compiler,stage2,parser,Lexer,x))
1207 $(eval $(call sdist-ghc-file,compiler,stage2,parser,Parser,y))
1208 $(eval $(call sdist-ghc-file,utils/hpc,dist-install,,HpcParser,y))
1209 $(eval $(call sdist-ghc-file,utils/genprimopcode,dist,,Lexer,x))
1210 $(eval $(call sdist-ghc-file,utils/genprimopcode,dist,,Parser,y))
1211
1212 .PHONY: sdist-ghc-prep
1213 sdist-ghc-prep : sdist-ghc-prep-tree
1214
1215 .PHONY: sdist-windows-tarballs-prep
1216 sdist-windows-tarballs-prep :
1217 $(call removeTrees,$(SRC_DIST_WINDOWS_TARBALLS_ROOT))
1218 $(call removeFiles,$(SRC_DIST_WINDOWS_TARBALLS_TARBALL))
1219 mkdir -p $(SRC_DIST_ROOT)
1220 mkdir -p $(SRC_DIST_WINDOWS_TARBALLS_ROOT)
1221 mkdir -p $(SRC_DIST_WINDOWS_TARBALLS_DIR)
1222 mkdir -p $(SRC_DIST_WINDOWS_TARBALLS_DIR)/ghc-tarballs
1223 cd $(SRC_DIST_WINDOWS_TARBALLS_DIR)/ghc-tarballs && lndir $(TOP)/ghc-tarballs
1224 $(call removeTrees,$(SRC_DIST_WINDOWS_TARBALLS_DIR)/ghc-tarballs/.git)
1225
1226 .PHONY: sdist-testsuite-prep
1227 sdist-testsuite-prep :
1228 $(call removeTrees,$(SRC_DIST_TESTSUITE_ROOT))
1229 $(call removeFiles,$(SRC_DIST_TESTSUITE_TARBALL))
1230 mkdir -p $(SRC_DIST_ROOT)
1231 mkdir -p $(SRC_DIST_TESTSUITE_ROOT)
1232 mkdir -p $(SRC_DIST_TESTSUITE_DIR)
1233 mkdir -p $(SRC_DIST_TESTSUITE_DIR)/testsuite
1234 cd $(SRC_DIST_TESTSUITE_DIR)/testsuite && lndir $(TOP)/testsuite
1235 cd $(SRC_DIST_TESTSUITE_DIR)/testsuite && $(MAKE) distclean
1236
1237 .PHONY: sdist-ghc
1238 sdist-ghc: sdist-ghc-prep
1239 cd $(SRC_DIST_GHC_ROOT) && "$(TAR_CMD)" chf - $(SRC_DIST_BASE_NAME) 2> src_ghc_log | $(TAR_COMP_CMD) -c > $(TOP)/$(SRC_DIST_GHC_TARBALL)
1240
1241 .PHONY: sdist-windows-tarballs
1242 sdist-windows-tarballs: sdist-windows-tarballs-prep
1243 cd $(SRC_DIST_WINDOWS_TARBALLS_ROOT) && "$(TAR_CMD)" chf - $(SRC_DIST_BASE_NAME) 2> windows_extra_src_ghc_log | $(TAR_COMP_CMD) -c > $(TOP)/$(SRC_DIST_WINDOWS_TARBALLS_TARBALL)
1244
1245 .PHONY: sdist-testsuite
1246 sdist-testsuite: sdist-testsuite-prep
1247 cd $(SRC_DIST_TESTSUITE_ROOT) && "$(TAR_CMD)" chf - $(SRC_DIST_BASE_NAME) 2> testsuite_log | $(TAR_COMP_CMD) -c > $(TOP)/$(SRC_DIST_TESTSUITE_TARBALL)
1248
1249
1250 .PHONY: sdist
1251 sdist : sdist-ghc sdist-windows-tarballs sdist-testsuite
1252
1253 sdist-manifest : $(SRC_DIST_GHC_TARBALL)
1254 tar tjf $(SRC_DIST_GHC_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
1255
1256 # Upload the distribution(s)
1257 # Retrying is to work around buggy firewalls that corrupt large file transfers
1258 # over SSH.
1259 ifneq "$(PublishLocation)" ""
1260 publish-sdist :
1261 $(call try10Times,$(PublishCp) $(SRC_DIST_GHC_TARBALL) $(PublishLocation)/dist)
1262 $(call try10Times,$(PublishCp) $(SRC_DIST_TESTSUITE_TARBALL) $(PublishLocation)/dist)
1263 endif
1264
1265 # -----------------------------------------------------------------------------
1266 # sdisting libraries
1267
1268 # Use manually, with e.g.:
1269 # make sdist_directory
1270
1271 sdist_%:
1272 inplace/bin/ghc-cabal sdist libraries/$* dist-install
1273
1274 # -----------------------------------------------------------------------------
1275 # Cleaning
1276
1277 .PHONY: clean
1278
1279 CLEAN_FILES += libraries/integer-gmp/include/HsIntegerGmp.h
1280 CLEAN_FILES += libraries/base/include/EventConfig.h
1281 CLEAN_FILES += mk/config.mk.old
1282 CLEAN_FILES += mk/project.mk.old
1283 CLEAN_FILES += compiler/ghc.cabal.old
1284
1285 # These are no longer generated, but we still clean them for a while
1286 # as they may still be in old GHC trees:
1287 CLEAN_FILES += includes/GHCConstants.h
1288 CLEAN_FILES += includes/DerivedConstants.h
1289 CLEAN_FILES += includes/ghcautoconf.h
1290 CLEAN_FILES += includes/ghcplatform.h
1291 CLEAN_FILES += includes/ghcversion.h
1292 CLEAN_FILES += utils/ghc-pkg/Version.hs
1293 CLEAN_FILES += compiler/prelude/primops.txt
1294 CLEAN_FILES += $(wildcard compiler/primop*incl)
1295
1296 clean : clean_files clean_libraries
1297
1298 .PHONY: clean_files
1299 clean_files :
1300 $(call removeFiles,$(CLEAN_FILES))
1301 # this is here since CLEAN_FILES can't handle folders
1302 $(call removeTrees,includes/dist-derivedconstants)
1303 $(call removeTrees,inplace/bin)
1304 $(call removeTrees,inplace/lib)
1305 $(call removeTrees,libraries/bootstrapping.conf)
1306
1307 .PHONY: clean_libraries
1308 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
1309 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(PACKAGES_STAGE0))
1310
1311 clean_libraries:
1312 $(call removeTrees,$(patsubst %, libraries/%/dist, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1313 $(call removeFiles,$(wildcard $(patsubst %.in, %, $(wildcard $(patsubst %, libraries/%/*.buildinfo.in, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))))))
1314 $(call removeFiles,$(patsubst %, libraries/%/config.log, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1315 $(call removeFiles,$(patsubst %, libraries/%/config.status, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1316 $(call removeFiles,$(wildcard $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))))
1317
1318 # We have to define a clean target for each library manually, because the
1319 # libraries/*/ghc.mk files are not included when we're cleaning.
1320 ifeq "$(CLEANING)" "YES"
1321 $(foreach lib,$(PACKAGES_STAGE0),\
1322 $(eval $(call clean-target,libraries/$(lib),dist-boot,libraries/$(lib)/dist-boot)))
1323 $(foreach lib,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),\
1324 $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
1325 endif
1326
1327 clean : clean_haddock_index
1328 .PHONY: clean_haddock_index
1329 clean_haddock_index:
1330 $(call removeTrees,libraries/dist-haddock)
1331
1332 clean : clean_bindistprep
1333 .PHONY: clean_bindistprep
1334 clean_bindistprep:
1335 $(call removeTrees,bindistprep/)
1336
1337 distclean : clean
1338 # Clean the files that ./validate creates.
1339 $(call removeFiles,mk/are-validating.mk)
1340
1341 # Clean the files that we ask ./configure to create.
1342 $(call removeFiles,mk/config.mk)
1343 $(call removeFiles,mk/install.mk)
1344 $(call removeFiles,mk/project.mk)
1345 $(call removeFiles,compiler/ghc.cabal)
1346 $(call removeFiles,ghc/ghc-bin.cabal)
1347 $(call removeFiles,utils/runghc/runghc.cabal)
1348 $(call removeFiles,settings)
1349 $(call removeFiles,docs/users_guide/ug-book.xml)
1350 $(call removeFiles,docs/users_guide/ug-ent.xml)
1351 $(call removeFiles,docs/users_guide/ghc_config.py)
1352 $(call removeFiles,docs/index.html)
1353 $(call removeFiles,libraries/prologue.txt)
1354 $(call removeFiles,distrib/configure.ac)
1355 $(call removeFiles,ch01.html ch02.html index.html)
1356
1357 # ./configure also makes these.
1358 $(call removeFiles,mk/config.h)
1359
1360 # Internal files generated by ./configure for itself.
1361 $(call removeFiles,config.cache config.status config.log)
1362
1363 # ./configure build ghc-pwd in utils/ghc-pwd/dist-boot, so clean it up.
1364 $(call removeTrees,utils/ghc-pwd/dist-boot)
1365
1366 # The root Makefile makes .old versions of some files that configure
1367 # generates, so we clean those too.
1368 $(call removeFiles,mk/config.mk.old)
1369 $(call removeFiles,mk/project.mk.old)
1370 $(call removeFiles,compiler/ghc.cabal.old)
1371
1372 # Clean the *Config.h files generated by library configure scripts
1373 $(call removeFiles,libraries/base/include/HsBaseConfig.h)
1374 $(call removeFiles,libraries/base/include/EventConfig.h)
1375 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h)
1376 $(call removeFiles,libraries/process/include/HsProcessConfig.h)
1377 $(call removeFiles,libraries/unix/include/HsUnixConfig.h)
1378 $(call removeFiles,libraries/time/lib/include/HsTimeConfig.h)
1379
1380 # The library configure scripts also like creating autom4te.cache
1381 # directories, so clean them all up.
1382 $(call removeTrees,$(patsubst %, libraries/%/autom4te.cache, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1383
1384 # We make these when making or testing bindists
1385 $(call removeFiles,bindist-list)
1386 $(call removeTrees,bindisttest/a)
1387
1388 # Not sure why this is being cleaned here.
1389 $(call removeTrees,includes/dist-derivedconstants)
1390
1391 # Also clean Windows-only inplace directories.
1392 # Don't delete 'inplace' itself, it contains source files.
1393 $(call removeTrees,inplace/mingw)
1394 $(call removeTrees,inplace/perl)
1395
1396 maintainer-clean : distclean
1397 $(call removeFiles,configure mk/config.h.in)
1398 $(call removeTrees,autom4te.cache $(wildcard libraries/*/autom4te.cache))
1399 $(call removeFiles,$(patsubst %, libraries/%/GNUmakefile, \
1400 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1401 $(call removeFiles,$(patsubst %, libraries/%/ghc.mk, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1402 $(call removeFiles,$(patsubst %, libraries/%/configure, \
1403 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1404 $(call removeFiles,libraries/base/include/HsBaseConfig.h.in)
1405 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h.in)
1406 $(call removeFiles,libraries/process/include/HsProcessConfig.h.in)
1407 $(call removeFiles,libraries/unix/include/HsUnixConfig.h.in)
1408 $(call removeFiles,libraries/time/lib/include/HsTimeConfig.h.in)
1409
1410 .PHONY: all_libraries
1411
1412 .PHONY: bootstrapping-files
1413 # See https://ghc.haskell.org/trac/ghc/wiki/Building/Porting
1414 bootstrapping-files: $(includes_H_CONFIG)
1415 bootstrapping-files: $(includes_DERIVEDCONSTANTS)
1416 bootstrapping-files: $(includes_GHCCONSTANTS)
1417 bootstrapping-files: $(libffi_HEADERS)
1418
1419 .DELETE_ON_ERROR:
1420
1421 # -----------------------------------------------------------------------------
1422
1423 ifeq "$(HADDOCK_DOCS)" "YES"
1424 BINDIST_HADDOCK_FLAG = --with-haddock="$(BINDIST_PREFIX)/bin/haddock"
1425 endif
1426 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
1427 BINDIST_LIBRARY_FLAGS = --enable-shared --disable-library-vanilla
1428 else
1429 BINDIST_LIBRARY_FLAGS = --enable-library-vanilla --disable-shared
1430 endif
1431 BINDIST_LIBRARY_FLAGS += --disable-library-prof
1432
1433 .PHONY: validate_build_xhtml
1434 validate_build_xhtml:
1435 cd libraries/xhtml && "$(BINDIST_PREFIX)/bin/ghc" --make Setup
1436 cd libraries/xhtml && ./Setup configure --with-ghc="$(BINDIST_PREFIX)/bin/ghc" $(BINDIST_HADDOCK_FLAG) $(BINDIST_LIBRARY_FLAGS) --global --builddir=dist-bindist --prefix="$(BINDIST_PREFIX)"
1437 cd libraries/xhtml && ./Setup build --builddir=dist-bindist
1438 ifeq "$(HADDOCK_DOCS)" "YES"
1439 cd libraries/xhtml && ./Setup haddock -v0 --ghc-options=-optP-P --builddir=dist-bindist
1440 endif
1441 cd libraries/xhtml && ./Setup install --builddir=dist-bindist
1442 cd libraries/xhtml && ./Setup clean --builddir=dist-bindist
1443 cd libraries/xhtml && rm -f Setup Setup.exe Setup.hi Setup.o
1444
1445 # Note [No stage2 packages when CrossCompiling or Stage1Only]
1446 #
1447 # (first read Note [CrossCompiling vs Stage1Only] and
1448 # Note [Stage1Only vs stage=1] in mk/config.mk.in)
1449 #
1450 # When either CrossCompiling=YES or Stage1Only=YES, we have to exclude the
1451 # following packages from the build:
1452 # * packages that we build with ghc-stage2 [1]
1453 # * packages that depend on the ghc library [2]
1454 #
1455 # Here's why:
1456 # - first of all, ghc-stage1 can't use stage0's ghc library (it's too old)
1457 # - neither do we register the ghc library (compiler/stage1) that we build
1458 # with stage0. TODO Why not? We do build it...
1459 # - as a result, we need to a) use ghc-stage2 to build packages that depend on
1460 # the ghc library (e.g. ghctags [4] and mkUserGuidePart) and b) exclude
1461 # those packages when ghc-stage2 is not available.
1462 # - when Stage1Only=YES, it's clear that ghc-stage2 is not available (we just
1463 # said we didn't want it), so we have to exclude the stage2 packages from
1464 # the build. This includes the case where Stage1Only=YES is combined with
1465 # CrossCompiling=YES (Building GHC as a cross-compiler [3]).
1466 # - when CrossCompiling=YES, but Stage1Only=NO (Cross-compiling GHC itself
1467 # [3]), we can not use ghc-stage2 either. The reason is that stage2 doesn't
1468 # run on the host platform at all; it is built to run on $(TARGETPLATFORM)"
1469 # [5]. Therefore in this case we also have to exclude the stage2 packages
1470 # from the build.
1471 #
1472 # [1] find utils -name ghc.mk | xargs grep -l 'build-prog.*,2'
1473 #
1474 # [2]
1475 # find utils -name package-data.mk | xargs grep -l 'DEP_NAMES =.* ghc\($\| \)'
1476 #
1477 # [3] https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling
1478 #
1479 # [4] 5fb72555f7b7ab67a33583f33ad9160761ca434f
1480 # "ghctags needs the stage2 compiler, since it uses the GHC API."
1481 #
1482 # [5] * bc31dbe8ee22819054df60f5ef219fed393a1c54
1483 # "Disable any packages built with stage 2 when cross-compiling
1484 # Since we can't run stage 2 on the host."
1485 #
1486 # * 72995160b0b190577b5c0cb8d7bd0426cc455b05
1487 # "We cannot use the stage 2 compiler, it runs on $(TARGETPLATFORM)"
1488
1489 # -----------------------------------------------------------------------------
1490 # Numbered phase targets
1491
1492 # In phase 1, we'll be building dependency files for most things
1493 # built by the bootstrapping compiler while make is 'include'ing
1494 # makefiles. But in order to build dependency files, we'll need to
1495 # build any automatically generated .hs files, which means that
1496 # we'll need to be able to build any tools that generate .hs files
1497 # etc. But in order to do that, we need to already know the
1498 # dependencies for those tools, so we build their dependency files
1499 # here.
1500 .PHONY: phase_0_builds
1501 # hsc2hs is needed, e.g. to make the .hs files for hpc.
1502 phase_0_builds: $(utils/hsc2hs_dist_depfile_haskell)
1503 phase_0_builds: $(utils/hsc2hs_dist_depfile_c_asm)
1504 # genprimopcode is needed to make the .hs-incl files that are in the
1505 # ghc package.
1506 phase_0_builds: $(utils/genprimopcode_dist_depfile_haskell)
1507 phase_0_builds: $(utils/genprimopcode_dist_depfile_c_asm)
1508 # deriveConstants is used to create header files included in the
1509 # ghc package.
1510 phase_0_builds: $(utils/deriveConstants_dist_depfile_haskell)
1511 phase_0_builds: $(utils/deriveConstants_dist_depfile_c_asm)
1512
1513 .PHONY: phase_1_builds
1514 phase_1_builds: $(PACKAGE_DATA_MKS)
1515