Keep the flag lists as IntSets rather than lists
[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_STAGE1 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 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 # Lax dependencies
289
290 ifeq "$(LAX_DEPENDENCIES)" "YES"
291 LAX_DEPS_FOLLOW = |
292 else
293 LAX_DEPS_FOLLOW =
294 endif
295
296 # This is a bit of a hack. When LAX_DEPS_FOLLOW is | some rules end up
297 # looking like
298 # target: a | b | c
299 # The first | signals the start of the order-only dependencies, but make
300 # treats the second | as a dependency. So we need to tell make how to
301 # build that dependency.
302
303 .PHONY: |
304 | :
305 @:
306
307 # -----------------------------------------------------------------------------
308 # Properties of packages
309
310 # These lists say "if this package is built, here's a property it has"
311 # They do not say "this package will be built"; see $(PACKAGES_xx) for that
312
313 # Packages that are built but not installed
314 PKGS_THAT_ARE_INTREE_ONLY := haskeline mtl terminfo utf8-string xhtml
315
316 PKGS_THAT_ARE_DPH := \
317 dph/dph-base \
318 dph/dph-prim-interface dph/dph-prim-seq dph/dph-prim-par \
319 dph/dph-lifted-base \
320 dph/dph-lifted-boxed dph/dph-lifted-copy dph/dph-lifted-vseg \
321 vector primitive random
322
323 # Packages that, if present, must be built by the stage2 compiler,
324 # because they use TH and/or annotations, or depend on other stage2
325 # packages:
326 PKGS_THAT_BUILD_WITH_STAGE2 := $(PKGS_THAT_ARE_DPH) haskell98 haskell2010
327
328 # Packages that we shouldn't build if we don't have TH (e.g. because
329 # we're building a profiled compiler):
330 PKGS_THAT_USE_TH := $(PKGS_THAT_ARE_DPH)
331
332 # Packages that are built by stage0, in addition to stage1. These
333 # packages are dependencies of GHC, that we do not assume the stage0
334 # compiler already has installed (or up-to-date enough).
335 #
336 # We assume that the stage0 compiler has a suitable bytestring package,
337 # so we don't have to include it below.
338 PKGS_THAT_BUILD_WITH_STAGE0 = Cabal/Cabal hpc extensible-exceptions binary bin-package-db hoopl
339
340 # $(EXTRA_PACKAGES) is another classification, of packages built but
341 # not installed
342 # It is set in rules/extra-package.mk,
343 # by $(call extra-packages) a little further down
344 # this ghc.mk
345
346
347
348 # ----------------------------------------------------------------------------
349 # Packages to build
350 # The lists of packages that we *actually* going to build in each stage:
351 #
352 # $(PACKAGES_STAGE0)
353 # $(PACKAGES_STAGE1)
354 # $(PACKAGES_STAGE2)
355 #
356 # These are automatically derived from
357 # (a) the set of packages in this source tree
358 # (b) the predicates above, e.g. $(PKGS_THAT_BUILD_WITH_STAGE2)
359 # (c) which platform we're on, and a few other things
360
361
362 # no processing to do on this one: it really is the list of packages
363 # to build with stage 0.
364 PACKAGES_STAGE0 = $(PKGS_THAT_BUILD_WITH_STAGE0)
365
366 define addPackageGeneral
367 # args: $1 = PACKAGES variable, $2 = package, $3 = condition
368 ifeq "$3" ""
369 $1 += $2
370 else
371 ifeq "$$(CLEANING)" "YES"
372 $1 += $2
373 else
374 ifeq $3
375 $1 += $2
376 endif
377 endif
378 endif
379 endef
380
381 define addPackage # args: $1 = package, $2 = condition
382 ifneq "$(filter $1,$(PKGS_THAT_USE_TH)) $(GhcProfiled)" "$1 YES"
383 ifeq "$(filter $1,$(PKGS_THAT_BUILD_WITH_STAGE2))" "$1"
384 $(call addPackageGeneral,PACKAGES_STAGE2,$1,$2)
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,bytestring))
402 $(eval $(call addPackage,deepseq))
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,extensible-exceptions))
414 $(eval $(call addPackage,haskell98))
415 $(eval $(call addPackage,haskell2010))
416 $(eval $(call addPackage,hpc))
417 $(eval $(call addPackage,pretty))
418 $(eval $(call addPackage,template-haskell))
419 $(eval $(call addPackage,Cabal/Cabal))
420 $(eval $(call addPackage,binary))
421 $(eval $(call addPackage,bin-package-db))
422 $(eval $(call addPackage,hoopl))
423 $(eval $(call addPackage,mtl))
424 $(eval $(call addPackage,utf8-string))
425 $(eval $(call addPackage,xhtml))
426 $(eval $(call addPackage,terminfo,($$(Windows),NO)))
427 $(eval $(call addPackage,haskeline))
428
429 $(eval $(call extra-packages))
430
431 # -------------------------------------------
432 # Dependencies between package-data.mk files
433
434 # We cannot run ghc-cabal to configure a package until we have
435 # configured and registered all of its dependencies. So the following
436 # hack forces all the configure steps to happen in exactly the following order:
437 #
438 # $(PACKAGES_STAGE1) ghc(stage2) $(PACKAGES_STAGE2)
439 #
440 # Ideally we should use the correct dependencies here to allow more
441 # parallelism, but we don't know the dependencies until we've
442 # generated the pacakge-data.mk files.
443 define fixed_pkg_dep
444 libraries/$1/$2/package-data.mk : $$(GHC_PKG_INPLACE) $$(fixed_pkg_prev)
445 fixed_pkg_prev:=libraries/$1/$2/package-data.mk
446 endef
447
448 ifneq "$(BINDIST)" "YES"
449 fixed_pkg_prev=
450 $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
451
452 # the GHC package doesn't live in libraries/, so we add its dependency manually:
453 compiler/stage2/package-data.mk: $(fixed_pkg_prev)
454 fixed_pkg_prev:=compiler/stage2/package-data.mk
455
456 # and continue with PACKAGES_STAGE2, which depend on GHC:
457 $(foreach pkg,$(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
458
459 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
460 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
461 # haddock depends on ghc and some libraries, but depending on GHC's
462 # package-data.mk is sufficient, as that in turn depends on all the
463 # libraries
464 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
465 utils/ghc-pwd/dist-install/package-data.mk: compiler/stage2/package-data.mk
466 utils/ghc-cabal/dist-install/package-data.mk: compiler/stage2/package-data.mk
467
468 utils/ghc-pkg/dist-install/package-data.mk: compiler/stage2/package-data.mk
469 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
470 utils/compare_sizes/dist-install/package-data.mk: compiler/stage2/package-data.mk
471 utils/runghc/dist-install/package-data.mk: compiler/stage2/package-data.mk
472
473 # add the final package.conf dependency: ghc-prim depends on RTS
474 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
475 endif
476
477 # --------------------------------
478 # Misc package-related settings
479
480 BOOT_PKG_CONSTRAINTS := \
481 $(foreach d,$(PACKAGES_STAGE0),\
482 $(foreach p,$(basename $(notdir $(wildcard libraries/$d/*.cabal))),\
483 --constraint "$p == $(shell grep -i "^Version:" libraries/$d/$p.cabal | sed "s/[^0-9.]//g")"))
484
485 # The actual .a and .so/.dll files: needed for dependencies.
486 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_v_LIB))
487 ifeq "$(BuildSharedLibs)" "YES"
488 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_dyn_LIB))
489 endif
490 BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB))
491
492 # ----------------------------------------
493 # Special magic for the ghc-prim package
494
495 # We want the ghc-prim package to include the GHC.Prim module when it
496 # is registered, but not when it is built, because GHC.Prim is not a
497 # real source module, it is built-in to GHC. The old build system did
498 # this using Setup.hs, but we can't do that here, so we have a flag to
499 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
500 # remains compatible with the old build system for the time being).
501 # GHC.Prim module in the ghc-prim package with a flag:
502 #
503 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
504
505 # And then we strip it out again before building the package:
506 define libraries/ghc-prim_PACKAGE_MAGIC
507 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
508 endef
509
510 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
511
512 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT) | $$(dir $$@)/.
513 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
514
515 # Required so that Haddock documents the primops.
516 libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
517
518 # ----------------------------------------
519 # Special magic for the integer package
520
521 ifneq "$(CLEANING)" "YES"
522 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
523 libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
524 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
525 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
526 else
527 $(error Unknown integer library: $(INTEGER_LIBRARY))
528 endif
529 endif
530
531 # ----------------------------------------------
532 # Checking packages with 'cabal check'
533
534 ifeq "$(phase)" "final"
535 ifeq "$(CHECK_PACKAGES)" "YES"
536 all: check_packages
537 endif
538 endif
539
540 # These packages don't pass the Cabal checks because hs-source-dirs
541 # points outside the source directory. This isn't a real problem in
542 # these cases, so we just skip checking them.
543 # NB. these must come before we include the ghc.mk files below, because
544 # they disable the relevant rules.
545 # In compiler's case, include-dirs points outside of the source tree
546 CHECKED_compiler = YES
547
548 # -----------------------------------------------------------------------------
549 # Include build instructions from all subdirs
550
551 ifneq "$(BINDIST)" "YES"
552 BUILD_DIRS += \
553 $(GHC_MKDIRHIER_DIR)
554 endif
555
556 BUILD_DIRS += \
557 docs/users_guide \
558 docs/ext-core \
559 docs/man \
560 $(GHC_UNLIT_DIR) \
561 $(GHC_HP2PS_DIR)
562
563 ifneq "$(GhcUnregisterised)" "YES"
564 BUILD_DIRS += \
565 $(GHC_SPLIT_DIR)
566 endif
567
568 ifneq "$(BINDIST)" "YES"
569 BUILD_DIRS += \
570 $(GHC_GENPRIMOP_DIR)
571 endif
572
573 BUILD_DIRS += \
574 driver \
575 driver/ghci \
576 driver/ghc \
577 driver/haddock \
578 libffi \
579 includes \
580 rts
581
582 ifneq "$(BINDIST)" "YES"
583 BUILD_DIRS += \
584 bindisttest \
585 $(GHC_GENAPPLY_DIR)
586 endif
587
588 ifneq "$(CLEANING)" "YES"
589 BUILD_DIRS += \
590 $(patsubst %, libraries/%, $(PACKAGES_STAGE1))
591 endif
592
593 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
594 BUILD_DIRS += libraries/integer-gmp/gmp
595 else ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
596 BUILD_DIRS += libraries/integer-gmp/gmp
597 endif
598
599 BUILD_DIRS += \
600 utils/haddock \
601 utils/haddock/doc \
602 compiler \
603 $(GHC_HSC2HS_DIR) \
604 $(GHC_PKG_DIR) \
605 utils/testremove \
606 utils/ghctags \
607 utils/ghc-pwd \
608 $(GHC_CABAL_DIR) \
609 utils/hpc \
610 utils/runghc \
611 ghc
612 ifeq "$(Windows)" "YES"
613 BUILD_DIRS += \
614 $(GHC_TOUCHY_DIR)
615 endif
616
617 ifneq "$(BINDIST)" "YES"
618 BUILD_DIRS += \
619 utils/mkUserGuidePart
620 endif
621
622 BUILD_DIRS += utils/count_lines
623 BUILD_DIRS += utils/compare_sizes
624
625 ifneq "$(CLEANING)" "YES"
626 # After compiler/, because these packages depend on it
627 BUILD_DIRS += \
628 $(patsubst %, libraries/%, $(PACKAGES_STAGE2))
629 endif
630
631 # ----------------------------------------------
632 # Actually include all the sub-ghc.mk's
633
634 # BUILD_DIRS_EXTRA needs to come after BUILD_DIRS, because stuff in
635 # libraries/dph/ghc.mk refers to stuff defined earlier, in particular
636 # things like $(libraries/dph/dph-base_dist-install_GHCI_LIB)
637 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS) $(BUILD_DIRS_EXTRA))
638
639 # A useful pseudo-target (must be after the include above, because it needs
640 # the value of things like $(libraries/base_dist-install_v_LIB).
641 .PHONY: stage1_libs
642 stage1_libs : $(ALL_STAGE1_LIBS)
643
644 # ----------------------------------------------
645 # Per-package compiler flags
646 #
647 # If you want to add per-package compiler flags, this
648 # is the place to do it. Do it like this for package <pkg>
649 #
650 # libraries/<pkg>_dist-boot_HC_OPTS += -Wwarn
651 # libraries/<pkg>_dist-install_HC_OPTS += -Wwarn
652
653 # Add $(GhcLibHcOpts) to all package builds
654 $(foreach pkg,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
655
656 # Add $(GhcBootLibHcOpts) to all stage0 package builds
657 $(foreach pkg,$(PACKAGES_STAGE0),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
658
659 # -----------------------------------------------
660 # Haddock-related bits
661
662 # Don't run Haddock for the package that will not be installed
663 $(foreach p,$(PKGS_THAT_ARE_INTREE_ONLY),$(eval libraries/$p_dist-install_DO_HADDOCK = NO))
664 # We don't haddock the bootstrapping libraries
665 $(foreach p,$(PACKAGES_STAGE0),$(eval libraries/$p_dist-boot_DO_HADDOCK = NO))
666
667 # Build the Haddock contents and index
668 ifeq "$(HADDOCK_DOCS)" "YES"
669 libraries/index.html: inplace/bin/haddock$(exeext) $(ALL_HADDOCK_FILES)
670 cd libraries && sh gen_contents_index --inplace
671 ifeq "$(phase)" "final"
672 $(eval $(call all-target,library_doc_index,libraries/index.html))
673 endif
674 INSTALL_LIBRARY_DOCS += libraries/*.html libraries/*.gif libraries/*.css libraries/*.js
675 CLEAN_FILES += $(wildcard libraries/doc-index* \
676 libraries/haddock*.css \
677 libraries/haddock*.js \
678 libraries/index*.html \
679 libraries/*.gif)
680 endif
681
682 # -----------------------------------------------------------------------------
683 # Bootstrapping libraries
684
685 # We need to build a few libraries with the installed GHC, since GHC itself
686 # and some of the tools depend on them:
687
688 ifneq "$(BINDIST)" "YES"
689
690 ifneq "$(BOOTSTRAPPING_CONF)" ""
691 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
692 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
693 endif
694 endif
695
696 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
697
698 # register the boot packages in strict sequence, because running
699 # multiple ghc-pkgs in parallel doesn't work (registrations may get
700 # lost).
701 fixed_pkg_prev=
702 $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
703
704 compiler/stage1/package-data.mk : $(fixed_pkg_prev)
705 endif
706
707 ifneq "$(BINDIST)" "YES"
708 # Make sure we have all the GHCi libs by the time we've built
709 # ghc-stage2. DPH includes a bit of Template Haskell which needs the
710 # GHCI libs, and we don't have a better way to express that dependency.
711 #
712 GHCI_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_GHCI_LIB)) \
713 $(compiler_stage2_GHCI_LIB)
714
715 ifeq "$(UseArchivesForGhci)" "NO"
716 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(GHCI_LIBS)
717 endif
718
719 ifeq "$(UseArchivesForGhci)" "YES"
720 GHCI_lib_way = v
721 else
722 GHCI_lib_way = GHCI
723 endif
724
725 # Deps for TH uses in libraries
726 $(foreach way, $(GhcLibWays),$(eval \
727 libraries/vector/dist-install/build/Data/Vector/Fusion/Stream/Monadic.$($(way)_osuf): \
728 $(libraries/primitive_dist-install_$(GHCI_lib_way)_LIB) \
729 ))
730 endif
731
732 # -----------------------------------------------------------------------------
733 # Creating a local mingw copy on Windows
734
735 ifeq "$(Windows)" "YES"
736
737 install : install_mingw
738 .PHONY: install_mingw
739 install_mingw : $(INPLACE_MINGW)
740 "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
741
742 install : install_perl
743 .PHONY: install_perl
744 install_perl : $(INPLACE_PERL)
745 "$(CP)" -Rp $(INPLACE_PERL) $(prefix)
746
747 endif # Windows
748
749 ifneq "$(BINDIST)" "YES"
750 $(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \
751 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
752 endif # BINDIST
753
754 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
755 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) \
756 | $$(dir $$@)/.
757 "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
758
759 .PHONY: tags
760 tags: tags_compiler
761
762 .PHONY: TAGS
763 TAGS: TAGS_compiler
764
765 # -----------------------------------------------------------------------------
766 # Installation
767
768 install: install_libs install_packages install_libexecs install_headers \
769 install_libexec_scripts install_bins install_topdirs
770 ifeq "$(HADDOCK_DOCS)" "YES"
771 install: install_docs
772 endif
773
774 install_bins: $(INSTALL_BINS)
775 $(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
776 for i in $(INSTALL_BINS); do \
777 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(bindir)") ; \
778 done
779
780 install_libs: $(INSTALL_LIBS)
781 $(call INSTALL_DIR,"$(DESTDIR)$(ghclibdir)")
782 for i in $(INSTALL_LIBS); do \
783 case $$i in \
784 *.a) \
785 $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)"); \
786 $(RANLIB) $(DESTDIR)$(ghclibdir)/`basename $$i` ;; \
787 *.dll) \
788 $(call INSTALL_DATA,-s $(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)") ;; \
789 *.so) \
790 $(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)") ;; \
791 *.dylib) \
792 $(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)");; \
793 *) \
794 $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)"); \
795 esac; \
796 done
797
798 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
799 ifeq "$(INSTALL_LIBEXEC_SCRIPTS)" ""
800 @:
801 else
802 $(call INSTALL_DIR,"$(DESTDIR)$(ghclibexecdir)")
803 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
804 $(call INSTALL_SCRIPT,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibexecdir)"); \
805 done
806 endif
807
808 install_libexecs: $(INSTALL_LIBEXECS)
809 ifeq "$(INSTALL_LIBEXECS)" ""
810 @:
811 else
812 $(call INSTALL_DIR,"$(DESTDIR)$(ghclibexecdir)")
813 for i in $(INSTALL_LIBEXECS); do \
814 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(ghclibexecdir)"); \
815 done
816 # We rename ghc-stage2, so that the right program name is used in error
817 # messages etc.
818 "$(MV)" "$(DESTDIR)$(ghclibexecdir)/ghc-stage2" "$(DESTDIR)$(ghclibexecdir)/ghc"
819 endif
820
821 install_topdirs: $(INSTALL_TOPDIRS)
822 $(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
823 for i in $(INSTALL_TOPDIRS); do \
824 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(topdir)"); \
825 done
826
827 install_headers: $(INSTALL_HEADERS)
828 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)")
829 for i in $(INSTALL_HEADERS); do \
830 $(call INSTALL_HEADER,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghcheaderdir)"); \
831 done
832
833 install_docs: $(INSTALL_DOCS)
834 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)")
835 ifneq "$(INSTALL_DOCS)" ""
836 for i in $(INSTALL_DOCS); do \
837 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(docdir)"); \
838 done
839 endif
840 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)/html")
841 $(call INSTALL_DOC,$(INSTALL_OPTS),docs/index.html,"$(DESTDIR)$(docdir)/html")
842 ifneq "$(INSTALL_LIBRARY_DOCS)" ""
843 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)/html/libraries")
844 for i in $(INSTALL_LIBRARY_DOCS); do \
845 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(docdir)/html/libraries/"); \
846 done
847 $(call INSTALL_DATA,$(INSTALL_OPTS),libraries/prologue.txt,"$(DESTDIR)$(docdir)/html/libraries/")
848 $(call INSTALL_SCRIPT,$(INSTALL_OPTS),libraries/gen_contents_index,"$(DESTDIR)$(docdir)/html/libraries/")
849 endif
850 ifneq "$(INSTALL_HTML_DOC_DIRS)" ""
851 for i in $(INSTALL_HTML_DOC_DIRS); do \
852 $(call INSTALL_DIR,"$(DESTDIR)$(docdir)/html/`basename $$i`"); \
853 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i/*,"$(DESTDIR)$(docdir)/html/`basename $$i`"); \
854 done
855 endif
856
857 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
858
859 # Install packages in the right order, so that ghc-pkg doesn't complain.
860 # Also, install ghc-pkg first.
861 ifeq "$(Windows)" "NO"
862 INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/ghc
863 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/ghc-pkg
864 else
865 INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
866 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
867 endif
868
869 INSTALLED_PKG_DIRS := $(addprefix libraries/,$(PACKAGES_STAGE1)) \
870 compiler \
871 $(addprefix libraries/,$(PACKAGES_STAGE2))
872 ifeq "$(InstallExtraPackages)" "NO"
873 INSTALLED_PKG_DIRS := $(filter-out $(addprefix libraries/,$(EXTRA_PACKAGES)),\
874 $(INSTALLED_PKG_DIRS))
875 endif
876 INSTALLED_PKG_DIRS := $(filter-out $(addprefix libraries/,$(PKGS_THAT_ARE_INTREE_ONLY)),\
877 $(INSTALLED_PKG_DIRS))
878
879 # Set the INSTALL_DISTDIR_p for each package; compiler is special
880 $(foreach p,$(filter-out compiler,$(INSTALLED_PKG_DIRS)),\
881 $(eval INSTALL_DISTDIR_$p = dist-install))
882 INSTALL_DISTDIR_compiler = stage2
883
884 # Now we can do the installation
885 install_packages: install_libexecs
886 install_packages: rts/package.conf.install
887 $(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
888 $(call removeTrees,"$(INSTALLED_PACKAGE_CONF)")
889 $(call INSTALL_DIR,"$(INSTALLED_PACKAGE_CONF)")
890 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
891 $(foreach p, $(INSTALLED_PKG_DIRS), \
892 $(call make-command, \
893 "$(GHC_CABAL_INPLACE)" install \
894 "$(INSTALLED_GHC_REAL)" \
895 "$(INSTALLED_GHC_PKG_REAL)" \
896 "$(STRIP_CMD)" \
897 "$(DESTDIR)$(topdir)" \
898 $p $(INSTALL_DISTDIR_$p) \
899 '$(DESTDIR)' \
900 '$(prefix)' \
901 '$(ghclibdir)' \
902 '$(docdir)/html/libraries' \
903 $(RelocatableBuild)))
904 # when we install the packages above, ghc-pkg obeys umask when creating
905 # the package.conf files, but for everything else we specify the
906 # permissions. We therefore now fix the permissions of package.cache.
907 # This means "sudo make install" does the right thing even if it runs
908 # with an 077 umask.
909 for f in '$(INSTALLED_PACKAGE_CONF)'/*; do $(CREATE_DATA) "$$f"; done
910
911 # -----------------------------------------------------------------------------
912 # Binary distributions
913
914 ifneq "$(CLEANING)" "YES"
915 # This rule seems to hold some files open on Windows which prevents
916 # cleaning, perhaps due to the $(wildcard).
917
918 $(eval $(call bindist,.,\
919 LICENSE \
920 README \
921 INSTALL \
922 configure config.sub config.guess install-sh \
923 settings.in \
924 packages \
925 Makefile \
926 mk/config.mk.in \
927 $(INPLACE_BIN)/mkdirhier \
928 utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
929 utils/ghc-pwd/dist-install/build/tmp/ghc-pwd \
930 $(BINDIST_WRAPPERS) \
931 $(BINDIST_PERL_SOURCES) \
932 $(BINDIST_LIBS) \
933 $(BINDIST_HI) \
934 $(BINDIST_EXTRAS) \
935 $(includes_H_FILES) \
936 $(INSTALL_HEADERS) \
937 $(INSTALL_LIBEXECS) \
938 $(INSTALL_LIBEXEC_SCRIPTS) \
939 $(INSTALL_TOPDIRS) \
940 $(INSTALL_BINS) \
941 $(INSTALL_MANPAGES) \
942 $(INSTALL_DOCS) \
943 $(INSTALL_LIBRARY_DOCS) \
944 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
945 docs/index.html \
946 compiler/stage2/doc \
947 $(wildcard libraries/*/dist-install/doc/) \
948 $(wildcard libraries/*/*/dist-install/doc/) \
949 $(filter-out settings,$(INSTALL_LIBS)) \
950 $(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
951 mk/project.mk \
952 mk/install.mk.in \
953 bindist.mk \
954 libraries/gen_contents_index \
955 libraries/prologue.txt \
956 $(wildcard libraries/dph/LICENSE \
957 libraries/dph/ghc-packages \
958 libraries/dph/ghc-packages2 \
959 libraries/dph/ghc-stage2-package) \
960 ))
961 endif
962 # mk/project.mk gets an absolute path, so we manually include it in
963 # the bindist with a relative path
964
965 BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
966
967 unix-binary-dist-prep:
968 $(call removeTrees,bindistprep/)
969 "$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
970 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
971 echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
972 echo "LATEX_DOCS = $(LATEX_DOCS)" >> $(BIN_DIST_MK)
973 echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
974 echo "BUILD_DOCBOOK_PS = $(BUILD_DOCBOOK_PS)" >> $(BIN_DIST_MK)
975 echo "BUILD_DOCBOOK_PDF = $(BUILD_DOCBOOK_PDF)" >> $(BIN_DIST_MK)
976 echo "BUILD_MAN = $(BUILD_MAN)" >> $(BIN_DIST_MK)
977 echo "GHC_CABAL_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal" >> $(BIN_DIST_MK)
978 cd $(BIN_DIST_PREP_DIR) && autoreconf
979 $(call removeFiles,$(BIN_DIST_PREP_TAR))
980 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
981 # tree then we want to include the real file, not a symlink to it
982 cd bindistprep && "$(TAR_CMD)" hcf - -T ../$(BIN_DIST_LIST) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
983
984 windows-binary-dist-prep:
985 $(call removeTrees,bindistprep/)
986 $(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
987 cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
988
989 windows-installer:
990 ifeq "$(ISCC_CMD)" ""
991 @echo No ISCC_CMD, so not making installer
992 else
993 "$(ISCC_CMD)" /O. /Fbindistprep/$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
994 endif
995
996 # tryTimes tries to run its third argument multiple times, until it
997 # succeeds. Don't call it directly; call try10Times instead.
998 # The first and second argument to tryTimes are lists of values.
999 # The length of the first argument is the number of times we have
1000 # already tried. The length of the second argument is the number more
1001 # times we will try.
1002 tryTimes = $(if $2, \
1003 { echo 'Try $(words x $1): $3' ; $3 ; } || \
1004 $(call tryTimes,x $1,$(wordlist 2,$(words $2),$2),$3), \
1005 )
1006
1007 # Try to run the argument 10 times. If all 10 fail, fail.
1008 try10Times = $(call tryTimes,,x x x x x x x x x x,$1) { echo Failed; false; }
1009
1010 .PHONY: publish-binary-dist
1011 publish-binary-dist:
1012 $(call try10Times,$(PublishCp) $(BIN_DIST_TAR_BZ2) $(PublishLocation)/dist)
1013 ifeq "$(mingw32_TARGET_OS)" "1"
1014 $(call try10Times,$(PublishCp) $(WINDOWS_INSTALLER) $(PublishLocation)/dist)
1015 endif
1016
1017 ifeq "$(mingw32_TARGET_OS)" "1"
1018 DOCDIR_TO_PUBLISH = bindisttest/"install dir"/doc
1019 else
1020 DOCDIR_TO_PUBLISH = bindisttest/"install dir"/share/doc/ghc
1021 endif
1022
1023 .PHONY: publish-docs
1024 publish-docs:
1025 $(call try10Times,$(PublishCp) -r $(DOCDIR_TO_PUBLISH)/* $(PublishLocation)/docs)
1026
1027 # -----------------------------------------------------------------------------
1028 # Source distributions
1029
1030 # Do it like this:
1031 #
1032 # $ make
1033 # $ make sdist
1034 #
1035
1036 # A source dist is built from a complete build tree, because we
1037 # require some extra files not contained in a darcs checkout: the
1038 # output from Happy and Alex, for example.
1039 #
1040 # The steps performed by 'make dist' are as follows:
1041 # - create a complete link-tree of the current build tree in /tmp
1042 # - run 'make distclean' on that tree
1043 # - remove a bunch of other files that we know shouldn't be in the dist
1044 # - tar up first the extralibs package, then the main source package
1045
1046 #
1047 # Directory in which we're going to build the src dist
1048 #
1049 SRC_DIST_NAME=ghc-$(ProjectVersion)
1050 SRC_DIST_DIR=$(TOP)/$(SRC_DIST_NAME)
1051
1052 #
1053 # Files to include in source distributions
1054 #
1055 SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts compiler ghc driver libraries ghc-tarballs
1056 SRC_DIST_FILES += \
1057 configure.ac config.guess config.sub configure \
1058 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
1059 ghc.spec.in ghc.spec settings.in VERSION \
1060 boot boot-pkgs packages ghc.mk
1061
1062 SRC_DIST_TARBALL = $(SRC_DIST_NAME)-src.tar.bz2
1063
1064 VERSION :
1065 echo $(ProjectVersion) >VERSION
1066
1067 sdist : VERSION
1068
1069 # Use:
1070 # $(call sdist_file,compiler,stage2,cmm,Foo/Bar,CmmLex,x)
1071 # to copy the generated file that replaces compiler/cmm/Foo/Bar/CmmLex.x, where
1072 # "stage2" is the dist dir.
1073 define sdist_file
1074 "$(CP)" $1/$2/build/$4/$5.hs $(SRC_DIST_DIR)/$1/$3/$4
1075 mv $(SRC_DIST_DIR)/$1/$3/$4/$5.$6 $(SRC_DIST_DIR)/$1/$3/$4/$5.$6.source
1076 endef
1077
1078 .PHONY: sdist-prep
1079 sdist-prep :
1080 $(call removeTrees,$(SRC_DIST_DIR))
1081 $(call removeFiles,$(SRC_DIST_TARBALL))
1082 mkdir $(SRC_DIST_DIR)
1083 cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_DIRS); do mkdir $$i; ( cd $$i && lndir $(TOP)/$$i ); done
1084 cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done
1085 cd $(SRC_DIST_DIR) && $(MAKE) distclean
1086 rm -rf $(SRC_DIST_DIR)/libraries/tarballs/
1087 rm -rf $(SRC_DIST_DIR)/libraries/stamp/
1088 $(call sdist_file,compiler,stage2,cmm,,CmmLex,x)
1089 $(call sdist_file,compiler,stage2,cmm,,CmmParse,y)
1090 $(call sdist_file,compiler,stage2,parser,,Lexer,x)
1091 $(call sdist_file,compiler,stage2,parser,,Parser,y.pp)
1092 $(call sdist_file,compiler,stage2,parser,,ParserCore,y)
1093 $(call sdist_file,utils/hpc,dist-install,,,HpcParser,y)
1094 $(call sdist_file,utils/genprimopcode,dist,,,Lexer,x)
1095 $(call sdist_file,utils/genprimopcode,dist,,,Parser,y)
1096 $(call sdist_file,utils/haddock,dist,src,Haddock,Lex,x)
1097 $(call sdist_file,utils/haddock,dist,src,Haddock,Parse,y)
1098 cd $(SRC_DIST_DIR) && $(call removeTrees,compiler/stage[123] mk/build.mk)
1099 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)
1100
1101 .PHONY: sdist
1102 sdist : sdist-prep
1103 "$(TAR_CMD)" chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
1104
1105 sdist-manifest : $(SRC_DIST_TARBALL)
1106 tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
1107
1108 # Upload the distribution(s)
1109 # Retrying is to work around buggy firewalls that corrupt large file transfers
1110 # over SSH.
1111 ifneq "$(PublishLocation)" ""
1112 publish-sdist :
1113 $(call try10Times,$(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist)
1114 endif
1115
1116 ifeq "$(BootingFromHc)" "YES"
1117 # In a normal build we use GHC to compile C files (see
1118 # rules/c-suffix-rules.mk), which passes a number of its own options
1119 # to the C compiler. So when bootstrapping we have to provide these
1120 # flags explicitly to C compilations.
1121 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
1122 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
1123 SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR)
1124 endif
1125
1126 # -----------------------------------------------------------------------------
1127 # sdisting libraries
1128
1129 # Use manually, with e.g.:
1130 # make sdist_directory
1131
1132 sdist_%:
1133 inplace/bin/ghc-cabal sdist libraries/$* dist-install
1134
1135 # -----------------------------------------------------------------------------
1136 # Cleaning
1137
1138 .PHONY: clean
1139
1140 CLEAN_FILES += libraries/bootstrapping.conf
1141 CLEAN_FILES += libraries/integer-gmp/cbits/GmpDerivedConstants.h
1142 CLEAN_FILES += libraries/integer-gmp/cbits/mkGmpDerivedConstants
1143
1144 clean : clean_files clean_libraries
1145
1146 .PHONY: clean_files
1147 clean_files :
1148 $(call removeFiles,$(CLEAN_FILES))
1149
1150 .PHONY: clean_libraries
1151 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2))
1152 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(PACKAGES_STAGE0))
1153
1154 clean_libraries:
1155 $(call removeTrees,$(patsubst %, libraries/%/dist, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1156 $(call removeFiles,$(patsubst %, $(wildcard libraries/%/*.buildinfo), $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1157
1158 # We have to define a clean target for each library manually, because the
1159 # libraries/*/ghc.mk files are not included when we're cleaning.
1160 ifeq "$(CLEANING)" "YES"
1161 $(foreach lib,$(PACKAGES_STAGE0),\
1162 $(eval $(call clean-target,libraries/$(lib),dist-boot,libraries/$(lib)/dist-boot)))
1163 $(foreach lib,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),\
1164 $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
1165 endif
1166
1167 clean : clean_bindistprep
1168 .PHONY: clean_bindistprep
1169 clean_bindistprep:
1170 $(call removeTrees,bindistprep/)
1171
1172 distclean : clean
1173 $(call removeFiles,config.cache config.status config.log mk/config.h mk/stamp-h)
1174 $(call removeFiles,mk/config.mk mk/are-validating.mk mk/project.mk)
1175 $(call removeFiles,mk/config.mk.old mk/project.mk.old)
1176 $(call removeFiles,settings docs/users_guide/ug-book.xml)
1177 $(call removeFiles,compiler/ghc.cabal compiler/ghc.cabal.old)
1178 $(call removeFiles,ghc/ghc-bin.cabal)
1179 $(call removeFiles,libraries/base/include/HsBaseConfig.h)
1180 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h)
1181 $(call removeFiles,libraries/process/include/HsProcessConfig.h)
1182 $(call removeFiles,libraries/unix/include/HsUnixConfig.h)
1183 $(call removeFiles,libraries/old-time/include/HsTimeConfig.h)
1184 $(call removeTrees,utils/ghc-pwd/dist)
1185 $(call removeTrees,inplace)
1186
1187 $(call removeFiles,$(patsubst %, libraries/%/config.log, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1188 $(call removeFiles,$(patsubst %, libraries/%/config.status, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1189 $(call removeFiles,$(patsubst %, $(wildcard,libraries/%/include/Hs*Config.h), $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1190 $(call removeTrees,$(patsubst %, libraries/%/autom4te.cache, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1191
1192 maintainer-clean : distclean
1193 $(call removeFiles,configure mk/config.h.in)
1194 $(call removeTrees,autom4te.cache $(wildcard libraries/*/autom4te.cache))
1195 $(call removeFiles,ghc.spec)
1196 $(call removeFiles,$(patsubst %, libraries/%/GNUmakefile, \
1197 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1198 $(call removeFiles,$(patsubst %, libraries/%/ghc.mk, $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1199 $(call removeFiles,$(patsubst %, libraries/%/configure, \
1200 $(PACKAGES_STAGE1) $(PACKAGES_STAGE2)))
1201 $(call removeFiles,libraries/base/include/HsBaseConfig.h.in)
1202 $(call removeFiles,libraries/directory/include/HsDirectoryConfig.h.in)
1203 $(call removeFiles,libraries/process/include/HsProcessConfig.h.in)
1204 $(call removeFiles,libraries/unix/include/HsUnixConfig.h.in)
1205 $(call removeFiles,libraries/old-time/include/HsTimeConfig.h.in)
1206
1207 .PHONY: all_libraries
1208
1209 .PHONY: bootstrapping-files
1210 bootstrapping-files: includes/ghcautoconf.h
1211 bootstrapping-files: includes/DerivedConstants.h
1212 bootstrapping-files: includes/GHCConstants.h
1213
1214 .DELETE_ON_ERROR:
1215
1216 # -----------------------------------------------------------------------------
1217 # Numbered phase targets
1218
1219 .PHONY: phase_0_builds
1220 phase_0_builds: $(utils/hsc2hs_dist_depfile_haskell)
1221 phase_0_builds: $(utils/hsc2hs_dist_depfile_c_asm)
1222 phase_0_builds: $(utils/genprimopcode_dist_depfile_haskell)
1223 phase_0_builds: $(utils/genprimopcode_dist_depfile_c_asm)
1224
1225 .PHONY: phase_1_builds
1226 phase_1_builds: $(PACKAGE_DATA_MKS)
1227