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