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