Allow non-operator infix pattern synonyms
[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 bin-package-db 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 += template-haskell
442 PACKAGES_STAGE1 += binary
443 PACKAGES_STAGE1 += Cabal/Cabal
444 PACKAGES_STAGE1 += bin-package-db
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/mkUserGuidePart/dist/package-data.mk: compiler/stage2/package-data.mk
542
543 # add the final package.conf dependency: ghc-prim depends on RTS
544 libraries/ghc-prim/dist-install/package-data.mk : rts/dist/package.conf.inplace
545 endif
546
547 # --------------------------------
548 # Misc package-related settings
549
550 # Run Haddock for the packages that will be installed. We need to handle
551 # compiler specially due to the different dist directory name.
552 $(foreach p,$(INSTALL_PACKAGES),$(eval $p_dist-install_DO_HADDOCK = YES))
553 compiler_stage2_DO_HADDOCK = YES
554
555 BOOT_PKG_CONSTRAINTS := \
556 $(foreach d,$(PACKAGES_STAGE0),\
557 $(foreach p,$(basename $(notdir $(wildcard libraries/$d/*.cabal))),\
558 --constraint "$p == $(shell grep -i "^Version:" libraries/$d/$p.cabal | sed "s/[^0-9.]//g")"))
559
560 # The actual .a and .so/.dll files: needed for dependencies.
561 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_v_LIB))
562 ifeq "$(BuildSharedLibs)" "YES"
563 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_dyn_LIB))
564 endif
565 BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB))
566
567 # ----------------------------------------
568 # Special magic for the ghc-prim package
569
570 # We want the ghc-prim package to include the GHC.Prim module when it
571 # is registered, but not when it is built, because GHC.Prim is not a
572 # real source module, it is built-in to GHC. The old build system did
573 # this using Setup.hs, but we can't do that here, so we have a flag to
574 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
575 # remains compatible with the old build system for the time being).
576 # GHC.Prim module in the ghc-prim package with a flag:
577 #
578 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
579
580 # And then we strip it out again before building the package:
581 define libraries/ghc-prim_PACKAGE_MAGIC
582 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
583 endef
584
585 PRIMOPS_TXT_STAGE1 = compiler/stage1/build/primops.txt
586
587 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
588 "$(genprimopcode_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
589
590 # Required so that Haddock documents the primops.
591 libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
592
593 # ----------------------------------------
594 # Special magic for the integer package
595
596 ifneq "$(CLEANING)" "YES"
597 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
598 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-gmp
599 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
600 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
601 else
602 $(error Unknown integer library: $(INTEGER_LIBRARY))
603 endif
604 endif
605
606 # -----------------------------------------------------------------------------
607 # Include build instructions from all subdirs
608 BUILD_DIRS += utils/mkdirhier
609 BUILD_DIRS += utils/touchy
610 BUILD_DIRS += utils/unlit
611 BUILD_DIRS += utils/hp2ps
612 BUILD_DIRS += driver/split
613 BUILD_DIRS += utils/genprimopcode
614 BUILD_DIRS += driver
615 BUILD_DIRS += driver/ghci
616 BUILD_DIRS += driver/ghc
617 BUILD_DIRS += driver/haddock
618 BUILD_DIRS += libffi
619 BUILD_DIRS += utils/deriveConstants
620 BUILD_DIRS += includes
621 BUILD_DIRS += rts
622 BUILD_DIRS += bindisttest
623 BUILD_DIRS += utils/genapply
624
625 # When cleaning, don't add any library packages to BUILD_DIRS. We include
626 # ghc.mk files for all BUILD_DIRS, but they don't exist until after running
627 # `./boot`. Running `make clean` before anything else, as well as running
628 # `make maintainer-clean` twice, should work.
629 ifneq "$(CLEANING)" "YES"
630 # These are deliberately in reverse order, so as to ensure that
631 # there is no need to have them in dependency order. That's important
632 # because it's tricky to ensure that they are in dependency order when
633 # cross-compiling, as some packages may only be in PACKAGES_STAGE0
634 # or PACKAGES_STAGE1.
635 BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE2))
636 BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1))
637 BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0)))
638 ifeq "$(BUILD_DPH)" "YES"
639 # Note: `$(eval $(call foreachLibrary,addExtraPackage))` above adds the
640 # packages listed in `libraries/dph/ghc-packages` (e.g. dph-base) to
641 # PACKAGES_STAGE2. But not 'libraries/dph' itself (it doesn't have a cabal
642 # file). Since it does have a ghc.mk file, we add it to BUILD_DIRS here.
643 BUILD_DIRS += $(wildcard libraries/dph)
644 endif
645 endif
646
647 BUILD_DIRS += libraries/integer-gmp/gmp
648 BUILD_DIRS += utils/haddock
649 BUILD_DIRS += utils/haddock/doc
650 BUILD_DIRS += compiler
651 BUILD_DIRS += utils/hsc2hs
652 BUILD_DIRS += utils/ghc-pkg
653 BUILD_DIRS += utils/testremove
654 BUILD_DIRS += utils/ghctags
655 BUILD_DIRS += utils/dll-split
656 BUILD_DIRS += utils/ghc-pwd
657 BUILD_DIRS += utils/ghc-cabal
658 BUILD_DIRS += utils/hpc
659 BUILD_DIRS += utils/runghc
660 BUILD_DIRS += ghc
661 BUILD_DIRS += utils/mkUserGuidePart
662 BUILD_DIRS += docs/users_guide
663 BUILD_DIRS += utils/count_lines
664 BUILD_DIRS += utils/compare_sizes
665
666 # ----------------------------------------------
667 # Actually include the sub-ghc.mk's
668
669 ifeq "$(CLEANING)" "YES"
670 # Don't exclude any BUILD_DIRS when cleaning. When you for example build
671 # haddock once, but later set HADDOCK_DOCS back to NO, then 'make clean'
672 # should still clean the haddock directory.
673 else # CLEANING
674 ifeq "$(BINDIST)" "YES"
675 BUILD_DIRS := $(filter-out utils/mkdirhier,$(BUILD_DIRS))
676 BUILD_DIRS := $(filter-out utils/genprimopcode,$(BUILD_DIRS))
677 BUILD_DIRS := $(filter-out bindisttest,$(BUILD_DIRS))
678 BUILD_DIRS := $(filter-out utils/genapply,$(BUILD_DIRS))
679 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
680 endif
681 ifeq "$(HADDOCK_DOCS)" "NO"
682 BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
683 BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
684 endif
685 ifeq "$(BUILD_SPHINX_HTML) $(BUILD_SPHINX_PDF)" "NO NO NO"
686 # Don't to build this little utility if we're not building the User's Guide.
687 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
688 endif
689 ifeq "$(Windows_Host)" "NO"
690 BUILD_DIRS := $(filter-out utils/touchy,$(BUILD_DIRS))
691 endif
692 ifeq "$(GhcUnregisterised)" "YES"
693 BUILD_DIRS := $(filter-out driver/split,$(BUILD_DIRS))
694 endif
695 ifeq "$(GhcWithInterpreter)" "NO"
696 # runghc is just GHCi in disguise
697 BUILD_DIRS := $(filter-out utils/runghc,$(BUILD_DIRS))
698 endif
699 ifneq "$(INTEGER_LIBRARY)" "integer-gmp"
700 BUILD_DIRS := $(filter-out libraries/integer-gmp/gmp,$(BUILD_DIRS))
701 endif
702 ifneq "$(CrossCompiling) $(Stage1Only)" "NO NO"
703 # See Note [No stage2 packages when CrossCompiling or Stage1Only].
704 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
705 BUILD_DIRS := $(filter-out utils/haddock,$(BUILD_DIRS))
706 BUILD_DIRS := $(filter-out utils/haddock/doc,$(BUILD_DIRS))
707 BUILD_DIRS := $(filter-out utils/ghctags,$(BUILD_DIRS))
708 BUILD_DIRS := $(filter-out utils/mkUserGuidePart,$(BUILD_DIRS))
709 endif
710 endif # CLEANING
711
712 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
713
714 # A useful pseudo-target (must be after the include above, because it needs
715 # the value of things like $(libraries/base_dist-install_v_LIB).
716 .PHONY: stage1_libs
717 stage1_libs : $(ALL_STAGE1_LIBS)
718
719 # ----------------------------------------------
720 # Per-package compiler flags
721 #
722 # If you want to add per-package compiler flags, see `mk/warnings.mk`.
723
724 # Add $(GhcLib(Extra)HcOpts) to all package builds
725 $(foreach pkg,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
726 $(foreach pkg,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_EXTRA_HC_OPTS += $$(GhcLibExtraHcOpts)))
727
728 # Add $(GhcBootLib(Extra)HcOpts) to all stage0 package builds
729 $(foreach pkg,$(PACKAGES_STAGE0),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
730 $(foreach pkg,$(PACKAGES_STAGE0),$(eval libraries/$(pkg)_dist-boot_EXTRA_HC_OPTS += $$(GhcBootLibExtraHcOpts)))
731
732 # -----------------------------------------------------------------------------
733 # Bootstrapping libraries
734
735 # We need to build a few libraries with the installed GHC, since GHC itself
736 # and some of the tools depend on them:
737
738 ifneq "$(BINDIST)" "YES"
739
740 ifneq "$(BOOTSTRAPPING_CONF)" ""
741 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
742 $(shell $(GHC_PKG) init $(BOOTSTRAPPING_CONF))
743 endif
744 endif
745
746 $(eval $(call clean-target,root,bootstrapping_conf,$(BOOTSTRAPPING_CONF)))
747
748 # register the boot packages in strict sequence, because running
749 # multiple ghc-pkgs in parallel doesn't work (registrations may get
750 # lost).
751 fixed_pkg_prev=
752 $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
753 # ghc-pkg, unlike other utils that we build with the stage0 compiler (TODO: is
754 # this really true?), depends on several boot packages (e.g. Cabal and
755 # bin-package-db). They need to be configured before ghc-pkg, so we add a
756 # dependency between their package-data.mk files. See also Note
757 # [Dependencies between package-data.mk files].
758 utils/ghc-pkg/dist/package-data.mk: $(fixed_pkg_prev)
759 compiler/stage1/package-data.mk: $(fixed_pkg_prev)
760 endif
761
762 ifneq "$(BINDIST)" "YES"
763 # Make sure we have all the GHCi libs by the time we've built
764 # ghc-stage2. DPH includes a bit of Template Haskell which needs the
765 # GHCi libs, and we don't have a better way to express that dependency.
766 #
767 GHCI_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_GHCI_LIB)) \
768 $(compiler_stage2_GHCI_LIB)
769
770 ifeq "$(UseArchivesForGhci)" "NO"
771 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(GHCI_LIBS)
772 endif
773
774 ifeq "$(UseArchivesForGhci)" "YES"
775 GHCI_lib_way = v
776 else
777 GHCI_lib_way = GHCI
778 endif
779
780 # Deps for TH uses in libraries
781 $(foreach way, $(GhcLibWays),$(eval \
782 libraries/vector/dist-install/build/Data/Vector/Fusion/Stream/Monadic.$($(way)_osuf): \
783 $(libraries/primitive_dist-install_$(GHCI_lib_way)_LIB) \
784 ))
785 endif
786
787 # -----------------------------------------------
788 # Haddock-related bits
789
790 # Build the Haddock contents and index
791 ifeq "$(HADDOCK_DOCS)" "YES"
792 libraries/dist-haddock/index.html: $(haddock_INPLACE) $(ALL_HADDOCK_FILES)
793 cd libraries && sh gen_contents_index --intree
794 ifeq "$(phase)" "final"
795 $(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
796 endif
797 INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
798 endif
799
800 # -----------------------------------------------------------------------------
801 # Creating a local mingw copy on Windows
802
803 ifeq "$(Windows_Host)" "YES"
804
805 install : install_mingw
806 .PHONY: install_mingw
807 install_mingw : $(INPLACE_MINGW)
808 "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
809
810 install : install_perl
811 .PHONY: install_perl
812 install_perl : $(INPLACE_PERL)
813 "$(CP)" -Rp $(INPLACE_PERL) $(prefix)
814
815 endif # Windows_Host
816
817 ifneq "$(BINDIST)" "YES"
818 $(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \
819 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
820 endif # BINDIST
821
822 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
823 $(PRIMOPS_TXT_STAGE1) $$(genprimopcode_INPLACE) \
824 | $$(dir $$@)/.
825 "$(genprimopcode_INPLACE)" --make-haskell-source < $< > $@
826
827 .PHONY: tags
828 tags: tags_compiler
829
830 .PHONY: TAGS
831 TAGS: TAGS_compiler
832
833 # -----------------------------------------------------------------------------
834 # Installation
835
836 install: install_libs install_packages install_libexecs \
837 install_bins install_topdirs
838 ifeq "$(HADDOCK_DOCS)" "YES"
839 install: install_docs
840 endif
841
842 define installLibsTo
843 # $1 = libraries to install
844 # $2 = directory to install to
845 #
846 # The .dll case calls STRIP_CMD explicitly, instead of `install -s`, because
847 # on Win64, "install -s" calls a strip that doesn't understand 64bit binaries.
848 # For some reason, this means the DLLs end up non-executable, which means
849 # executables that use them just segfault.
850 $(INSTALL_DIR) $2
851 for i in $1; do \
852 case $$i in \
853 *.a) \
854 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $2; \
855 $(RANLIB_CMD) $2/`basename $$i` ;; \
856 *.dll) \
857 $(INSTALL_PROGRAM) $(INSTALL_OPTS) $$i $2 ; \
858 $(STRIP_CMD) $2/`basename $$i` ;; \
859 *.so) \
860 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $2 ;; \
861 *.dylib) \
862 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $2;; \
863 *) \
864 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $2; \
865 esac; \
866 done
867 endef
868
869 install_bins: $(INSTALL_BINS) $(INSTALL_SCRIPTS)
870 $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
871 for i in $(INSTALL_BINS); do \
872 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(bindir)" ; \
873 done
874 for i in $(INSTALL_SCRIPTS); do \
875 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i "$(DESTDIR)$(bindir)" ; \
876 done
877
878 install_libs: $(INSTALL_LIBS)
879 $(call installLibsTo, $(INSTALL_LIBS), "$(DESTDIR)$(ghclibdir)")
880
881 install_libexecs: $(INSTALL_LIBEXECS)
882 ifeq "$(INSTALL_LIBEXECS)" ""
883 @:
884 else
885 $(INSTALL_DIR) "$(DESTDIR)$(ghclibexecdir)/bin"
886 for i in $(INSTALL_LIBEXECS); do \
887 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(ghclibexecdir)/bin"; \
888 done
889 # We rename ghc-stage2, so that the right program name is used in error
890 # messages etc.
891 "$(MV)" "$(DESTDIR)$(ghclibexecdir)/bin/ghc-stage$(INSTALL_GHC_STAGE)" "$(DESTDIR)$(ghclibexecdir)/bin/ghc"
892 endif
893
894 install_topdirs: $(INSTALL_TOPDIR_BINS) $(INSTALL_TOPDIR_SCRIPTS)
895 $(INSTALL_DIR) "$(DESTDIR)$(topdir)"
896 for i in $(INSTALL_TOPDIR_BINS); do \
897 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(topdir)"; \
898 done
899 for i in $(INSTALL_TOPDIR_SCRIPTS); do \
900 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i "$(DESTDIR)$(topdir)"; \
901 done
902
903 install_docs: $(INSTALL_DOCS)
904 $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
905 ifneq "$(INSTALL_DOCS)" ""
906 for i in $(INSTALL_DOCS); do \
907 $(INSTALL_DOC) $(INSTALL_OPTS) $$i "$(DESTDIR)$(docdir)"; \
908 done
909 endif
910 $(INSTALL_DIR) "$(DESTDIR)$(docdir)/html"
911 $(INSTALL_DOC) $(INSTALL_OPTS) docs/index.html "$(DESTDIR)$(docdir)/html"
912 ifneq "$(INSTALL_LIBRARY_DOCS)" ""
913 $(INSTALL_DIR) "$(DESTDIR)$(docdir)/html/libraries"
914 for i in $(INSTALL_LIBRARY_DOCS); do \
915 $(INSTALL_DOC) $(INSTALL_OPTS) $$i "$(DESTDIR)$(docdir)/html/libraries/"; \
916 done
917 $(INSTALL_DATA) $(INSTALL_OPTS) libraries/prologue.txt "$(DESTDIR)$(docdir)/html/libraries/"
918 $(INSTALL_SCRIPT) $(INSTALL_OPTS) libraries/gen_contents_index "$(DESTDIR)$(docdir)/html/libraries/"
919 endif
920 ifneq "$(INSTALL_HTML_DOC_DIRS)" ""
921 for i in $(INSTALL_HTML_DOC_DIRS); do \
922 $(INSTALL_DIR) "$(DESTDIR)$(docdir)/html/`basename $$i`"; \
923 for f in $$i/*; do \
924 # We filter out the directories so install doesn't choke on them \
925 if test -f $$f; then \
926 $(INSTALL_DOC) $(INSTALL_OPTS) "$$f" "$(DESTDIR)$(docdir)/html/`basename $$i`"; \
927 fi \
928 done \
929 done
930 endif
931
932 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
933
934 # Install packages in the right order, so that ghc-pkg doesn't complain.
935 # Also, install ghc-pkg first.
936 ifeq "$(Windows_Host)" "NO"
937 INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc
938 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc-pkg
939 else
940 INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
941 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
942 endif
943
944 # Set the INSTALL_DISTDIR_p for each package; compiler is special
945 $(foreach p,$(filter-out compiler,$(INSTALL_PACKAGES)),\
946 $(eval INSTALL_DISTDIR_$p = dist-install))
947 INSTALL_DISTDIR_compiler = stage2
948
949 # Now we can do the installation
950 install_packages: install_libexecs
951 install_packages: rts/dist/package.conf.install
952 $(INSTALL_DIR) "$(DESTDIR)$(topdir)"
953 $(call removeTrees,"$(INSTALLED_PACKAGE_CONF)")
954 $(INSTALL_DIR) "$(INSTALLED_PACKAGE_CONF)"
955 $(INSTALL_DIR) "$(DESTDIR)$(topdir)/rts"
956 $(call installLibsTo, $(RTS_INSTALL_LIBS), "$(DESTDIR)$(topdir)/rts")
957 $(foreach p, $(INSTALL_PACKAGES), \
958 $(call make-command, \
959 "$(ghc-cabal_INPLACE)" copy \
960 $p $(INSTALL_DISTDIR_$p) \
961 "$(STRIP_CMD)" \
962 '$(DESTDIR)' \
963 '$(prefix)' \
964 '$(ghclibdir)' \
965 '$(docdir)/html/libraries' \
966 '$(GhcLibWays)'))
967 "$(INSTALLED_GHC_PKG_REAL)" --force --global-package-db "$(INSTALLED_PACKAGE_CONF)" update rts/dist/package.conf.install
968 $(foreach p, $(INSTALL_PACKAGES), \
969 $(call make-command, \
970 "$(ghc-cabal_INPLACE)" register \
971 $p $(INSTALL_DISTDIR_$p) \
972 "$(INSTALLED_GHC_REAL)" \
973 "$(INSTALLED_GHC_PKG_REAL)" \
974 "$(DESTDIR)$(topdir)" \
975 '$(DESTDIR)' \
976 '$(prefix)' \
977 '$(ghclibdir)' \
978 '$(docdir)/html/libraries' \
979 $(RelocatableBuild)))
980 # when we install the packages above, ghc-pkg obeys umask when creating
981 # the package.conf files, but for everything else we specify the
982 # permissions. We therefore now fix the permissions of package.cache.
983 # This means "sudo make install" does the right thing even if it runs
984 # with an 077 umask.
985 for f in '$(INSTALLED_PACKAGE_CONF)'/*; do $(CREATE_DATA) "$$f"; done
986
987 # -----------------------------------------------------------------------------
988 # Binary distributions
989
990 ifneq "$(CLEANING)" "YES"
991 # This rule seems to hold some files open on Windows which prevents
992 # cleaning, perhaps due to the $(wildcard).
993
994 $(eval $(call bindist-list,.,\
995 LICENSE \
996 README \
997 INSTALL \
998 configure config.sub config.guess install-sh \
999 settings.in \
1000 packages \
1001 Makefile \
1002 mk/config.mk.in \
1003 $(INPLACE_BIN)/mkdirhier \
1004 utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
1005 utils/ghc-pwd/dist-install/build/tmp/ghc-pwd \
1006 $(BINDIST_WRAPPERS) \
1007 $(BINDIST_PERL_SOURCES) \
1008 $(BINDIST_LIBS) \
1009 $(BINDIST_HI) \
1010 $(BINDIST_EXTRAS) \
1011 $(includes_H_FILES) \
1012 $(includes_DERIVEDCONSTANTS) \
1013 $(includes_GHCCONSTANTS) \
1014 $(libffi_HEADERS) \
1015 $(INSTALL_LIBEXECS) \
1016 $(INSTALL_LIBEXEC_SCRIPTS) \
1017 $(INSTALL_TOPDIR_BINS) \
1018 $(INSTALL_TOPDIR_SCRIPTS) \
1019 $(INSTALL_BINS) \
1020 $(INSTALL_SCRIPTS) \
1021 $(INSTALL_MANPAGES) \
1022 $(INSTALL_DOCS) \
1023 $(INSTALL_LIBRARY_DOCS) \
1024 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
1025 docs/index.html \
1026 compiler/stage2/doc \
1027 $(wildcard libraries/*/dist-install/doc/) \
1028 $(wildcard libraries/*/*/dist-install/doc/) \
1029 $(filter-out settings,$(INSTALL_LIBS)) \
1030 $(RTS_INSTALL_LIBS) \
1031 $(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
1032 mk/project.mk \
1033 mk/install.mk.in \
1034 bindist.mk \
1035 libraries/gen_contents_index \
1036 libraries/prologue.txt \
1037 $(wildcard libraries/dph/LICENSE \
1038 libraries/dph/ghc-packages \
1039 libraries/dph/ghc-packages2 \
1040 libraries/dph/ghc-stage2-package) \
1041 ))
1042 endif
1043 # mk/project.mk gets an absolute path, so we manually include it in
1044 # the bindist with a relative path
1045
1046 BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
1047
1048 unix-binary-dist-prep:
1049 $(call removeTrees,bindistprep/)
1050 "$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
1051 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
1052 echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
1053 echo "BUILD_SPHINX_HTML = $(BUILD_SPHINX_HTML)" >> $(BIN_DIST_MK)
1054 echo "BUILD_SPHINX_PDF = $(BUILD_SPHINX_PDF)" >> $(BIN_DIST_MK)
1055 echo "BUILD_MAN = $(BUILD_MAN)" >> $(BIN_DIST_MK)
1056 echo "override ghc-cabal_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" >> $(BIN_DIST_MK)
1057 echo "UseSystemLibFFI = $(UseSystemLibFFI)" >> $(BIN_DIST_MK)
1058 cd $(BIN_DIST_PREP_DIR) && autoreconf
1059 $(call removeFiles,$(BIN_DIST_PREP_TAR))
1060 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
1061 # tree then we want to include the real file, not a symlink to it
1062 cd bindistprep && "$(TAR_CMD)" hcf - -T ../bindist-list | $(TAR_COMP_CMD) -c > ../$(BIN_DIST_PREP_TAR_COMP)
1063
1064 windows-binary-dist-prep:
1065 $(call removeTrees,bindistprep/)
1066 $(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
1067 cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | $(TAR_COMP_CMD) -c > ../$(BIN_DIST_PREP_TAR_COMP)
1068
1069 # tryTimes tries to run its third argument multiple times, until it
1070 # succeeds. Don't call it directly; call try10Times instead.
1071 # The first and second argument to tryTimes are lists of values.
1072 # The length of the first argument is the number of times we have
1073 # already tried. The length of the second argument is the number more
1074 # times we will try.
1075 tryTimes = $(if $2, \
1076 { echo 'Try $(words x $1): $3' ; $3 ; } || \
1077 $(call tryTimes,x $1,$(wordlist 2,$(words $2),$2),$3), \
1078 )
1079
1080 # Try to run the argument 10 times. If all 10 fail, fail.
1081 try10Times = $(call tryTimes,,x x x x x x x x x x,$1) { echo Failed; false; }
1082
1083 .PHONY: publish-binary-dist
1084 publish-binary-dist:
1085 $(call try10Times,$(PublishCp) $(BIN_DIST_TAR_COMP) $(PublishLocation)/dist)
1086
1087 ifeq "$(mingw32_TARGET_OS)" "1"
1088 DOCDIR_TO_PUBLISH = $(BIN_DIST_INST_DIR)/doc
1089 else
1090 DOCDIR_TO_PUBLISH = $(BIN_DIST_INST_DIR)/share/doc/ghc
1091 endif
1092
1093 .PHONY: publish-docs
1094 publish-docs:
1095 $(call try10Times,$(PublishCp) -r $(DOCDIR_TO_PUBLISH)/* $(PublishLocation)/docs)
1096
1097 # -----------------------------------------------------------------------------
1098 # Source distributions
1099
1100 # Do it like this:
1101 #
1102 # $ ./boot
1103 # $ ./configure
1104 # $ make sdist
1105 #
1106
1107 # A source dist is built from a (partial) build tree, because we
1108 # require some extra files not contained in a git checkout: the
1109 # output from Happy and Alex, for example.
1110 #
1111 # The steps performed by 'make sdist' are as follows:
1112 # - build those extra files
1113 # - create a complete link-tree of the current build tree in /tmp
1114 # - run 'make distclean' on that tree
1115 # - remove a bunch of other files that we know shouldn't be in the dist
1116
1117 #
1118 # Directory in which we're going to build the src dist
1119 #
1120 SRC_DIST_ROOT = sdistprep
1121 SRC_DIST_BASE_NAME = ghc-$(ProjectVersion)
1122
1123 SRC_DIST_GHC_NAME = ghc-$(ProjectVersion)-src
1124 SRC_DIST_GHC_ROOT = $(SRC_DIST_ROOT)/ghc
1125 SRC_DIST_GHC_DIR = $(SRC_DIST_GHC_ROOT)/$(SRC_DIST_BASE_NAME)
1126 SRC_DIST_GHC_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_GHC_NAME).tar.$(TAR_COMP_EXT)
1127
1128 SRC_DIST_WINDOWS_TARBALLS_NAME = ghc-$(ProjectVersion)-windows-extra-src
1129 SRC_DIST_WINDOWS_TARBALLS_ROOT = $(SRC_DIST_ROOT)/windows-tarballs
1130 SRC_DIST_WINDOWS_TARBALLS_DIR = $(SRC_DIST_WINDOWS_TARBALLS_ROOT)/$(SRC_DIST_BASE_NAME)
1131 SRC_DIST_WINDOWS_TARBALLS_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_WINDOWS_TARBALLS_NAME).tar.$(TAR_COMP_EXT)
1132
1133 SRC_DIST_TESTSUITE_NAME = ghc-$(ProjectVersion)-testsuite
1134 SRC_DIST_TESTSUITE_ROOT = $(SRC_DIST_ROOT)/testsuite-ghc
1135 SRC_DIST_TESTSUITE_DIR = $(SRC_DIST_TESTSUITE_ROOT)/$(SRC_DIST_BASE_NAME)
1136 SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME).tar.$(TAR_COMP_EXT)
1137
1138 #
1139 # Files to include in source distributions
1140 #
1141 SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \
1142 utils docs rts compiler ghc driver libraries libffi-tarballs
1143 SRC_DIST_GHC_FILES += \
1144 configure.ac config.guess config.sub configure \
1145 aclocal.m4 README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \
1146 install-sh settings.in VERSION GIT_COMMIT_ID \
1147 boot packages ghc.mk MAKEHELP.md
1148
1149 .PHONY: VERSION
1150 VERSION:
1151 @if test -f $@ && test "`cat $@`" = "$(ProjectVersion)"; \
1152 then echo "$@ needs no update"; \
1153 else echo "update $@ ($(ProjectVersion))"; echo "$(ProjectVersion)" > $@; fi
1154
1155 .PHONY: GIT_COMMIT_ID
1156 GIT_COMMIT_ID:
1157 @if test -d .git && test "`git rev-parse HEAD`" != "$(ProjectGitCommitId)"; then \
1158 echo "******************************************************************************"; \
1159 echo "Stale ProjectGitCommitId (=$(ProjectGitCommitId)) detected!"; \
1160 echo "'git rev-parse HEAD' says: `git rev-parse HEAD`"; \
1161 echo "Please re-run './configure' before creating source-distribution"; \
1162 echo "******************************************************************************"; \
1163 exit 1; \
1164 fi
1165 @if test -f $@ && test "`cat $@`" = "$(ProjectGitCommitId)"; \
1166 then echo "$@ needs no update"; \
1167 else echo "update $@ ($(ProjectGitCommitId))"; echo -n "$(ProjectGitCommitId)" > $@; fi
1168
1169 sdist-ghc-prep-tree : VERSION GIT_COMMIT_ID
1170
1171 # Extra packages which shouldn't be in the source distribution: see #8801
1172 EXTRA_PACKAGES=parallel stm random primitive vector dph
1173
1174 .PHONY: sdist-ghc-prep-tree
1175 sdist-ghc-prep-tree :
1176 $(call removeTrees,$(SRC_DIST_GHC_ROOT))
1177 $(call removeFiles,$(SRC_DIST_GHC_TARBALL))
1178 mkdir -p $(SRC_DIST_ROOT)
1179 mkdir -p $(SRC_DIST_GHC_ROOT)
1180 mkdir -p $(SRC_DIST_GHC_DIR)
1181 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_DIRS); do mkdir -p $$i; ( cd $$i && lndir $(TOP)/$$i ); done
1182 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_FILES); do $(LN_S) $(TOP)/$$i .; done
1183 cd $(SRC_DIST_GHC_DIR) && $(MAKE) distclean
1184 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/tarballs/)
1185 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/stamp/)
1186 $(call removeTrees,$(SRC_DIST_GHC_DIR)/compiler/stage[123])
1187 $(call removeFiles,$(SRC_DIST_GHC_DIR)/mk/build.mk)
1188 for i in $(EXTRA_PACKAGES); do $(RM) $(RM_OPTS_REC) $(SRC_DIST_GHC_DIR)/libraries/$$i/; done
1189 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)
1190
1191 # Add files generated by alex and happy.
1192 # These rules depend on sdist-ghc-prep-tree.
1193 $(eval $(call sdist-ghc-file,compiler,stage2,cmm,CmmLex,x))
1194 $(eval $(call sdist-ghc-file,compiler,stage2,cmm,CmmParse,y))
1195 $(eval $(call sdist-ghc-file,compiler,stage2,parser,Lexer,x))
1196 $(eval $(call sdist-ghc-file,compiler,stage2,parser,Parser,y))
1197 $(eval $(call sdist-ghc-file,utils/hpc,dist-install,,HpcParser,y))
1198 $(eval $(call sdist-ghc-file,utils/genprimopcode,dist,,Lexer,x))
1199 $(eval $(call sdist-ghc-file,utils/genprimopcode,dist,,Parser,y))
1200
1201 .PHONY: sdist-ghc-prep
1202 sdist-ghc-prep : sdist-ghc-prep-tree
1203
1204 .PHONY: sdist-windows-tarballs-prep
1205 sdist-windows-tarballs-prep :
1206 $(call removeTrees,$(SRC_DIST_WINDOWS_TARBALLS_ROOT))
1207 $(call removeFiles,$(SRC_DIST_WINDOWS_TARBALLS_TARBALL))
1208 mkdir -p $(SRC_DIST_ROOT)
1209 mkdir -p $(SRC_DIST_WINDOWS_TARBALLS_ROOT)
1210 mkdir -p $(SRC_DIST_WINDOWS_TARBALLS_DIR)
1211 mkdir -p $(SRC_DIST_WINDOWS_TARBALLS_DIR)/ghc-tarballs
1212 cd $(SRC_DIST_WINDOWS_TARBALLS_DIR)/ghc-tarballs && lndir $(TOP)/ghc-tarballs
1213 $(call removeTrees,$(SRC_DIST_WINDOWS_TARBALLS_DIR)/ghc-tarballs/.git)
1214
1215 .PHONY: sdist-testsuite-prep
1216 sdist-testsuite-prep :
1217 $(call removeTrees,$(SRC_DIST_TESTSUITE_ROOT))
1218 $(call removeFiles,$(SRC_DIST_TESTSUITE_TARBALL))
1219 mkdir -p $(SRC_DIST_ROOT)
1220 mkdir -p $(SRC_DIST_TESTSUITE_ROOT)
1221 mkdir -p $(SRC_DIST_TESTSUITE_DIR)
1222 mkdir -p $(SRC_DIST_TESTSUITE_DIR)/testsuite
1223 cd $(SRC_DIST_TESTSUITE_DIR)/testsuite && lndir $(TOP)/testsuite
1224 cd $(SRC_DIST_TESTSUITE_DIR)/testsuite && $(MAKE) distclean
1225
1226 .PHONY: sdist-ghc
1227 sdist-ghc: sdist-ghc-prep
1228 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)
1229
1230 .PHONY: sdist-windows-tarballs
1231 sdist-windows-tarballs: sdist-windows-tarballs-prep
1232 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)
1233
1234 .PHONY: sdist-testsuite
1235 sdist-testsuite: sdist-testsuite-prep
1236 cd $(SRC_DIST_TESTSUITE_ROOT) && "$(TAR_CMD)" chf - $(SRC_DIST_BASE_NAME) 2> testsuite_log | $(TAR_COMP_CMD) -c > $(TOP)/$(SRC_DIST_TESTSUITE_TARBALL)
1237
1238
1239 .PHONY: sdist
1240 sdist : sdist-ghc sdist-windows-tarballs sdist-testsuite
1241
1242 sdist-manifest : $(SRC_DIST_GHC_TARBALL)
1243 tar tjf $(SRC_DIST_GHC_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
1244
1245 # Upload the distribution(s)
1246 # Retrying is to work around buggy firewalls that corrupt large file transfers
1247 # over SSH.
1248 ifneq "$(PublishLocation)" ""
1249 publish-sdist :
1250 $(call try10Times,$(PublishCp) $(SRC_DIST_GHC_TARBALL) $(PublishLocation)/dist)
1251 $(call try10Times,$(PublishCp) $(SRC_DIST_TESTSUITE_TARBALL) $(PublishLocation)/dist)
1252 endif
1253
1254 # -----------------------------------------------------------------------------
1255 # sdisting libraries
1256
1257 # Use manually, with e.g.:
1258 # make sdist_directory
1259
1260 sdist_%:
1261 inplace/bin/ghc-cabal sdist libraries/$* dist-install
1262
1263 # -----------------------------------------------------------------------------
1264 # Cleaning
1265
1266 .PHONY: clean
1267
1268 CLEAN_FILES += libraries/integer-gmp/include/HsIntegerGmp.h
1269 CLEAN_FILES += libraries/base/include/EventConfig.h
1270 CLEAN_FILES += mk/config.mk.old
1271 CLEAN_FILES += mk/project.mk.old
1272 CLEAN_FILES += compiler/ghc.cabal.old
1273
1274 # These are no longer generated, but we still clean them for a while
1275 # as they may still be in old GHC trees:
1276 CLEAN_FILES += includes/GHCConstants.h
1277 CLEAN_FILES += includes/DerivedConstants.h
1278 CLEAN_FILES += includes/ghcautoconf.h
1279 CLEAN_FILES += includes/ghcplatform.h
1280 CLEAN_FILES += includes/ghcversion.h
1281 CLEAN_FILES += utils/ghc-pkg/Version.hs
1282 CLEAN_FILES += compiler/prelude/primops.txt
1283 CLEAN_FILES += $(wildcard compiler/primop*incl)
1284
1285 clean : clean_files clean_libraries
1286
1287 .PHONY: clean_files
1288 clean_files :
1289 $(call removeFiles,$(CLEAN_FILES))
1290 # this is here since CLEAN_FILES can't handle folders
1291 $(call removeTrees,includes/dist-derivedconstants)
1292 $(call removeTrees,inplace/bin)
1293 $(call removeTrees,inplace/lib)
1294 $(call removeTrees,libraries/bootstrapping.conf)
1295
1296 .PHONY: clean_libraries
1297 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
1298 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(PACKAGES_STAGE0))
1299
1300 clean_libraries:
1301 $(call removeTrees,$(patsubst %, libraries/%/dist, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1302 $(call removeFiles,$(wildcard $(patsubst %.in, %, $(wildcard $(patsubst %, libraries/%/*.buildinfo.in, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))))))
1303 $(call removeFiles,$(patsubst %, libraries/%/config.log, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1304 $(call removeFiles,$(patsubst %, libraries/%/config.status, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1305 $(call removeFiles,$(wildcard $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))))
1306
1307 # We have to define a clean target for each library manually, because the
1308 # libraries/*/ghc.mk files are not included when we're cleaning.
1309 ifeq "$(CLEANING)" "YES"
1310 $(foreach lib,$(PACKAGES_STAGE0),\
1311 $(eval $(call clean-target,libraries/$(lib),dist-boot,libraries/$(lib)/dist-boot)))
1312 $(foreach lib,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),\
1313 $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
1314 endif
1315
1316 clean : clean_haddock_index
1317 .PHONY: clean_haddock_index
1318 clean_haddock_index:
1319 $(call removeTrees,libraries/dist-haddock)
1320
1321 clean : clean_bindistprep
1322 .PHONY: clean_bindistprep
1323 clean_bindistprep:
1324 $(call removeTrees,bindistprep/)
1325
1326 distclean : clean
1327 # Clean the files that we ask ./configure to create.
1328 $(call removeFiles,mk/config.mk)
1329 $(call removeFiles,mk/install.mk)
1330 $(call removeFiles,mk/project.mk)
1331 $(call removeFiles,compiler/ghc.cabal)
1332 $(call removeFiles,ghc/ghc-bin.cabal)
1333 $(call removeFiles,utils/runghc/runghc.cabal)
1334 $(call removeFiles,settings)
1335 $(call removeFiles,docs/users_guide/ug-book.xml)
1336 $(call removeFiles,docs/users_guide/ug-ent.xml)
1337 $(call removeFiles,docs/users_guide/ghc_config.py)
1338 $(call removeFiles,docs/index.html)
1339 $(call removeFiles,libraries/prologue.txt)
1340 $(call removeFiles,distrib/configure.ac)
1341 $(call removeFiles,ch01.html ch02.html index.html)
1342
1343 # ./configure also makes these.
1344 $(call removeFiles,mk/config.h)
1345
1346 # Internal files generated by ./configure for itself.
1347 $(call removeFiles,config.cache config.status config.log)
1348
1349 # ./configure build ghc-pwd in utils/ghc-pwd/dist-boot, so clean it up.
1350 $(call removeTrees,utils/ghc-pwd/dist-boot)
1351
1352 # The root Makefile makes .old versions of some files that configure
1353 # generates, so we clean those too.
1354 $(call removeFiles,mk/config.mk.old)
1355 $(call removeFiles,mk/project.mk.old)
1356 $(call removeFiles,compiler/ghc.cabal.old)
1357
1358 # Clean the *Config.h files generated by library configure scripts
1359 $(call removeFiles,libraries/base/include/HsBaseConfig.h)
1360 $(call removeFiles,libraries/base/include/EventConfig.h)
1361 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h)
1362 $(call removeFiles,libraries/process/include/HsProcessConfig.h)
1363 $(call removeFiles,libraries/unix/include/HsUnixConfig.h)
1364 $(call removeFiles,libraries/time/lib/include/HsTimeConfig.h)
1365
1366 # The library configure scripts also like creating autom4te.cache
1367 # directories, so clean them all up.
1368 $(call removeTrees,$(patsubst %, libraries/%/autom4te.cache, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1369
1370 # We make these when making or testing bindists
1371 $(call removeFiles,bindist-list)
1372 $(call removeTrees,bindisttest/a)
1373
1374 # Not sure why this is being cleaned here.
1375 $(call removeTrees,includes/dist-derivedconstants)
1376
1377 # Finally, clean the inplace tree.
1378 $(call removeTrees,inplace)
1379
1380 maintainer-clean : distclean
1381 $(call removeFiles,configure mk/config.h.in)
1382 $(call removeTrees,autom4te.cache $(wildcard libraries/*/autom4te.cache))
1383 $(call removeFiles,$(patsubst %, libraries/%/GNUmakefile, \
1384 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1385 $(call removeFiles,$(patsubst %, libraries/%/ghc.mk, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1386 $(call removeFiles,$(patsubst %, libraries/%/configure, \
1387 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1388 $(call removeFiles,libraries/base/include/HsBaseConfig.h.in)
1389 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h.in)
1390 $(call removeFiles,libraries/process/include/HsProcessConfig.h.in)
1391 $(call removeFiles,libraries/unix/include/HsUnixConfig.h.in)
1392 $(call removeFiles,libraries/time/lib/include/HsTimeConfig.h.in)
1393
1394 .PHONY: all_libraries
1395
1396 .PHONY: bootstrapping-files
1397 # See https://ghc.haskell.org/trac/ghc/wiki/Building/Porting
1398 bootstrapping-files: $(includes_H_CONFIG)
1399 bootstrapping-files: $(includes_DERIVEDCONSTANTS)
1400 bootstrapping-files: $(includes_GHCCONSTANTS)
1401 bootstrapping-files: $(libffi_HEADERS)
1402
1403 .DELETE_ON_ERROR:
1404
1405 # -----------------------------------------------------------------------------
1406
1407 ifeq "$(HADDOCK_DOCS)" "YES"
1408 BINDIST_HADDOCK_FLAG = --with-haddock="$(BINDIST_PREFIX)/bin/haddock"
1409 endif
1410 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
1411 BINDIST_LIBRARY_FLAGS = --enable-shared --disable-library-vanilla
1412 else
1413 BINDIST_LIBRARY_FLAGS = --enable-library-vanilla --disable-shared
1414 endif
1415 BINDIST_LIBRARY_FLAGS += --disable-library-prof
1416
1417 .PHONY: validate_build_xhtml
1418 validate_build_xhtml:
1419 cd libraries/xhtml && "$(BINDIST_PREFIX)/bin/ghc" --make Setup
1420 cd libraries/xhtml && ./Setup configure --with-ghc="$(BINDIST_PREFIX)/bin/ghc" $(BINDIST_HADDOCK_FLAG) $(BINDIST_LIBRARY_FLAGS) --global --builddir=dist-bindist --prefix="$(BINDIST_PREFIX)"
1421 cd libraries/xhtml && ./Setup build --builddir=dist-bindist
1422 ifeq "$(HADDOCK_DOCS)" "YES"
1423 cd libraries/xhtml && ./Setup haddock -v0 --ghc-options=-optP-P --builddir=dist-bindist
1424 endif
1425 cd libraries/xhtml && ./Setup install --builddir=dist-bindist
1426 cd libraries/xhtml && ./Setup clean --builddir=dist-bindist
1427 cd libraries/xhtml && rm -f Setup Setup.exe Setup.hi Setup.o
1428
1429 # Note [No stage2 packages when CrossCompiling or Stage1Only]
1430 #
1431 # (first read Note [CrossCompiling vs Stage1Only] and
1432 # Note [Stage1Only vs stage=1] in mk/config.mk.in)
1433 #
1434 # When either CrossCompiling=YES or Stage1Only=YES, we have to exclude the
1435 # following packages from the build:
1436 # * packages that we build with ghc-stage2 [1]
1437 # * packages that depend on the ghc library [2]
1438 #
1439 # Here's why:
1440 # - first of all, ghc-stage1 can't use stage0's ghc library (it's too old)
1441 # - neither do we register the ghc library (compiler/stage1) that we build
1442 # with stage0. TODO Why not? We do build it...
1443 # - as a result, we need to a) use ghc-stage2 to build packages that depend on
1444 # the ghc library (e.g. ghctags [4] and mkUserGuidePart) and b) exclude
1445 # those packages when ghc-stage2 is not available.
1446 # - when Stage1Only=YES, it's clear that ghc-stage2 is not available (we just
1447 # said we didn't want it), so we have to exclude the stage2 packages from
1448 # the build. This includes the case where Stage1Only=YES is combined with
1449 # CrossCompiling=YES (Building GHC as a cross-compiler [3]).
1450 # - when CrossCompiling=YES, but Stage1Only=NO (Cross-compiling GHC itself
1451 # [3]), we can not use ghc-stage2 either. The reason is that stage2 doesn't
1452 # run on the host platform at all; it is built to run on $(TARGETPLATFORM)"
1453 # [5]. Therefore in this case we also have to exclude the stage2 packages
1454 # from the build.
1455 #
1456 # [1] find utils -name ghc.mk | xargs grep -l 'build-prog.*,2'
1457 #
1458 # [2]
1459 # find utils -name package-data.mk | xargs grep -l 'DEP_NAMES =.* ghc\($\| \)'
1460 #
1461 # [3] https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling
1462 #
1463 # [4] 5fb72555f7b7ab67a33583f33ad9160761ca434f
1464 # "ghctags needs the stage2 compiler, since it uses the GHC API."
1465 #
1466 # [5] * bc31dbe8ee22819054df60f5ef219fed393a1c54
1467 # "Disable any packages built with stage 2 when cross-compiling
1468 # Since we can't run stage 2 on the host."
1469 #
1470 # * 72995160b0b190577b5c0cb8d7bd0426cc455b05
1471 # "We cannot use the stage 2 compiler, it runs on $(TARGETPLATFORM)"
1472
1473 # -----------------------------------------------------------------------------
1474 # Numbered phase targets
1475
1476 # In phase 1, we'll be building dependency files for most things
1477 # built by the bootstrapping compiler while make is 'include'ing
1478 # makefiles. But in order to build dependency files, we'll need to
1479 # build any automatically generated .hs files, which means that
1480 # we'll need to be able to build any tools that generate .hs files
1481 # etc. But in order to do that, we need to already know the
1482 # dependencies for those tools, so we build their dependency files
1483 # here.
1484 .PHONY: phase_0_builds
1485 # hsc2hs is needed, e.g. to make the .hs files for hpc.
1486 phase_0_builds: $(utils/hsc2hs_dist_depfile_haskell)
1487 phase_0_builds: $(utils/hsc2hs_dist_depfile_c_asm)
1488 # genprimopcode is needed to make the .hs-incl files that are in the
1489 # ghc package.
1490 phase_0_builds: $(utils/genprimopcode_dist_depfile_haskell)
1491 phase_0_builds: $(utils/genprimopcode_dist_depfile_c_asm)
1492 # deriveConstants is used to create header files included in the
1493 # ghc package.
1494 phase_0_builds: $(utils/deriveConstants_dist_depfile_haskell)
1495 phase_0_builds: $(utils/deriveConstants_dist_depfile_c_asm)
1496
1497 .PHONY: phase_1_builds
1498 phase_1_builds: $(PACKAGE_DATA_MKS)
1499