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