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