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