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