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