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