Test for misaligned sections, and fail if we find one
[ghc.git] / ghc.mk
1
2 # -----------------------------------------------------------------------------
3 #
4 # (c) 2009 The University of Glasgow
5 #
6 # This file is part of the GHC build system.
7 #
8 # To understand how the build system works and how to modify it, see
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
10 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11 #
12 # -----------------------------------------------------------------------------
13
14 # ToDo List.
15 #
16 # * remove old Makefiles, add new stubs for building in subdirs
17 # * docs/Makefile
18 # * docs/docbook-cheat-sheet/Makefile
19 # * docs/man/Makefile
20 # * docs/storage-mgmt/Makefile
21 # * docs/vh/Makefile
22 # * rts/dotnet/Makefile
23 # * utils/Makefile
24 # * add Makefiles for the rest of the utils/ programs that aren't built
25 # by default (need to exclude them from 'make all' too)
26
27 # Possible cleanups:
28 #
29 # * per-source-file dependencies instead of one .depend file?
30 # * eliminate undefined variables, and use --warn-undefined-variables?
31 # * put outputs from different ways in different subdirs of distdir/build,
32 # then we don't have to use -osuf/-hisuf. We would have to install
33 # them in different places too, so we'd need ghc-pkg support for packages
34 # of different ways.
35 # * make PACKAGES_STAGE1 generated by './configure' or './boot'?
36 # * we should use a directory of package.conf files rather than a single
37 # file for the inplace package database, so that we can express
38 # dependencies more accurately. Otherwise it's possible to get into
39 # a state where the package database is out of date, and the build
40 # system doesn't know.
41
42 # Approximate build order.
43 #
44 # The actual build order is defined by dependencies, and the phase
45 # ordering used to ensure correct ordering of makefile-generation; see
46 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
47 #
48 # * With bootstrapping compiler:
49 # o Build utils/ghc-cabal
50 # o Build utils/ghc-pkg
51 # o Build utils/hsc2hs
52 # * For each package:
53 # o configure, generate package-data.mk and inplace-pkg-info
54 # o register each package into inplace/lib/package.conf
55 # * build libffi
56 # * With bootstrapping compiler:
57 # o Build libraries/{filepath,hpc,Cabal}
58 # o Build compiler (stage 1)
59 # * With stage 1:
60 # o Build libraries/*
61 # o Build rts
62 # o Build utils/* (except haddock)
63 # o Build compiler (stage 2)
64 # * With stage 2:
65 # o Build utils/haddock
66 # o Build compiler (stage 3) (optional)
67 # * With haddock:
68 # o libraries/*
69 # o compiler
70
71 .PHONY: default all haddock
72
73 # We need second expansion for the way we handle directories, so that
74 # | $$$$(dir $$$$@)/.
75 # expands to the directory of a rule that uses a % pattern.
76 .SECONDEXPANSION:
77
78 default : all
79
80 # Catch make if it runs away into an infinite loop
81 ifeq "$(MAKE_RESTARTS)" ""
82 else ifeq "$(MAKE_RESTARTS)" "1"
83 else
84 $(error Make has restarted itself $(MAKE_RESTARTS) times; is there a makefile bug?)
85 endif
86
87 ifneq "$(CLEANING)" "YES"
88 CLEANING = NO
89 endif
90
91 # -----------------------------------------------------------------------------
92 # Misc GNU make utils
93
94 nothing=
95 space=$(nothing) $(nothing)
96 comma=,
97
98 # Cancel all suffix rules. Ideally we'd like to have 'make -r' turned on
99 # by default, because that disables all the implicit rules, but there doesn't
100 # seem to be a good way to do that. This turns off all the old-style suffix
101 # rules, which does half the job and speeds up make quite a bit:
102 .SUFFIXES:
103
104 # -----------------------------------------------------------------------------
105 # Makefile debugging
106 #
107 # to see the effective value used for a Makefile variable, do
108 # make show VALUE=MY_VALUE
109 #
110
111 show:
112 @echo '$(VALUE)="$($(VALUE))"'
113
114 # -----------------------------------------------------------------------------
115 # Include subsidiary build-system bits
116
117 include mk/tree.mk
118
119 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
120 include mk/config.mk
121 ifeq "$(ProjectVersion)" ""
122 $(error Please run ./configure first)
123 endif
124 endif
125
126 include mk/ways.mk
127
128 # (Optional) build-specific configuration
129 include mk/custom-settings.mk
130
131 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
132 ifeq "$(GhcLibWays)" ""
133 $(error $$(GhcLibWays) is empty, it must contain at least one way)
134 endif
135 endif
136
137 ifeq "$(phase)" ""
138 phase = final
139 endif
140
141 # -----------------------------------------------------------------------------
142 # Utility definitions
143
144 include rules/prof.mk
145 include rules/trace.mk
146 include rules/make-command.mk
147
148 # -----------------------------------------------------------------------------
149 # Macros for standard targets
150
151 include rules/all-target.mk
152 include rules/clean-target.mk
153
154 # -----------------------------------------------------------------------------
155 # The inplace tree
156
157 $(eval $(call clean-target,inplace,,inplace/bin inplace/lib))
158
159 # -----------------------------------------------------------------------------
160 # Whether to build dependencies or not
161
162 # When we're just doing 'make clean' or 'make show', then we don't need
163 # to build dependencies.
164
165 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
166 NO_INCLUDE_DEPS = YES
167 NO_INCLUDE_PKGDATA = YES
168 endif
169 ifneq "$(findstring bootstrapping-files,$(MAKECMDGOALS))" ""
170 NO_INCLUDE_DEPS = YES
171 NO_INCLUDE_PKGDATA = YES
172 endif
173 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
174 NO_INCLUDE_DEPS = YES
175 # We want package-data.mk for show
176 endif
177
178 # -----------------------------------------------------------------------------
179 # Ways
180
181 include rules/way-prelims.mk
182
183 $(foreach way,$(ALL_WAYS),\
184 $(eval $(call way-prelims,$(way))))
185
186 # -----------------------------------------------------------------------------
187 # Compilation Flags
188
189 include rules/distdir-way-opts.mk
190
191 # -----------------------------------------------------------------------------
192 # Finding source files and object files
193
194 include rules/hs-sources.mk
195 include rules/c-sources.mk
196 include rules/includes-sources.mk
197 include rules/hs-objs.mk
198 include rules/c-objs.mk
199 include rules/cmm-objs.mk
200
201 # -----------------------------------------------------------------------------
202 # Suffix rules
203
204 # Suffix rules cause "make clean" to fail on Windows (trac #3233)
205 # so we don't make any when cleaning.
206 ifneq "$(CLEANING)" "YES"
207
208 include rules/hs-suffix-rules-srcdir.mk
209 include rules/hs-suffix-rules.mk
210 include rules/hi-rule.mk
211
212 $(foreach way,$(ALL_WAYS),\
213 $(eval $(call hi-rule,$(way))))
214
215 include rules/c-suffix-rules.mk
216 include rules/cmm-suffix-rules.mk
217
218 endif # CLEANING=YES
219
220 # -----------------------------------------------------------------------------
221 # Building package-data.mk files from .cabal files
222
223 include rules/package-config.mk
224
225 # -----------------------------------------------------------------------------
226 # Building dependencies
227
228 include rules/dependencies.mk
229 include rules/build-dependencies.mk
230 include rules/include-dependencies.mk
231
232 # -----------------------------------------------------------------------------
233 # Build package-data.mk files
234
235 include rules/build-package-data.mk
236
237 # -----------------------------------------------------------------------------
238 # Build and install a program
239
240 include rules/build-prog.mk
241 include rules/shell-wrapper.mk
242
243 # -----------------------------------------------------------------------------
244 # Build a perl script
245
246 include rules/build-perl.mk
247
248 # -----------------------------------------------------------------------------
249 # Build a package
250
251 include rules/build-package.mk
252 include rules/build-package-way.mk
253 include rules/haddock.mk
254 include rules/tags-package.mk
255 include rules/extra-packages.mk
256
257 # -----------------------------------------------------------------------------
258 # Registering hand-written package descriptions (used in rts)
259
260 include rules/manual-package-config.mk
261
262 # -----------------------------------------------------------------------------
263 # Docs
264
265 include rules/docbook.mk
266
267 # -----------------------------------------------------------------------------
268 # Making bindists
269
270 include rules/bindist.mk
271
272 # -----------------------------------------------------------------------------
273 # Directories
274
275 # Don't try to delete directories:
276 .PRECIOUS: %/.
277
278 # Create build directories on demand. NB. the | below: this indicates
279 # that $(MKDIRHIER) is an order-only dependency, which means that this
280 # rule fires after building mkdirhier, but we won't try to recreate
281 # directories if mkdirhier changes.
282 %/. : | $(MKDIRHIER)
283 "$(MKDIRHIER)" $@
284
285 # -----------------------------------------------------------------------------
286 # Lax dependencies
287
288 ifeq "$(LAX_DEPENDENCIES)" "YES"
289 LAX_DEPS_FOLLOW = |
290 else
291 LAX_DEPS_FOLLOW =
292 endif
293
294 # This is a bit of a hack. When LAX_DEPS_FOLLOW is | some rules end up
295 # looking like
296 # target: a | b | c
297 # The first | signals the start of the order-only dependencies, but make
298 # treats the second | as a dependency. So we need to tell make how to
299 # build that dependency.
300
301 .PHONY: |
302 | :
303 @:
304
305 # -----------------------------------------------------------------------------
306 # Properties of packages
307
308 # These lists say "if this package is built, here's a property it has"
309 # They do not say "this package will be built"; see $(PACKAGES_xx) for that
310
311 # Packages that are built but not installed
312 PKGS_THAT_ARE_INTREE_ONLY := haskeline mtl terminfo utf8-string xhtml
313
314 PKGS_THAT_ARE_DPH := \
315 dph/dph-base \
316 dph/dph-prim-interface dph/dph-prim-seq dph/dph-prim-par \
317 dph/dph-lifted-base \
318 dph/dph-lifted-boxed dph/dph-lifted-copy dph/dph-lifted-vseg \
319 vector primitive random
320
321 # Packages that, if present, must be built by the stage2 compiler,
322 # because they use TH and/or annotations, or depend on other stage2
323 # packages:
324 PKGS_THAT_BUILD_WITH_STAGE2 := $(PKGS_THAT_ARE_DPH) haskell98 haskell2010
325
326 # Packages that we shouldn't build if we don't have TH (e.g. because
327 # we're building a profiled compiler):
328 PKGS_THAT_USE_TH := $(PKGS_THAT_ARE_DPH)
329
330 # Packages that are built by stage0, in addition to stage1. These
331 # packages are dependencies of GHC, that we do not assume the stage0
332 # compiler already has installed (or up-to-date enough).
333 #
334 # We assume that the stage0 compiler has a suitable bytestring package,
335 # so we don't have to include it below.
336 PKGS_THAT_BUILD_WITH_STAGE0 = Cabal/Cabal hpc binary bin-package-db hoopl
337
338 # $(EXTRA_PACKAGES) is another classification, of packages built but
339 # not installed
340 # It is set in rules/extra-package.mk,
341 # by $(call extra-packages) a little further down
342 # this ghc.mk
343
344
345
346 # ----------------------------------------------------------------------------
347 # Packages to build
348 # The lists of packages that we *actually* going to build in each stage:
349 #
350 # $(PACKAGES_STAGE0)
351 # $(PACKAGES_STAGE1)
352 # $(PACKAGES_STAGE2)
353 #
354 # These are automatically derived from
355 # (a) the set of packages in this source tree
356 # (b) the predicates above, e.g. $(PKGS_THAT_BUILD_WITH_STAGE2)
357 # (c) which platform we're on, and a few other things
358
359
360 # no processing to do on this one: it really is the list of packages
361 # to build with stage 0.
362 PACKAGES_STAGE0 = $(PKGS_THAT_BUILD_WITH_STAGE0)
363
364 define addPackageGeneral
365 # args: $1 = PACKAGES variable, $2 = package, $3 = condition
366 ifeq "$3" ""
367 $1 += $2
368 else
369 ifeq "$$(CLEANING)" "YES"
370 $1 += $2
371 else
372 ifeq $3
373 $1 += $2
374 endif
375 endif
376 endif
377 endef
378
379 define addPackage # args: $1 = package, $2 = condition
380 ifneq "$(filter $1,$(PKGS_THAT_USE_TH)) $(GhcProfiled)" "$1 YES"
381 ifeq "$(filter $1,$(PKGS_THAT_BUILD_WITH_STAGE2))" "$1"
382 ifneq "$(BuildingCrossCompiler)" "YES"
383 $(call addPackageGeneral,PACKAGES_STAGE2,$1,$2)
384 endif
385 else
386 $(call addPackageGeneral,PACKAGES_STAGE1,$1,$2)
387 endif
388 endif
389 endef
390
391 $(eval $(call addPackage,ghc-prim))
392 ifeq "$(CLEANING)" "YES"
393 $(eval $(call addPackage,integer-gmp))
394 $(eval $(call addPackage,integer-simple))
395 else
396 $(eval $(call addPackage,$(INTEGER_LIBRARY)))
397 endif
398 $(eval $(call addPackage,base))
399 $(eval $(call addPackage,filepath))
400 $(eval $(call addPackage,array))
401 $(eval $(call addPackage,deepseq))
402 $(eval $(call addPackage,bytestring))
403 $(eval $(call addPackage,containers))
404
405 $(eval $(call addPackage,Win32,($$(Windows),YES)))
406 $(eval $(call addPackage,unix,($$(Windows),NO)))
407
408 $(eval $(call addPackage,old-locale))
409 $(eval $(call addPackage,old-time))
410 $(eval $(call addPackage,time))
411 $(eval $(call addPackage,directory))
412 $(eval $(call addPackage,process))
413 $(eval $(call addPackage,haskell98))
414 $(eval $(call addPackage,haskell2010))
415 $(eval $(call addPackage,hpc))
416 $(eval $(call addPackage,pretty))
417 $(eval $(call addPackage,template-haskell))
418 $(eval $(call addPackage,Cabal/Cabal))
419 $(eval $(call addPackage,binary))
420 $(eval $(call addPackage,bin-package-db))
421 $(eval $(call addPackage,hoopl))
422 $(eval $(call addPackage,mtl))
423 $(eval $(call addPackage,utf8-string))
424 $(eval $(call addPackage,xhtml))
425 $(eval $(call addPackage,terminfo,($$(Windows),NO)))
426 $(eval $(call addPackage,haskeline))
427
428 $(eval $(call extra-packages))
429
430 # -------------------------------------------
431 # Dependencies between package-data.mk files
432
433 # We cannot run ghc-cabal to configure a package until we have
434 # configured and registered all of its dependencies. So the following
435 # hack forces all the configure steps to happen in exactly the following order:
436 #
437 # $(PACKAGES_STAGE1) ghc(stage2) $(PACKAGES_STAGE2)
438 #
439 # Ideally we should use the correct dependencies here to allow more
440 # parallelism, but we don't know the dependencies until we've
441 # generated the package-data.mk files.
442 define fixed_pkg_dep
443 libraries/$1/$2/package-data.mk : $$(GHC_PKG_INPLACE) $$(fixed_pkg_prev)
444 fixed_pkg_prev:=libraries/$1/$2/package-data.mk
445 endef
446
447 ifneq "$(BINDIST)" "YES"
448 fixed_pkg_prev=
449 $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
450
451 # the GHC package doesn't live in libraries/, so we add its dependency manually:
452 compiler/stage2/package-data.mk: $(fixed_pkg_prev)
453 fixed_pkg_prev:=compiler/stage2/package-data.mk
454
455 # and continue with PACKAGES_STAGE2, which depend on GHC:
456 $(foreach pkg,$(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
457
458 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
459 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
460 # haddock depends on ghc and some libraries, but depending on GHC's
461 # package-data.mk is sufficient, as that in turn depends on all the
462 # libraries
463 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
464 utils/ghc-pwd/dist-install/package-data.mk: compiler/stage2/package-data.mk
465 utils/ghc-cabal/dist-install/package-data.mk: compiler/stage2/package-data.mk
466
467 utils/ghc-pkg/dist-install/package-data.mk: compiler/stage2/package-data.mk
468 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
469 utils/compare_sizes/dist-install/package-data.mk: compiler/stage2/package-data.mk
470 utils/runghc/dist-install/package-data.mk: compiler/stage2/package-data.mk
471
472 # add the final package.conf dependency: ghc-prim depends on RTS
473 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
474 endif
475
476 # --------------------------------
477 # Misc package-related settings
478
479 BOOT_PKG_CONSTRAINTS := \
480 $(foreach d,$(PACKAGES_STAGE0),\
481 $(foreach p,$(basename $(notdir $(wildcard libraries/$d/*.cabal))),\
482 --constraint "$p == $(shell grep -i "^Version:" libraries/$d/$p.cabal | sed "s/[^0-9.]//g")"))
483
484 # The actual .a and .so/.dll files: needed for dependencies.
485 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_v_LIB))
486 ifeq "$(BuildSharedLibs)" "YES"
487 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_dyn_LIB))
488 endif
489 BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB))
490
491 # ----------------------------------------
492 # Special magic for the ghc-prim package
493
494 # We want the ghc-prim package to include the GHC.Prim module when it
495 # is registered, but not when it is built, because GHC.Prim is not a
496 # real source module, it is built-in to GHC. The old build system did
497 # this using Setup.hs, but we can't do that here, so we have a flag to
498 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
499 # remains compatible with the old build system for the time being).
500 # GHC.Prim module in the ghc-prim package with a flag:
501 #
502 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
503
504 # And then we strip it out again before building the package:
505 define libraries/ghc-prim_PACKAGE_MAGIC
506 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
507 endef
508
509 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
510
511 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT) | $$(dir $$@)/.
512 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
513
514 # Required so that Haddock documents the primops.
515 libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
516
517 # ----------------------------------------
518 # Special magic for the integer package
519
520 ifneq "$(CLEANING)" "YES"
521 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
522 libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
523 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
524 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
525 else
526 $(error Unknown integer library: $(INTEGER_LIBRARY))
527 endif
528 endif
529
530 # ----------------------------------------------
531 # Checking packages with 'cabal check'
532
533 ifeq "$(phase)" "final"
534 ifeq "$(CHECK_PACKAGES)" "YES"
535 all: check_packages
536 endif
537 endif
538
539 # These packages don't pass the Cabal checks because hs-source-dirs
540 # points outside the source directory. This isn't a real problem in
541 # these cases, so we just skip checking them.
542 # NB. these must come before we include the ghc.mk files below, because
543 # they disable the relevant rules.
544 # In compiler's case, include-dirs points outside of the source tree
545 CHECKED_compiler = YES
546
547 # -----------------------------------------------------------------------------
548 # Include build instructions from all subdirs
549
550 ifneq "$(BINDIST)" "YES"
551 BUILD_DIRS += \
552 $(GHC_MKDIRHIER_DIR)
553 endif
554
555 ifeq "$(Windows)" "YES"
556 BUILD_DIRS += \
557 $(GHC_TOUCHY_DIR)
558 endif
559
560 BUILD_DIRS += \
561 docs/users_guide \
562 docs/man \
563 $(GHC_UNLIT_DIR) \
564 $(GHC_HP2PS_DIR)
565
566 ifneq "$(GhcUnregisterised)" "YES"
567 BUILD_DIRS += \
568 $(GHC_SPLIT_DIR)
569 endif
570
571 ifneq "$(BINDIST)" "YES"
572 BUILD_DIRS += \
573 $(GHC_GENPRIMOP_DIR)
574 endif
575
576 ifeq "$(BuildingCrossCompiler)-$(phase)" "YES-final"
577 MAYBE_GHCI=
578 else
579 MAYBE_GHCI=driver/ghci
580 endif
581
582 BUILD_DIRS += \
583 driver \
584 $(MAYBE_GHCI) \
585 driver/ghc \
586 driver/haddock \
587 libffi \
588 includes \
589 rts
590
591 ifneq "$(BINDIST)" "YES"
592 BUILD_DIRS += \
593 bindisttest \
594 $(GHC_GENAPPLY_DIR)
595 endif
596
597 ifneq "$(CLEANING)" "YES"
598 BUILD_DIRS += \
599 $(patsubst %, libraries/%, $(PACKAGES_STAGE1))
600 endif
601
602 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
603 BUILD_DIRS += libraries/integer-gmp/gmp
604 else ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
605 BUILD_DIRS += libraries/integer-gmp/gmp
606 endif
607
608 ifeq "$(BuildingCrossCompiler)-$(phase)" "YES-final"
609 MAYBE_COMPILER=
610 MAYBE_GHCTAGS=
611 MAYBE_HPC=
612 MAYBE_RUNGHC=
613 else
614 MAYBE_COMPILER=compiler
615 MAYBE_GHCTAGS=utils/ghctags
616 MAYBE_HPC=utils/hpc
617 MAYBE_RUNGHC=utils/runghc
618 endif
619
620 BUILD_DIRS += \
621 utils/haddock \
622 utils/haddock/doc \
623 $(MAYBE_COMPILER) \
624 $(GHC_HSC2HS_DIR) \
625 $(GHC_PKG_DIR) \
626 utils/testremove \
627 $(MAYBE_GHCTAGS) \
628 utils/ghc-pwd \
629 $(GHC_CABAL_DIR) \
630 $(MAYBE_HPC) \
631 $(MAYBE_RUNGHC) \
632 ghc
633
634 ifneq "$(BINDIST)" "YES"
635 ifneq "$(BuildingCrossCompiler)-$(phase)" "YES-final"
636 BUILD_DIRS += \
637 utils/mkUserGuidePart
638 endif
639 endif
640
641 BUILD_DIRS += utils/count_lines
642 BUILD_DIRS += utils/compare_sizes
643
644 ifneq "$(CLEANING)" "YES"
645 # After compiler/, because these packages depend on it
646 BUILD_DIRS += \
647 $(patsubst %, libraries/%, $(PACKAGES_STAGE2))
648 endif
649
650 # ----------------------------------------------
651 # Actually include all the sub-ghc.mk's
652
653 # BUILD_DIRS_EXTRA needs to come after BUILD_DIRS, because stuff in
654 # libraries/dph/ghc.mk refers to stuff defined earlier, in particular
655 # things like $(libraries/dph/dph-base_dist-install_GHCI_LIB)
656 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS) $(BUILD_DIRS_EXTRA))
657
658 # A useful pseudo-target (must be after the include above, because it needs
659 # the value of things like $(libraries/base_dist-install_v_LIB).
660 .PHONY: stage1_libs
661 stage1_libs : $(ALL_STAGE1_LIBS)
662
663 # ----------------------------------------------
664 # Per-package compiler flags
665 #
666 # If you want to add per-package compiler flags, this
667 # is the place to do it. Do it like this for package <pkg>
668 #
669 # libraries/<pkg>_dist-boot_HC_OPTS += -Wwarn
670 # libraries/<pkg>_dist-install_HC_OPTS += -Wwarn
671
672 # Add $(GhcLibHcOpts) to all package builds
673 $(foreach pkg,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
674
675 # Add $(GhcBootLibHcOpts) to all stage0 package builds
676 $(foreach pkg,$(PACKAGES_STAGE0),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
677
678 # -----------------------------------------------
679 # Haddock-related bits
680
681 # Don't run Haddock for the package that will not be installed
682 $(foreach p,$(PKGS_THAT_ARE_INTREE_ONLY),$(eval libraries/$p_dist-install_DO_HADDOCK = NO))
683 # We don't haddock the bootstrapping libraries
684 $(foreach p,$(PACKAGES_STAGE0),$(eval libraries/$p_dist-boot_DO_HADDOCK = NO))
685
686 # Build the Haddock contents and index
687 ifeq "$(HADDOCK_DOCS)" "YES"
688 libraries/dist-haddock/index.html: inplace/bin/haddock$(exeext) $(ALL_HADDOCK_FILES)
689 cd libraries && sh gen_contents_index --inplace
690 ifeq "$(phase)" "final"
691 $(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
692 endif
693 INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
694 endif
695
696 # -----------------------------------------------------------------------------
697 # Bootstrapping libraries
698
699 # We need to build a few libraries with the installed GHC, since GHC itself
700 # and some of the tools depend on them:
701
702 ifneq "$(BINDIST)" "YES"
703
704 ifneq "$(BOOTSTRAPPING_CONF)" ""
705 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
706 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
707 endif
708 endif
709
710 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
711
712 # register the boot packages in strict sequence, because running
713 # multiple ghc-pkgs in parallel doesn't work (registrations may get
714 # lost).
715 fixed_pkg_prev=
716 $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
717
718 compiler/stage1/package-data.mk : $(fixed_pkg_prev)
719 endif
720
721 ifneq "$(BINDIST)" "YES"
722 # Make sure we have all the GHCi libs by the time we've built
723 # ghc-stage2. DPH includes a bit of Template Haskell which needs the
724 # GHCI libs, and we don't have a better way to express that dependency.
725 #
726 GHCI_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_GHCI_LIB)) \
727 $(compiler_stage2_GHCI_LIB)
728
729 ifeq "$(UseArchivesForGhci)" "NO"
730 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(GHCI_LIBS)
731 endif
732
733 ifeq "$(UseArchivesForGhci)" "YES"
734 GHCI_lib_way = v
735 else
736 GHCI_lib_way = GHCI
737 endif
738
739 # Deps for TH uses in libraries
740 $(foreach way, $(GhcLibWays),$(eval \
741 libraries/vector/dist-install/build/Data/Vector/Fusion/Stream/Monadic.$($(way)_osuf): \
742 $(libraries/primitive_dist-install_$(GHCI_lib_way)_LIB) \
743 ))
744 endif
745
746 # -----------------------------------------------------------------------------
747 # Creating a local mingw copy on Windows
748
749 ifeq "$(Windows)" "YES"
750
751 install : install_mingw
752 .PHONY: install_mingw
753 install_mingw : $(INPLACE_MINGW)
754 "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
755
756 install : install_perl
757 .PHONY: install_perl
758 install_perl : $(INPLACE_PERL)
759 "$(CP)" -Rp $(INPLACE_PERL) $(prefix)
760
761 endif # Windows
762
763 ifneq "$(BINDIST)" "YES"
764 $(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \
765 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
766 endif # BINDIST
767
768 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
769 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) \
770 | $$(dir $$@)/.
771 "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
772
773 .PHONY: tags
774 tags: tags_compiler
775
776 .PHONY: TAGS
777 TAGS: TAGS_compiler
778
779 # -----------------------------------------------------------------------------
780 # Installation
781
782 install: install_libs install_packages install_libexecs \
783 install_libexec_scripts install_bins install_topdirs
784 ifeq "$(HADDOCK_DOCS)" "YES"
785 install: install_docs
786 endif
787
788 install_bins: $(INSTALL_BINS)
789 $(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
790 for i in $(INSTALL_BINS); do \
791 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(bindir)") ; \
792 done
793
794 install_libs: $(INSTALL_LIBS)
795 $(call INSTALL_DIR,"$(DESTDIR)$(ghclibdir)")
796 for i in $(INSTALL_LIBS); do \
797 case $$i in \
798 *.a) \
799 $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)"); \
800 $(RANLIB) $(DESTDIR)$(ghclibdir)/`basename $$i` ;; \
801 *.dll) \
802 $(call INSTALL_PROGRAM,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)") ; \
803 $(STRIP_CMD) "$(DESTDIR)$(ghclibdir)"/$$i ;; \
804 *.so) \
805 $(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)") ;; \
806 *.dylib) \
807 $(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)");; \
808 *) \
809 $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)"); \
810 esac; \
811 done
812
813 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
814 ifeq "$(INSTALL_LIBEXEC_SCRIPTS)" ""
815 @:
816 else
817 $(call INSTALL_DIR,"$(DESTDIR)$(ghclibexecdir)")
818 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
819 $(call INSTALL_SCRIPT,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibexecdir)"); \
820 done
821 endif
822
823 install_libexecs: $(INSTALL_LIBEXECS)
824 ifeq "$(INSTALL_LIBEXECS)" ""
825 @:
826 else
827 $(call INSTALL_DIR,"$(DESTDIR)$(ghclibexecdir)")
828 for i in $(INSTALL_LIBEXECS); do \
829 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(ghclibexecdir)"); \
830 done
831 # We rename ghc-stage2, so that the right program name is used in error
832 # messages etc.
833 "$(MV)" "$(DESTDIR)$(ghclibexecdir)/ghc-stage$(INSTALL_GHC_STAGE)" "$(DESTDIR)$(ghclibexecdir)/ghc"
834 endif
835
836 install_topdirs: $(INSTALL_TOPDIRS)
837 $(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
838 for i in $(INSTALL_TOPDIRS); do \
839 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(topdir)"); \
840 done
841
842 install_docs: $(INSTALL_DOCS)
843 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)")
844 ifneq "$(INSTALL_DOCS)" ""
845 for i in $(INSTALL_DOCS); do \
846 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(docdir)"); \
847 done
848 endif
849 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)/html")
850 $(call INSTALL_DOC,$(INSTALL_OPTS),docs/index.html,"$(DESTDIR)$(docdir)/html")
851 ifneq "$(INSTALL_LIBRARY_DOCS)" ""
852 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)/html/libraries")
853 for i in $(INSTALL_LIBRARY_DOCS); do \
854 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(docdir)/html/libraries/"); \
855 done
856 $(call INSTALL_DATA,$(INSTALL_OPTS),libraries/prologue.txt,"$(DESTDIR)$(docdir)/html/libraries/")
857 $(call INSTALL_SCRIPT,$(INSTALL_OPTS),libraries/gen_contents_index,"$(DESTDIR)$(docdir)/html/libraries/")
858 endif
859 ifneq "$(INSTALL_HTML_DOC_DIRS)" ""
860 for i in $(INSTALL_HTML_DOC_DIRS); do \
861 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)/html/`basename $$i`"); \
862 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i/*,"$(DESTDIR)$(docdir)/html/`basename $$i`"); \
863 done
864 endif
865
866 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
867
868 # Install packages in the right order, so that ghc-pkg doesn't complain.
869 # Also, install ghc-pkg first.
870 ifeq "$(Windows)" "NO"
871 INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/ghc
872 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/ghc-pkg
873 else
874 INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
875 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
876 endif
877
878 INSTALLED_PKG_DIRS := $(addprefix libraries/,$(PACKAGES_STAGE1))
879 ifeq "$(BuildingCrossCompiler)" "NO"
880 INSTALLED_PKG_DIRS := $(INSTALLED_PKG_DIRS) compiler
881 endif
882 INSTALLED_PKG_DIRS := $(INSTALLED_PKG_DIRS) $(addprefix libraries/,$(PACKAGES_STAGE2))
883 ifeq "$(InstallExtraPackages)" "NO"
884 INSTALLED_PKG_DIRS := $(filter-out $(addprefix libraries/,$(EXTRA_PACKAGES)),\
885 $(INSTALLED_PKG_DIRS))
886 endif
887 INSTALLED_PKG_DIRS := $(filter-out $(addprefix libraries/,$(PKGS_THAT_ARE_INTREE_ONLY)),\
888 $(INSTALLED_PKG_DIRS))
889
890 # Set the INSTALL_DISTDIR_p for each package; compiler is special
891 $(foreach p,$(filter-out compiler,$(INSTALLED_PKG_DIRS)),\
892 $(eval INSTALL_DISTDIR_$p = dist-install))
893 INSTALL_DISTDIR_compiler = stage2
894
895 # Now we can do the installation
896 install_packages: install_libexecs
897 install_packages: rts/package.conf.install
898 $(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
899 $(call removeTrees,"$(INSTALLED_PACKAGE_CONF)")
900 $(call INSTALL_DIR,"$(INSTALLED_PACKAGE_CONF)")
901 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
902 $(foreach p, $(INSTALLED_PKG_DIRS), \
903 $(call make-command, \
904 CROSS_COMPILE="$(CrossCompilePrefix)" \
905 "$(GHC_CABAL_INPLACE)" install \
906 "$(INSTALLED_GHC_REAL)" \
907 "$(INSTALLED_GHC_PKG_REAL)" \
908 "$(STRIP_CMD)" \
909 "$(DESTDIR)$(topdir)" \
910 $p $(INSTALL_DISTDIR_$p) \
911 '$(DESTDIR)' \
912 '$(prefix)' \
913 '$(ghclibdir)' \
914 '$(docdir)/html/libraries' \
915 $(RelocatableBuild)))
916 # when we install the packages above, ghc-pkg obeys umask when creating
917 # the package.conf files, but for everything else we specify the
918 # permissions. We therefore now fix the permissions of package.cache.
919 # This means "sudo make install" does the right thing even if it runs
920 # with an 077 umask.
921 for f in '$(INSTALLED_PACKAGE_CONF)'/*; do $(CREATE_DATA) "$$f"; done
922
923 # -----------------------------------------------------------------------------
924 # Binary distributions
925
926 ifneq "$(CLEANING)" "YES"
927 # This rule seems to hold some files open on Windows which prevents
928 # cleaning, perhaps due to the $(wildcard).
929
930 $(eval $(call bindist,.,\
931 LICENSE \
932 README \
933 INSTALL \
934 configure config.sub config.guess install-sh \
935 settings.in \
936 packages \
937 Makefile \
938 mk/config.mk.in \
939 $(INPLACE_BIN)/mkdirhier \
940 utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
941 utils/ghc-pwd/dist-install/build/tmp/ghc-pwd \
942 $(BINDIST_WRAPPERS) \
943 $(BINDIST_PERL_SOURCES) \
944 $(BINDIST_LIBS) \
945 $(BINDIST_HI) \
946 $(BINDIST_EXTRAS) \
947 $(includes_H_FILES) \
948 $(includes_DERIVEDCONSTANTS) \
949 $(includes_GHCCONSTANTS) \
950 $(libffi_HEADERS) \
951 $(INSTALL_LIBEXECS) \
952 $(INSTALL_LIBEXEC_SCRIPTS) \
953 $(INSTALL_TOPDIRS) \
954 $(INSTALL_BINS) \
955 $(INSTALL_MANPAGES) \
956 $(INSTALL_DOCS) \
957 $(INSTALL_LIBRARY_DOCS) \
958 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
959 docs/index.html \
960 compiler/stage2/doc \
961 $(wildcard libraries/*/dist-install/doc/) \
962 $(wildcard libraries/*/*/dist-install/doc/) \
963 $(filter-out settings,$(INSTALL_LIBS)) \
964 $(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
965 mk/project.mk \
966 mk/install.mk.in \
967 bindist.mk \
968 libraries/gen_contents_index \
969 libraries/prologue.txt \
970 $(wildcard libraries/dph/LICENSE \
971 libraries/dph/ghc-packages \
972 libraries/dph/ghc-packages2 \
973 libraries/dph/ghc-stage2-package) \
974 ))
975 endif
976 # mk/project.mk gets an absolute path, so we manually include it in
977 # the bindist with a relative path
978
979 BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
980
981 unix-binary-dist-prep:
982 $(call removeTrees,bindistprep/)
983 "$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
984 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
985 echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
986 echo "LATEX_DOCS = $(LATEX_DOCS)" >> $(BIN_DIST_MK)
987 echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
988 echo "BUILD_DOCBOOK_PS = $(BUILD_DOCBOOK_PS)" >> $(BIN_DIST_MK)
989 echo "BUILD_DOCBOOK_PDF = $(BUILD_DOCBOOK_PDF)" >> $(BIN_DIST_MK)
990 echo "BUILD_MAN = $(BUILD_MAN)" >> $(BIN_DIST_MK)
991 echo "GHC_CABAL_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal" >> $(BIN_DIST_MK)
992 cd $(BIN_DIST_PREP_DIR) && autoreconf
993 $(call removeFiles,$(BIN_DIST_PREP_TAR))
994 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
995 # tree then we want to include the real file, not a symlink to it
996 cd bindistprep && "$(TAR_CMD)" hcf - -T ../$(BIN_DIST_LIST) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
997
998 windows-binary-dist-prep:
999 $(call removeTrees,bindistprep/)
1000 $(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
1001 cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
1002
1003 windows-installer:
1004 ifeq "$(ISCC_CMD)" ""
1005 @echo No ISCC_CMD, so not making installer
1006 else
1007 "$(ISCC_CMD)" /O. /Fbindistprep/$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
1008 endif
1009
1010 # tryTimes tries to run its third argument multiple times, until it
1011 # succeeds. Don't call it directly; call try10Times instead.
1012 # The first and second argument to tryTimes are lists of values.
1013 # The length of the first argument is the number of times we have
1014 # already tried. The length of the second argument is the number more
1015 # times we will try.
1016 tryTimes = $(if $2, \
1017 { echo 'Try $(words x $1): $3' ; $3 ; } || \
1018 $(call tryTimes,x $1,$(wordlist 2,$(words $2),$2),$3), \
1019 )
1020
1021 # Try to run the argument 10 times. If all 10 fail, fail.
1022 try10Times = $(call tryTimes,,x x x x x x x x x x,$1) { echo Failed; false; }
1023
1024 .PHONY: publish-binary-dist
1025 publish-binary-dist:
1026 $(call try10Times,$(PublishCp) $(BIN_DIST_TAR_BZ2) $(PublishLocation)/dist)
1027 ifeq "$(mingw32_TARGET_OS)" "1"
1028 $(call try10Times,$(PublishCp) $(WINDOWS_INSTALLER) $(PublishLocation)/dist)
1029 endif
1030
1031 ifeq "$(mingw32_TARGET_OS)" "1"
1032 DOCDIR_TO_PUBLISH = bindisttest/"install dir"/doc
1033 else
1034 DOCDIR_TO_PUBLISH = bindisttest/"install dir"/share/doc/ghc
1035 endif
1036
1037 .PHONY: publish-docs
1038 publish-docs:
1039 $(call try10Times,$(PublishCp) -r $(DOCDIR_TO_PUBLISH)/* $(PublishLocation)/docs)
1040
1041 # -----------------------------------------------------------------------------
1042 # Source distributions
1043
1044 # Do it like this:
1045 #
1046 # $ make
1047 # $ make sdist
1048 #
1049
1050 # A source dist is built from a complete build tree, because we
1051 # require some extra files not contained in a darcs checkout: the
1052 # output from Happy and Alex, for example.
1053 #
1054 # The steps performed by 'make dist' are as follows:
1055 # - create a complete link-tree of the current build tree in /tmp
1056 # - run 'make distclean' on that tree
1057 # - remove a bunch of other files that we know shouldn't be in the dist
1058 # - tar up first the extralibs package, then the main source package
1059
1060 #
1061 # Directory in which we're going to build the src dist
1062 #
1063 SRC_DIST_ROOT = sdistprep
1064 SRC_DIST_BASE_NAME = ghc-$(ProjectVersion)
1065
1066 SRC_DIST_GHC_NAME = ghc-$(ProjectVersion)-src
1067 SRC_DIST_GHC_ROOT = $(SRC_DIST_ROOT)/ghc
1068 SRC_DIST_GHC_DIR = $(SRC_DIST_GHC_ROOT)/$(SRC_DIST_BASE_NAME)
1069 SRC_DIST_GHC_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_GHC_NAME).tar.bz2
1070
1071 SRC_DIST_TESTSUITE_NAME = ghc-$(ProjectVersion)-testsuite
1072 SRC_DIST_TESTSUITE_ROOT = $(SRC_DIST_ROOT)/testsuite-ghc
1073 SRC_DIST_TESTSUITE_DIR = $(SRC_DIST_TESTSUITE_ROOT)/$(SRC_DIST_BASE_NAME)
1074 SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME).tar.bz2
1075
1076 #
1077 # Files to include in source distributions
1078 #
1079 SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \
1080 utils docs rts compiler ghc driver libraries ghc-tarballs
1081 SRC_DIST_GHC_FILES += \
1082 configure.ac config.guess config.sub configure \
1083 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
1084 ghc.spec.in ghc.spec settings.in VERSION \
1085 boot boot-pkgs packages ghc.mk
1086
1087 VERSION :
1088 echo $(ProjectVersion) >VERSION
1089
1090 sdist : VERSION
1091
1092 # Use:
1093 # $(call sdist_ghc_file,compiler,stage2,cmm,Foo/Bar,CmmLex,x)
1094 # to copy the generated file that replaces compiler/cmm/Foo/Bar/CmmLex.x, where
1095 # "stage2" is the dist dir.
1096 define sdist_ghc_file
1097 "$(CP)" $1/$2/build/$4/$5.hs $(SRC_DIST_GHC_DIR)/$1/$3/$4
1098 mv $(SRC_DIST_GHC_DIR)/$1/$3/$4/$5.$6 $(SRC_DIST_GHC_DIR)/$1/$3/$4/$5.$6.source
1099 endef
1100
1101 .PHONY: sdist-ghc-prep
1102 sdist-ghc-prep :
1103 $(call removeTrees,$(SRC_DIST_GHC_ROOT))
1104 $(call removeFiles,$(SRC_DIST_GHC_TARBALL))
1105 -mkdir $(SRC_DIST_ROOT)
1106 mkdir $(SRC_DIST_GHC_ROOT)
1107 mkdir $(SRC_DIST_GHC_DIR)
1108 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_DIRS); do mkdir $$i; ( cd $$i && lndir $(TOP)/$$i ); done
1109 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_FILES); do $(LN_S) $(TOP)/$$i .; done
1110 cd $(SRC_DIST_GHC_DIR) && $(MAKE) distclean
1111 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/tarballs/)
1112 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/stamp/)
1113 $(call removeTrees,$(SRC_DIST_GHC_DIR)/compiler/stage[123])
1114 $(call removeFiles,$(SRC_DIST_GHC_DIR)/mk/build.mk)
1115 $(call sdist_ghc_file,compiler,stage2,cmm,,CmmLex,x)
1116 $(call sdist_ghc_file,compiler,stage2,cmm,,CmmParse,y)
1117 $(call sdist_ghc_file,compiler,stage2,parser,,Lexer,x)
1118 $(call sdist_ghc_file,compiler,stage2,parser,,Parser,y.pp)
1119 $(call sdist_ghc_file,compiler,stage2,parser,,ParserCore,y)
1120 $(call sdist_ghc_file,utils/hpc,dist-install,,,HpcParser,y)
1121 $(call sdist_ghc_file,utils/genprimopcode,dist,,,Lexer,x)
1122 $(call sdist_ghc_file,utils/genprimopcode,dist,,,Parser,y)
1123 $(call sdist_ghc_file,utils/haddock,dist,src,Haddock,Lex,x)
1124 $(call sdist_ghc_file,utils/haddock,dist,src,Haddock,Parse,y)
1125 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)
1126
1127 .PHONY: sdist-testsuite-prep
1128 sdist-testsuite-prep :
1129 $(call removeTrees,$(SRC_DIST_TESTSUITE_ROOT))
1130 $(call removeFiles,$(SRC_DIST_TESTSUITE_TARBALL))
1131 -mkdir $(SRC_DIST_ROOT)
1132 mkdir $(SRC_DIST_TESTSUITE_ROOT)
1133 mkdir $(SRC_DIST_TESTSUITE_DIR)
1134 mkdir $(SRC_DIST_TESTSUITE_DIR)/testsuite
1135 cd $(SRC_DIST_TESTSUITE_DIR)/testsuite && lndir $(TOP)/testsuite
1136 $(call removeTrees,$(SRC_DIST_TESTSUITE_DIR)/testsuite/.git)
1137
1138 .PHONY: sdist
1139 sdist : sdist-ghc-prep sdist-testsuite-prep
1140 cd $(SRC_DIST_GHC_ROOT) && "$(TAR_CMD)" chf - $(SRC_DIST_BASE_NAME) 2> src_ghc_log | bzip2 > $(TOP)/$(SRC_DIST_GHC_TARBALL)
1141 cd $(SRC_DIST_TESTSUITE_ROOT) && "$(TAR_CMD)" chf - $(SRC_DIST_BASE_NAME) 2> src_ghc_log | bzip2 > $(TOP)/$(SRC_DIST_TESTSUITE_TARBALL)
1142
1143 sdist-manifest : $(SRC_DIST_GHC_TARBALL)
1144 tar tjf $(SRC_DIST_GHC_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
1145
1146 # Upload the distribution(s)
1147 # Retrying is to work around buggy firewalls that corrupt large file transfers
1148 # over SSH.
1149 ifneq "$(PublishLocation)" ""
1150 publish-sdist :
1151 $(call try10Times,$(PublishCp) $(SRC_DIST_GHC_TARBALL) $(PublishLocation)/dist)
1152 $(call try10Times,$(PublishCp) $(SRC_DIST_TESTSUITE_TARBALL) $(PublishLocation)/dist)
1153 endif
1154
1155 ifeq "$(BootingFromHc)" "YES"
1156 # In a normal build we use GHC to compile C files (see
1157 # rules/c-suffix-rules.mk), which passes a number of its own options
1158 # to the C compiler. So when bootstrapping we have to provide these
1159 # flags explicitly to C compilations.
1160 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
1161 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
1162 SRC_CC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
1163 endif
1164
1165 # -----------------------------------------------------------------------------
1166 # sdisting libraries
1167
1168 # Use manually, with e.g.:
1169 # make sdist_directory
1170
1171 sdist_%:
1172 inplace/bin/ghc-cabal sdist libraries/$* dist-install
1173
1174 # -----------------------------------------------------------------------------
1175 # Cleaning
1176
1177 .PHONY: clean
1178
1179 CLEAN_FILES += libraries/bootstrapping.conf
1180 CLEAN_FILES += libraries/integer-gmp/cbits/GmpDerivedConstants.h
1181 CLEAN_FILES += libraries/integer-gmp/cbits/mkGmpDerivedConstants
1182
1183 # These four are no longer generated, but we still clean them for a while
1184 # as they may still be in old GHC trees:
1185 CLEAN_FILES += includes/GHCConstants.h
1186 CLEAN_FILES += includes/DerivedConstants.h
1187 CLEAN_FILES += includes/ghcautoconf.h
1188 CLEAN_FILES += includes/ghcplatform.h
1189
1190 clean : clean_files clean_libraries
1191
1192 .PHONY: clean_files
1193 clean_files :
1194 $(call removeFiles,$(CLEAN_FILES))
1195
1196 .PHONY: clean_libraries
1197 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
1198 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(PACKAGES_STAGE0))
1199
1200 clean_libraries:
1201 $(call removeTrees,$(patsubst %, libraries/%/dist, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1202 $(call removeFiles,$(wildcard $(patsubst %, libraries/%/*.buildinfo, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))))
1203 $(call removeFiles,$(patsubst %, libraries/%/config.log, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1204 $(call removeFiles,$(patsubst %, libraries/%/config.status, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1205 $(call removeFiles,$(wildcard $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2))))
1206
1207 # We have to define a clean target for each library manually, because the
1208 # libraries/*/ghc.mk files are not included when we're cleaning.
1209 ifeq "$(CLEANING)" "YES"
1210 $(foreach lib,$(PACKAGES_STAGE0),\
1211 $(eval $(call clean-target,libraries/$(lib),dist-boot,libraries/$(lib)/dist-boot)))
1212 $(foreach lib,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),\
1213 $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
1214 endif
1215
1216 clean : clean_haddock_index
1217 .PHONY: clean_haddock_index
1218 clean_haddock_index:
1219 $(call removeTrees,libraries/dist-haddock)
1220
1221 clean : clean_bindistprep
1222 .PHONY: clean_bindistprep
1223 clean_bindistprep:
1224 $(call removeTrees,bindistprep/)
1225
1226 distclean : clean
1227 $(call removeFiles,config.cache config.status config.log mk/config.h mk/stamp-h)
1228 $(call removeFiles,mk/config.mk mk/are-validating.mk mk/project.mk)
1229 $(call removeFiles,mk/config.mk.old mk/project.mk.old)
1230 $(call removeFiles,settings docs/users_guide/ug-book.xml)
1231 $(call removeFiles,compiler/ghc.cabal compiler/ghc.cabal.old)
1232 $(call removeFiles,ghc/ghc-bin.cabal)
1233 $(call removeFiles,libraries/base/include/HsBaseConfig.h)
1234 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h)
1235 $(call removeFiles,libraries/process/include/HsProcessConfig.h)
1236 $(call removeFiles,libraries/unix/include/HsUnixConfig.h)
1237 $(call removeFiles,libraries/old-time/include/HsTimeConfig.h)
1238 $(call removeTrees,utils/ghc-pwd/dist-boot)
1239 $(call removeTrees,inplace)
1240 $(call removeTrees,$(patsubst %, libraries/%/autom4te.cache, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1241
1242 maintainer-clean : distclean
1243 $(call removeFiles,configure mk/config.h.in)
1244 $(call removeTrees,autom4te.cache $(wildcard libraries/*/autom4te.cache))
1245 $(call removeFiles,ghc.spec)
1246 $(call removeFiles,$(patsubst %, libraries/%/GNUmakefile, \
1247 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1248 $(call removeFiles,$(patsubst %, libraries/%/ghc.mk, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1249 $(call removeFiles,$(patsubst %, libraries/%/configure, \
1250 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1251 $(call removeFiles,libraries/base/include/HsBaseConfig.h.in)
1252 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h.in)
1253 $(call removeFiles,libraries/process/include/HsProcessConfig.h.in)
1254 $(call removeFiles,libraries/unix/include/HsUnixConfig.h.in)
1255 $(call removeFiles,libraries/old-time/include/HsTimeConfig.h.in)
1256
1257 .PHONY: all_libraries
1258
1259 .PHONY: bootstrapping-files
1260 bootstrapping-files: $(includes_H_CONFIG)
1261 bootstrapping-files: $(includes_DERIVEDCONSTANTS)
1262 bootstrapping-files: $(includes_GHCCONSTANTS)
1263 bootstrapping-files: $(libffi_HEADERS)
1264
1265 .DELETE_ON_ERROR:
1266
1267 # -----------------------------------------------------------------------------
1268 # Numbered phase targets
1269
1270 .PHONY: phase_0_builds
1271 phase_0_builds: $(utils/hsc2hs_dist_depfile_haskell)
1272 phase_0_builds: $(utils/hsc2hs_dist_depfile_c_asm)
1273 phase_0_builds: $(utils/genprimopcode_dist_depfile_haskell)
1274 phase_0_builds: $(utils/genprimopcode_dist_depfile_c_asm)
1275
1276 .PHONY: phase_1_builds
1277 phase_1_builds: $(PACKAGE_DATA_MKS)
1278