move way-related stuff into a separate file
[ghc-hetmet.git] / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # ToDo List.
14 #
15 #   * finish installation
16 #     * Windows: should we have ghc-pkg-<version>?
17 #     * should we be stripping things?
18 #     * install libgmp.a, gmp.h
19 #   * need to fix Cabal for new Windows layout, see
20 #     Distribution/Simple/GHC.configureToolchain.
21 #   * remove old Makefiles, add new stubs for building in subdirs
22 #     * docs/Makefile
23 #     * docs/docbook-cheat-sheet/Makefile
24 #     * docs/ext-core/Makefile
25 #     * docs/man/Makefile
26 #     * docs/storage-mgmt/Makefile
27 #     * docs/vh/Makefile
28 #     * rts/dotnet/Makefile
29 #     * utils/Makefile
30 #   * optionally install stage3?
31 #   * add Makefiles for the rest of the utils/ programs that aren't built
32 #     by default (need to exclude them from 'make all' too)
33 #
34 # Tickets we can now close, or fix and close:
35 #
36 #   * 1693 make distclean
37
38 # Possible cleanups:
39 #
40 #   * per-source-file dependencies instead of one .depend file?
41 #   * eliminate undefined variables, and use --warn-undefined-variables?
42 #   * perhaps we should make all the output dirs in the .depend rule, to
43 #     avoid all these mkdirhier calls?
44 #   * put outputs from different ways in different subdirs of distdir/build,
45 #     then we don't have to use -osuf/-hisuf.  We would have to install
46 #     them in different places too, so we'd need ghc-pkg support for packages
47 #     of different ways.
48 #   * make PACKAGES generated by configure or sh boot?
49 #   * we should use a directory of package.conf files rather than a single
50 #     file for the inplace package database, so that we can express
51 #     dependencies more accurately.  Otherwise it's possible to get into
52 #     a state where the package database is out of date, and the build
53 #     system doesn't know.
54
55 # Approximate build order.
56 #
57 # The actual build order is defined by dependencies, and the phase
58 # ordering used to ensure correct ordering of makefile-generation; see
59 #    http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
60 #
61 #     * With bootstrapping compiler:
62 #           o Build utils/ghc-cabal
63 #           o Build utils/ghc-pkg
64 #           o Build utils/hsc2hs
65 #     * For each package:
66 #           o configure, generate package-data.mk and inplace-pkg-info
67 #           o register each package into inplace/lib/package.conf
68 #     * build libffi
69 #     * With bootstrapping compiler:
70 #           o Build libraries/{filepath,hpc,extensible-exceptions,Cabal}
71 #           o Build compiler (stage 1)
72 #     * With stage 1:
73 #           o Build libraries/*
74 #           o Build rts
75 #           o Build utils/* (except haddock)
76 #           o Build compiler (stage 2)
77 #     * With stage 2:
78 #           o Build utils/haddock
79 #           o Build compiler (stage 3) (optional)
80 #     * With haddock:
81 #           o libraries/*
82 #           o compiler
83
84 .PHONY: default all haddock
85
86 default : all
87
88 # Just bring makefiles up to date:
89 .PHONY: just-makefiles
90 just-makefiles:
91         @:
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 # to see the effective value used for a Makefile variable, do
109 #  make show VALUE=MY_VALUE
110 #
111
112 show:
113         @echo '$(VALUE)="$($(VALUE))"'
114
115 # -----------------------------------------------------------------------------
116 # Include subsidiary build-system bits
117
118 include mk/tree.mk
119
120 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
121 include mk/config.mk
122 ifeq "$(ProjectVersion)" ""
123 $(error Please run ./configure first)
124 endif
125 endif
126
127 include mk/ways.mk
128
129 # (Optional) build-specific configuration
130 include mk/custom-settings.mk
131
132 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
133 ifeq "$(GhcLibWays)" ""
134 $(error $$(GhcLibWays) is empty, it must contain at least one way)
135 endif
136 endif
137
138 # -----------------------------------------------------------------------------
139 # Macros for standard targets
140
141 include rules/all-target.mk
142 include rules/clean-target.mk
143
144 # -----------------------------------------------------------------------------
145 # The inplace tree
146
147 $(eval $(call clean-target,inplace,,inplace))
148
149 # -----------------------------------------------------------------------------
150 # Whether to build dependencies or not
151
152 # When we're just doing 'make clean' or 'make show', then we don't need
153 # to build dependencies.
154
155 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
156 NO_INCLUDE_DEPS = YES
157 NO_INCLUDE_PKGDATA = YES
158 endif
159 ifneq "$(findstring bootstrapping-files,$(MAKECMDGOALS))" ""
160 NO_INCLUDE_DEPS = YES
161 NO_INCLUDE_PKGDATA = YES
162 endif
163 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
164 NO_INCLUDE_DEPS = YES
165 # We want package-data.mk for show
166 endif
167
168 # We don't haddock base3-compat, as it has the same package name as base
169 libraries/base3-compat_dist-install_DO_HADDOCK = NO
170
171 # We don't haddock the bootstrapping libraries
172 libraries/hpc_dist-boot_DO_HADDOCK = NO
173 libraries/Cabal_dist-boot_DO_HADDOCK = NO
174 libraries/extensible-exceptions_dist-boot_DO_HADDOCK = NO
175 libraries/filepath_dist-boot_DO_HADDOCK = NO
176 libraries/binary_dist-boot_DO_HADDOCK = NO
177 libraries/bin-package-db_dist-boot_DO_HADDOCK = NO
178
179 # -----------------------------------------------------------------------------
180 # Ways
181
182 include rules/way-prelims.mk
183
184 $(foreach way,$(ALL_WAYS),\
185   $(eval $(call way-prelims,$(way))))
186
187 # -----------------------------------------------------------------------------
188 # Compilation Flags
189
190 include rules/distdir-way-opts.mk
191
192 # -----------------------------------------------------------------------------
193 # Finding source files and object files
194
195 include rules/hs-sources.mk
196 include rules/c-sources.mk
197 include rules/includes-sources.mk
198 include rules/hs-objs.mk
199 include rules/c-objs.mk
200 include rules/cmm-objs.mk
201
202 # -----------------------------------------------------------------------------
203 # Suffix rules
204
205 # Suffix rules cause "make clean" to fail on Windows (trac #3233)
206 # so we don't make any when cleaning.
207 ifneq "$(CLEANING)" "YES"
208
209 include rules/hs-suffix-rules-srcdir.mk
210 include rules/hs-suffix-rules.mk
211
212 # -----------------------------------------------------------------------------
213 # Suffix rules for .hi files
214
215 include rules/hi-rule.mk
216
217 $(foreach way,$(ALL_WAYS),\
218   $(eval $(call hi-rule,$(way))))
219
220 #-----------------------------------------------------------------------------
221 # C-related suffix rules
222
223 include rules/c-suffix-rules.mk
224
225 #-----------------------------------------------------------------------------
226 # CMM-related suffix rules
227
228 include rules/cmm-suffix-rules.mk
229
230 endif
231
232 # -----------------------------------------------------------------------------
233 # Building package-data.mk files from .cabal files
234
235 include rules/package-config.mk
236
237 # -----------------------------------------------------------------------------
238 # Building dependencies
239
240 include rules/build-dependencies.mk
241
242 # -----------------------------------------------------------------------------
243 # Build package-data.mk files
244
245 include rules/build-package-data.mk
246
247 # -----------------------------------------------------------------------------
248 # Build and install a program
249
250 include rules/build-prog.mk
251 include rules/shell-wrapper.mk
252
253 # -----------------------------------------------------------------------------
254 # Build a perl script
255
256 include rules/build-perl.mk
257
258 # -----------------------------------------------------------------------------
259 # Build a package
260
261 include rules/build-package.mk
262 include rules/build-package-way.mk
263 include rules/haddock.mk
264
265 # -----------------------------------------------------------------------------
266 # Registering hand-written package descriptions (used in libffi and rts)
267
268 include rules/manual-package-config.mk
269
270 # -----------------------------------------------------------------------------
271 # Docs
272
273 include rules/docbook.mk
274
275 # -----------------------------------------------------------------------------
276 # Making bindists
277
278 include rules/bindist.mk
279
280 # -----------------------------------------------------------------------------
281 # Building libraries
282
283 define addPackage # args: $1 = package, $2 = condition
284     ifneq "$2" ""
285         ifeq "$$(CLEANING)" "YES"
286             PACKAGES += $1
287         else
288             ifeq $2
289                 PACKAGES += $1
290             endif
291         endif
292     else
293         PACKAGES += $1
294     endif
295 endef
296
297 $(eval $(call addPackage,ghc-prim))
298 ifeq "$(CLEANING)" "YES"
299 $(eval $(call addPackage,integer-gmp))
300 $(eval $(call addPackage,integer-simple))
301 else
302 $(eval $(call addPackage,$(INTEGER_LIBRARY)))
303 endif
304 $(eval $(call addPackage,base))
305 $(eval $(call addPackage,filepath))
306 $(eval $(call addPackage,array))
307 $(eval $(call addPackage,bytestring))
308 $(eval $(call addPackage,containers))
309
310 $(eval $(call addPackage,Win32,($$(Windows),YES)))
311 $(eval $(call addPackage,unix,($$(Windows),NO)))
312
313 $(eval $(call addPackage,old-locale))
314 $(eval $(call addPackage,old-time))
315 $(eval $(call addPackage,time))
316 $(eval $(call addPackage,directory))
317 $(eval $(call addPackage,process))
318 $(eval $(call addPackage,random))
319 $(eval $(call addPackage,extensible-exceptions))
320 $(eval $(call addPackage,haskell98))
321 $(eval $(call addPackage,hpc))
322 $(eval $(call addPackage,pretty))
323 $(eval $(call addPackage,syb))
324 $(eval $(call addPackage,template-haskell))
325 $(eval $(call addPackage,base3-compat))
326 $(eval $(call addPackage,Cabal))
327 $(eval $(call addPackage,binary))
328 $(eval $(call addPackage,bin-package-db))
329 $(eval $(call addPackage,mtl))
330 $(eval $(call addPackage,utf8-string))
331
332 $(eval $(call addPackage,terminfo,($$(Windows),NO)))
333
334 $(eval $(call addPackage,haskeline))
335
336 ifneq "$(BootingFromHc)" "YES"
337 PACKAGES_STAGE2 += \
338         dph/dph-base \
339         dph/dph-prim-interface \
340         dph/dph-prim-seq \
341         dph/dph-prim-par \
342         dph/dph-seq \
343         dph/dph-par
344 endif
345
346 # We assume that the stage0 compiler has a suitable bytestring package,
347 # so we don't have to include it below.
348 BOOT_PKGS = Cabal hpc extensible-exceptions binary bin-package-db
349
350 # The actual .a and .so/.dll files: needed for dependencies.
351 ALL_STAGE1_LIBS  = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_v_LIB))
352 ifeq "$(BuildSharedLibs)" "YES"
353 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_dyn_LIB))
354 endif
355 BOOT_LIBS = $(foreach lib,$(BOOT_PKGS),$(libraries/$(lib)_dist-boot_v_LIB))
356
357 OTHER_LIBS = libffi/libHSffi$(v_libsuf) libffi/HSffi.o
358 ifeq "$(BuildSharedLibs)" "YES"
359 OTHER_LIBS  += libffi/libHSffi$(dyn_libsuf)
360 endif
361
362 # We cannot run ghc-cabal to configure a package until we have
363 # configured and registered all of its dependencies.  So the following
364 # hack forces all the configure steps to happen in exactly the order
365 # given in the PACKAGES variable above.  Ideally we should use the
366 # correct dependencies here to allow more parallelism, but we don't
367 # know the dependencies until we've generated the pacakge-data.mk
368 # files.
369 define fixed_pkg_dep
370 libraries/$1/$2/package-data.mk : $$(GHC_PKG_INPLACE) $$(if $$(fixed_pkg_prev),libraries/$$(fixed_pkg_prev)/$2/package-data.mk)
371 fixed_pkg_prev:=$1
372 endef
373
374 ifneq "$(BINDIST)" "YES"
375 fixed_pkg_prev=
376 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
377
378 # We assume that the stage2 compiler depends on all the libraries, so
379 # they all get added to the package database before we try to configure
380 # it
381 compiler/stage2/package-data.mk: $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),libraries/$(pkg)/dist-install/package-data.mk)
382 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
383 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
384 # haddock depends on ghc and some libraries, but depending on GHC's
385 # package-data.mk is sufficient, as that in turn depends on all the
386 # libraries
387 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
388
389 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
390
391 # add the final two package.conf dependencies: ghc-prim depends on RTS,
392 # and RTS depends on libffi.
393 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
394 rts/package.conf.inplace : libffi/package.conf.inplace
395 endif
396
397 # -----------------------------------------------------------------------------
398 # Special magic for the ghc-prim package
399
400 # We want the ghc-prim package to include the GHC.Prim module when it
401 # is registered, but not when it is built, because GHC.Prim is not a
402 # real source module, it is built-in to GHC.  The old build system did
403 # this using Setup.hs, but we can't do that here, so we have a flag to
404 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
405 # remains compatible with the old build system for the time being).
406 # GHC.Prim module in the ghc-prim package with a flag:
407 #
408 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
409
410 # And then we strip it out again before building the package:
411 define libraries/ghc-prim_PACKAGE_MAGIC
412 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
413 endef
414
415 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
416
417 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
418         "$(MKDIRHIER)" $(dir $@)
419         "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
420
421 libraries/ghc-prim/GHC/Prim.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
422         "$(GENPRIMOP_INPLACE)" --make-haskell-source <$(PRIMOPS_TXT) >$@
423
424
425 # -----------------------------------------------------------------------------
426 # Include build instructions from all subdirs
427
428 # For the rationale behind the build phases, see
429 #   http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
430
431 # Setting foo_dist_DISABLE=YES means "in directory foo, for build
432 # "dist", just read the package-data.mk file, do not build anything".
433
434 # We carefully engineer things so that we can build the
435 # package-data.mk files early on: they depend only on a few tools also
436 # built early.  Having got the package-data.mk files built, we can
437 # restart make with up-to-date information about all the packages
438 # (this is phase 0).  The remaining problem is the .depend files:
439 #
440 #   - .depend files in libraries need the stage 1 compiler to build
441 #   - ghc/stage1/.depend needs compiler/stage1 built
442 #   - compiler/stage1/.depend needs the bootstrap libs built
443 #
444 # GHC 6.11+ can build a .depend file without having built the
445 # dependencies of the package, but we can't rely on the bootstrapping
446 # compiler being able to do this, which is why we have to separate the
447 # three phases above.
448
449 # So this is the final ordering:
450
451 # Phase 0 : all package-data.mk files
452 #           (requires ghc-cabal, ghc-pkg, mkdirhier, dummy-ghc etc.)
453 # Phase 1 : .depend files for bootstrap libs
454 #           (requires hsc2hs)
455 # Phase 2 : compiler/stage1/.depend
456 #           (requires bootstrap libs and genprimopcode)
457 # Phase 3 : ghc/stage1/.depend
458 #           (requires compiler/stage1)
459 #
460 # The rest : libraries/*/dist-install, compiler/stage2, ghc/stage2
461
462 BUILD_DIRS =
463
464 ifneq "$(BINDIST)" "YES"
465 BUILD_DIRS += \
466    $(GHC_MKDEPENDC_DIR) \
467    $(GHC_MKDIRHIER_DIR)
468 endif
469
470 BUILD_DIRS += \
471    docs/users_guide \
472    libraries/Cabal/doc \
473    $(GHC_UNLIT_DIR) \
474    $(GHC_HP2PS_DIR)
475
476 ifneq "$(GhcUnregisterised)" "YES"
477 BUILD_DIRS += \
478    $(GHC_MANGLER_DIR) \
479    $(GHC_SPLIT_DIR)
480 endif
481
482 ifneq "$(BINDIST)" "YES"
483 BUILD_DIRS += \
484    $(GHC_GENPRIMOP_DIR)
485 endif
486
487 BUILD_DIRS += \
488    driver \
489    driver/ghci \
490    driver/ghc \
491    libffi \
492    includes \
493    rts
494
495 ifneq "$(BINDIST)" "YES"
496 BUILD_DIRS += \
497    $(GHC_CABAL_DIR) \
498    $(GHC_GENAPPLY_DIR)
499 endif
500
501 BUILD_DIRS += \
502    utils/haddock \
503    utils/haddock/doc
504
505 ifneq "$(CLEANING)" "YES"
506 BUILD_DIRS += \
507    $(patsubst %, libraries/%, $(PACKAGES) $(PACKAGES_STAGE2))
508 ifneq "$(BootingFromHc)" "YES"
509 BUILD_DIRS += \
510    libraries/dph
511 endif
512 endif
513
514 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
515 BUILD_DIRS += libraries/integer-gmp/gmp
516 endif
517
518 BUILD_DIRS += \
519    compiler \
520    $(GHC_HSC2HS_DIR) \
521    $(GHC_PKG_DIR) \
522    utils/hpc \
523    utils/runghc \
524    ghc
525 ifeq "$(Windows)" "YES"
526 BUILD_DIRS += \
527    $(GHC_TOUCHY_DIR)
528 endif
529
530 # XXX libraries/% must come before any programs built with stage1, see
531 # Note [lib-depends].
532
533 ifeq "$(phase)" "0"
534 $(foreach lib,$(BOOT_PKGS),$(eval \
535   libraries/$(lib)_dist-boot_DISABLE = YES))
536 endif
537
538 ifneq "$(findstring $(phase),0 1)" ""
539 # We can build deps for compiler/stage1 in phase 2
540 compiler_stage1_DISABLE = YES
541 endif
542
543 ifneq "$(findstring $(phase),0 1 2)" ""
544 ghc_stage1_DISABLE = YES
545 endif
546
547 ifneq "$(CLEANING)" "YES"
548 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
549 libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
550 else
551     ifeq "$(INTEGER_LIBRARY)" "integer-simple"
552         libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
553     else
554 $(error Unknown integer library: $(INTEGER_LIBRARY))
555     endif
556 endif
557 endif
558
559 ifneq "$(findstring $(phase),0 1 2 3)" ""
560 # In phases 0-3, we disable stage2-3, the full libraries and haddock
561 utils/haddock_dist_DISABLE = YES
562 utils/runghc_dist_DISABLE = YES
563 utils/hpc_dist_DISABLE = YES
564 utils/hsc2hs_dist-install_DISABLE = YES
565 utils/ghc-pkg_dist-install_DISABLE = YES
566 compiler_stage2_DISABLE = YES
567 compiler_stage3_DISABLE = YES
568 ghc_stage2_DISABLE = YES
569 ghc_stage3_DISABLE = YES
570 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),$(eval \
571   libraries/$(lib)_dist-install_DISABLE = YES))
572 endif
573
574 # These packages don't pass the Cabal checks because hs-source-dirs
575 # points outside the source directory. This isn't a real problem in
576 # these cases, so we just skip checking them.
577 CHECKED_libraries/dph/dph-seq = YES
578 CHECKED_libraries/dph/dph-par = YES
579 # In compiler's case, include-dirs points outside of the source tree
580 CHECKED_compiler = YES
581
582 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
583
584 # We need -fno-warn-deprecated-flags to avoid failure with -Werror
585 GhcLibHcOpts += -fno-warn-deprecated-flags
586 ifeq "$(ghc_ge_609)" "YES"
587 GhcBootLibHcOpts += -fno-warn-deprecated-flags
588 endif
589
590 # Add $(GhcLibHcOpts) to all library builds
591 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
592
593 # XXX Hack; remove this
594 $(foreach pkg,$(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += -Wwarn))
595
596 # XXX we configure packages with the bootstrapping compiler (for
597 # dependency reasons, see the phase ordering), which doesn't
598 # necessarily support all the extensions we need, and Cabal filters
599 # out the ones it thinks aren't supported.
600 libraries/base3-compat_dist-install_HC_OPTS += -XPackageImports
601
602 # A useful pseudo-target
603 .PHONY: stage1_libs
604 stage1_libs : $(ALL_STAGE1_LIBS)
605
606 ifeq "$(HADDOCK_DOCS)" "YES"
607 libraries/index.html: $(ALL_HADDOCK_FILES)
608         cd libraries && sh gen_contents_index --inplace
609 $(eval $(call all-target,library_doc_index,libraries/index.html))
610 INSTALL_LIBRARY_DOCS += libraries/*.html libraries/*.gif libraries/*.css libraries/*.js
611 CLEAN_FILES += libraries/doc-index* libraries/haddock*.css \
612                libraries/haddock*.js libraries/index*.html libraries/*.gif
613 endif
614
615 ifeq "$(CHECK_PACKAGES)" "YES"
616 all: check_packages
617 endif
618
619 # -----------------------------------------------------------------------------
620 # Bootstrapping libraries
621
622 # We need to build a few libraries with the installed GHC, since GHC itself
623 # and some of the tools depend on them:
624
625 ifneq "$(BINDIST)" "YES"
626
627 ifneq "$(BOOTSTRAPPING_CONF)" ""
628 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
629 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
630 endif
631 endif
632
633 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
634
635 # These three libraries do not depend on each other, so we can build
636 # them straight off:
637
638 $(eval $(call build-package,libraries/hpc,dist-boot,0))
639 $(eval $(call build-package,libraries/extensible-exceptions,dist-boot,0))
640 $(eval $(call build-package,libraries/Cabal,dist-boot,0))
641 $(eval $(call build-package,libraries/binary,dist-boot,0))
642 $(eval $(call build-package,libraries/bin-package-db,dist-boot,0))
643
644 # register the boot packages in strict sequence, because running
645 # multiple ghc-pkgs in parallel doesn't work (registrations may get
646 # lost).
647 fixed_pkg_prev=
648 $(foreach pkg,$(BOOT_PKGS),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
649
650 compiler/stage1/package-data.mk : \
651     libraries/Cabal/dist-boot/package-data.mk \
652     libraries/hpc/dist-boot/package-data.mk \
653     libraries/extensible-exceptions/dist-boot/package-data.mk \
654     libraries/bin-package-db/dist-boot/package-data.mk
655
656 # These are necessary because the bootstrapping compiler may not know
657 # about cross-package dependencies:
658 $(compiler_stage1_depfile) : $(BOOT_LIBS)
659 $(ghc_stage1_depfile) : $(compiler_stage1_v_LIB)
660
661 # A few careful dependencies between bootstrapping packages.  When we
662 # can rely on the stage 0 compiler being able to generate
663 # cross-package dependencies with -M (fixed in GHC 6.12.1) we can drop
664 # these, and also some of the phases.
665 #
666 # If you miss any out here, then 'make -j8' will probably tell you.
667 #
668 libraries/bin-package-db/dist-boot/build/Distribution/InstalledPackageInfo/Binary.$(v_osuf) : libraries/binary/dist-boot/build/Data/Binary.$(v_hisuf) libraries/Cabal/dist-boot/build/Distribution/InstalledPackageInfo.$(v_hisuf)
669
670 $(foreach pkg,$(BOOT_PKGS),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
671
672 endif
673
674 # -----------------------------------------------------------------------------
675 # Creating a local mingw copy on Windows
676
677 ifeq "$(Windows)" "YES"
678
679 # directories don't work well as dependencies, hence a stamp file
680 $(INPLACE)/stamp-mingw : $(MKDIRHIER)
681         $(MKDIRHIER) $(INPLACE_MINGW)/bin
682         GCC=`type -p $(WhatGccIsCalled)`; \
683         GccDir=`dirname $$GCC`; \
684         "$(CP)" -p $$GccDir/{gcc.exe,ar.exe,as.exe,dlltool.exe,dllwrap.exe,windres.exe} $(INPLACE_MINGW)/bin; \
685         "$(CP)" -Rp $$GccDir/../include $(INPLACE_MINGW); \
686         "$(CP)" -Rp $$GccDir/../lib     $(INPLACE_MINGW); \
687         "$(CP)" -Rp $$GccDir/../libexec $(INPLACE_MINGW); \
688         "$(CP)" -Rp $$GccDir/../mingw32 $(INPLACE_MINGW)
689         touch $(INPLACE)/stamp-mingw
690
691 install : install_mingw
692 .PHONY: install_mingw
693 install_mingw : $(INPLACE_MINGW)
694         "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
695
696 $(INPLACE_LIB)/perl.exe $(INPLACE_LIB)/perl56.dll :
697         "$(CP)" $(GhcDir)../{perl.exe,perl56.dll} $(INPLACE_LIB)
698
699 endif # Windows
700
701 libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock: \
702     libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs \
703     libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs
704
705 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
706                             $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
707         "$(MKDIRHIER)" $(dir $@)
708         "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
709
710 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
711                             $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
712         "$(MKDIRHIER)" $(dir $@)
713         "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers < $< > $@
714
715 # -----------------------------------------------------------------------------
716 # Installation
717
718 install: install_packages install_libs install_libexecs install_headers \
719          install_libexec_scripts install_bins install_docs \
720                  install_topdirs install_topdir_scripts
721
722 install_bins: $(INSTALL_BINS)
723         $(INSTALL_DIR) $(DESTDIR)$(bindir)
724         for i in $(INSTALL_BINS); do \
725                 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ;  \
726                 if test "$(darwin_TARGET_OS)" = "1"; then \
727                    sh mk/fix_install_names.sh $(ghclibdir) $(DESTDIR)$(bindir)/$$i ; \
728                 fi ; \
729         done
730
731 install_libs: $(INSTALL_LIBS)
732         $(INSTALL_DIR) $(DESTDIR)$(ghclibdir)
733         for i in $(INSTALL_LIBS); do \
734                 case $$i in \
735                   *.a) \
736                     $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(ghclibdir); \
737                     $(RANLIB) $(DESTDIR)$(ghclibdir)/`basename $$i` ;; \
738                   *.dll) \
739                     $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(ghclibdir) ;; \
740                   *.so) \
741                     $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(ghclibdir) ;; \
742                   *.dylib) \
743                     $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(ghclibdir); \
744                     install_name_tool -id $(DESTDIR)$(ghclibdir)/`basename $$i` $(DESTDIR)$(ghclibdir)/`basename $$i` ;; \
745                   *) \
746                     $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(ghclibdir); \
747                 esac; \
748         done
749
750 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
751         $(INSTALL_DIR) $(DESTDIR)$(ghclibexecdir)
752         for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
753                 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(ghclibexecdir); \
754         done
755
756 install_libexecs:  $(INSTALL_LIBEXECS)
757         $(INSTALL_DIR) $(DESTDIR)$(ghclibexecdir)
758         for i in $(INSTALL_LIBEXECS); do \
759                 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(ghclibexecdir); \
760         done
761
762 install_topdir_scripts: $(INSTALL_TOPDIR_SCRIPTS)
763         $(INSTALL_DIR) $(DESTDIR)$(topdir)
764         for i in $(INSTALL_TOPDIR_SCRIPTS); do \
765                 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(topdir); \
766         done
767
768 install_topdirs: $(INSTALL_TOPDIRS)
769         $(INSTALL_DIR) $(DESTDIR)$(topdir)
770         for i in $(INSTALL_TOPDIRS); do \
771                 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(topdir); \
772         done
773
774 install_headers: $(INSTALL_HEADERS)
775         $(INSTALL_DIR) $(DESTDIR)$(ghcheaderdir)
776         for i in $(INSTALL_HEADERS); do \
777                 $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(ghcheaderdir); \
778         done
779
780 install_docs: $(INSTALL_HEADERS)
781         $(INSTALL_DIR) $(DESTDIR)$(docdir)
782         for i in $(INSTALL_DOCS); do \
783                 $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir); \
784         done
785         $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html; \
786         $(INSTALL_DOC) $(INSTALL_OPTS) docs/index.html $(DESTDIR)$(docdir)/html; \
787         for i in $(INSTALL_LIBRARY_DOCS); do \
788                 $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir)/html/libraries/; \
789         done
790         for i in $(INSTALL_HTML_DOC_DIRS); do \
791                 $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html/`basename $$i`; \
792                 $(INSTALL_DOC) $(INSTALL_OPTS) $$i/* $(DESTDIR)$(docdir)/html/`basename $$i`; \
793         done
794
795 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
796
797 # Install packages in the right order, so that ghc-pkg doesn't complain.
798 # Also, install ghc-pkg first.
799 ifeq "$(Windows)" "NO"
800 INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/ghc-stage2
801 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/ghc-pkg
802 else
803 INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
804 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
805 endif
806
807 install_packages: install_libexecs
808 install_packages: libffi/package.conf.install rts/package.conf.install
809         $(INSTALL_DIR) $(DESTDIR)$(topdir)
810         "$(RM)" -r $(RM_OPTS) $(INSTALLED_PACKAGE_CONF)
811         $(INSTALL_DIR) $(INSTALLED_PACKAGE_CONF)
812         "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update libffi/package.conf.install
813         "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update rts/package.conf.install
814         $(foreach p, $(PACKAGES) $(PACKAGES_STAGE2),\
815             "$(GHC_CABAL_INPLACE)" install \
816                  $(INSTALLED_GHC_REAL) \
817                  $(INSTALLED_GHC_PKG_REAL) \
818                  $(DESTDIR)$(topdir) \
819                  libraries/$p dist-install \
820                  '$(DESTDIR)' '$(prefix)' '$(ghclibdir)' '$(docdir)/html/libraries' &&) true
821         "$(GHC_CABAL_INPLACE)" install \
822                  $(INSTALLED_GHC_REAL) \
823                  $(INSTALLED_GHC_PKG_REAL) \
824                  $(DESTDIR)$(topdir) \
825                  compiler stage2 \
826                  '$(DESTDIR)' '$(prefix)' '$(ghclibdir)' '$(docdir)/html/libraries'
827
828 # -----------------------------------------------------------------------------
829 # Binary distributions
830
831 ifneq "$(CLEANING)" "YES"
832 # This rule seems to hold some files open on Windows which prevents
833 # cleaning, perhaps due to the $(wildcard).
834
835 $(eval $(call bindist,.,\
836     LICENSE \
837     configure config.sub config.guess install-sh \
838     extra-gcc-opts.in \
839     Makefile \
840     mk/config.mk.in \
841     $(INPLACE_BIN)/mkdirhier \
842     $(INPLACE_BIN)/ghc-cabal \
843     utils/ghc-pwd/ghc-pwd \
844         $(BINDIST_WRAPPERS) \
845         $(BINDIST_LIBS) \
846         $(BINDIST_HI) \
847         $(BINDIST_EXTRAS) \
848         $(includes_H_CONFIG) \
849         $(includes_H_PLATFORM) \
850         includes/ghcconfig.h \
851         includes/rts/Config.h \
852     $(INSTALL_HEADERS) \
853     $(INSTALL_LIBEXECS) \
854     $(INSTALL_LIBEXEC_SCRIPTS) \
855     $(INSTALL_TOPDIRS) \
856     $(INSTALL_TOPDIR_SCRIPTS) \
857     $(INSTALL_BINS) \
858     $(INSTALL_DOCS) \
859     $(INSTALL_LIBRARY_DOCS) \
860     $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
861         docs/index.html \
862         $(wildcard libraries/*/dist-install/doc/) \
863     $(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
864     $(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
865         mk/fix_install_names.sh \
866         mk/project.mk \
867         mk/install.mk.in \
868         bindist.mk \
869         libraries/dph/LICENSE \
870  ))
871 endif
872 # mk/project.mk gets an absolute path, so we manually include it in
873 # the bindist with a relative path
874
875 BIN_DIST_MK = $(BIN_DIST_NAME)/bindist.mk
876
877 binary-dist:
878         "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
879         mkdir $(BIN_DIST_NAME)
880         set -e; for i in 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; do ln -s ../$$i $(BIN_DIST_NAME)/; done
881         echo "HADDOCK_DOCS       = $(HADDOCK_DOCS)"       >> $(BIN_DIST_MK)
882         echo "LATEX_DOCS         = $(LATEX_DOCS)"         >> $(BIN_DIST_MK)
883         echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
884         echo "BUILD_DOCBOOK_PS   = $(BUILD_DOCBOOK_PS)"   >> $(BIN_DIST_MK)
885         echo "BUILD_DOCBOOK_PDF  = $(BUILD_DOCBOOK_PDF)"  >> $(BIN_DIST_MK)
886         ln -s ../distrib/configure-bin.ac $(BIN_DIST_NAME)/configure.ac
887         cd $(BIN_DIST_NAME) && autoreconf
888         "$(RM)" $(RM_OPTS) $(BIN_DIST_TAR)
889 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
890 # tree then we want to include the real file, not a symlink to it
891         "$(TAR)" hcf - -T $(BIN_DIST_LIST) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
892
893 windows-binary-dist:
894         "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
895         $(MAKE) prefix=$(BIN_DIST_DIR) install
896         "$(TAR)" cf - $(BIN_DIST_NAME) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
897
898 windows-installer:
899         "$(ISCC)" /O. /F$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
900
901 nTimes = set -e; for i in `seq 1 $(1)`; do echo Try "$$i: $(2)"; if $(2); then break; fi; done
902
903 .PHONY: publish-binary-dist
904 publish-binary-dist:
905         $(call nTimes,10,$(PublishCp) $(BIN_DIST_TAR_BZ2) $(PublishLocation)/dist)
906 ifeq "$(mingw32_TARGET_OS)" "1"
907         $(call nTimes,10,$(PublishCp) $(WINDOWS_INSTALLER) $(PublishLocation)/dist)
908 endif
909
910 .PHONY: publish-docs
911 publish-docs:
912         $(call nTimes,10,$(PublishCp) -r bindisttest/installed/share/doc/ghc/* $(PublishLocation)/docs)
913
914 # -----------------------------------------------------------------------------
915 # Source distributions
916
917 # Do it like this:
918 #
919 #       $ make
920 #       $ make sdist
921 #
922
923 # A source dist is built from a complete build tree, because we
924 # require some extra files not contained in a darcs checkout: the
925 # output from Happy and Alex, for example.
926 #
927 # The steps performed by 'make dist' are as follows:
928 #   - create a complete link-tree of the current build tree in /tmp
929 #   - run 'make distclean' on that tree
930 #   - remove a bunch of other files that we know shouldn't be in the dist
931 #   - tar up first the extralibs package, then the main source package
932
933 #
934 # Directory in which we're going to build the src dist
935 #
936 SRC_DIST_NAME=ghc-$(ProjectVersion)
937 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
938
939 #
940 # Files to include in source distributions
941 #
942 SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts compiler ghc driver libraries
943 SRC_DIST_FILES += \
944         configure.ac config.guess config.sub configure \
945         aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
946         ghc.spec.in ghc.spec extra-gcc-opts.in VERSION \
947         boot boot-pkgs packages ghc.mk
948
949 SRC_DIST_TARBALL = $(SRC_DIST_NAME)-src.tar.bz2
950
951 VERSION :
952         echo $(ProjectVersion) >VERSION
953
954 sdist : VERSION
955
956 # Use:
957 #     $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
958 # to copy the generated file that replaces compiler/cmm/CmmLex.x, where
959 # "stage2" is the dist dir.
960 sdist_file = \
961   if test -f $(TOP)/$1/$2/build/$4.hs; then \
962     "$(CP)" $(TOP)/$1/$2/build/$4.hs $1/$3/ ; \
963     mv $1/$3/$4.$5 $1/$3/$4.$5.source ;\
964   else \
965     echo "does not exist: $1/$2/build/$4.hs"; \
966     exit 1; \
967   fi
968
969 .PHONY: sdist-prep
970 sdist-prep :
971         "$(RM)" $(RM_OPTS) -r $(SRC_DIST_DIR)
972         "$(RM)" $(RM_OPTS) $(SRC_DIST_TARBALL)
973         mkdir $(SRC_DIST_DIR)
974         cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_DIRS); do mkdir $$i; ( cd $$i && lndir $(TOP)/$$i ); done
975         cd $(SRC_DIST_DIR) && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done
976         cd $(SRC_DIST_DIR) && $(MAKE) distclean
977         cd $(SRC_DIST_DIR) && if test -f $(TOP)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs; then "$(CP)" $(TOP)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs libraries/haskell-src/Language/Haskell/ ; mv libraries/haskell-src/Language/Haskell/Parser.ly libraries/haskell-src/Language/Haskell/Parser.ly.source ; fi
978         cd $(SRC_DIST_DIR) && $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
979         cd $(SRC_DIST_DIR) && $(call sdist_file,compiler,stage2,cmm,CmmParse,y)
980         cd $(SRC_DIST_DIR) && $(call sdist_file,compiler,stage2,parser,Lexer,x)
981         cd $(SRC_DIST_DIR) && $(call sdist_file,compiler,stage2,parser,Parser,y.pp)
982         cd $(SRC_DIST_DIR) && $(call sdist_file,compiler,stage2,parser,ParserCore,y)
983         cd $(SRC_DIST_DIR) && $(call sdist_file,utils/hpc,dist,,HpcParser,y)
984         cd $(SRC_DIST_DIR) && $(call sdist_file,utils/genprimopcode,dist,,Lexer,x)
985         cd $(SRC_DIST_DIR) && $(call sdist_file,utils/genprimopcode,dist,,Parser,y)
986         cd $(SRC_DIST_DIR) && "$(RM)" $(RM_OPTS) -r compiler/stage[123] mk/build.mk
987         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 "$(RM)" $(RM_OPTS) -r
988
989 .PHONY: sdist
990 sdist : sdist-prep
991         "$(TAR)" chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
992
993 sdist-manifest : $(SRC_DIST_TARBALL)
994         tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
995
996 # Upload the distribution(s)
997 # Retrying is to work around buggy firewalls that corrupt large file transfers
998 # over SSH.
999 ifneq "$(PublishLocation)" ""
1000 publish-sdist :
1001         $(call nTimes,10,$(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist)
1002 endif
1003
1004 ifeq "$(BootingFromHc)" "YES"
1005 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
1006 endif
1007
1008 # -----------------------------------------------------------------------------
1009 # Cleaning
1010
1011 .PHONY: clean
1012
1013 CLEAN_FILES += utils/ghc-pwd/ghc-pwd
1014 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.exe
1015 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.hi
1016 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.o
1017 CLEAN_FILES += libraries/bootstrapping.conf
1018 CLEAN_FILES += libraries/integer-gmp/cbits/GmpDerivedConstants.h
1019 CLEAN_FILES += libraries/integer-gmp/cbits/mkGmpDerivedConstants
1020
1021 clean : clean_files clean_libraries
1022
1023 .PHONY: clean_files
1024 clean_files :
1025         "$(RM)" $(RM_OPTS) $(CLEAN_FILES)
1026
1027 ifneq "$(NO_CLEAN_GMP)" "YES"
1028 CLEAN_FILES += libraries/integer-gmp/gmp/gmp.h
1029 CLEAN_FILES += libraries/integer-gmp/gmp/libgmp.a
1030
1031 clean : clean_gmp
1032 .PHONY: clean_gmp
1033 clean_gmp:
1034         "$(RM)" $(RM_OPTS) -r libraries/integer-gmp/gmp/objs
1035         "$(RM)" $(RM_OPTS) -r libraries/integer-gmp/gmp/gmpbuild
1036 endif
1037
1038 .PHONY: clean_libraries
1039 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES) $(PACKAGES_STAGE2))
1040 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(BOOT_PKGS))
1041
1042 clean_libraries:
1043         "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/dist, $(PACKAGES) $(PACKAGES_STAGE2))
1044         "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/*.buildinfo, $(PACKAGES) $(PACKAGES_STAGE2))
1045
1046 # We have to define a clean target for each library manually, because the
1047 # libraries/*/ghc.mk files are not included when we're cleaning.
1048 ifeq "$(CLEANING)" "YES"
1049 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),\
1050   $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
1051 endif
1052
1053 distclean : clean
1054         "$(RM)" $(RM_OPTS) config.cache config.status config.log mk/config.h mk/stamp-h
1055         "$(RM)" $(RM_OPTS) mk/config.mk mk/are-validating.mk mk/project.mk
1056         "$(RM)" $(RM_OPTS) mk/config.mk.old mk/project.mk.old
1057         "$(RM)" $(RM_OPTS) extra-gcc-opts docs/users_guide/ug-book.xml
1058         "$(RM)" $(RM_OPTS) compiler/ghc.cabal compiler/ghc.cabal.old
1059         "$(RM)" $(RM_OPTS) ghc/ghc-bin.cabal
1060         "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h
1061         "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h
1062         "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h
1063         "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h
1064         "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h
1065
1066         "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.log, $(PACKAGES) $(PACKAGES_STAGE2))
1067         "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.status, $(PACKAGES) $(PACKAGES_STAGE2))
1068         "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES) $(PACKAGES_STAGE2))
1069         "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/autom4te.cache, $(PACKAGES) $(PACKAGES_STAGE2))
1070
1071 maintainer-clean : distclean
1072         "$(RM)" $(RM_OPTS) configure mk/config.h.in
1073         "$(RM)" $(RM_OPTS) -r autom4te.cache libraries/*/autom4te.cache
1074         "$(RM)" $(RM_OPTS) ghc.spec
1075         "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/GNUmakefile, \
1076                 $(PACKAGES) $(PACKAGES_STAGE2))
1077         "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/ghc.mk, $(PACKAGES) $(PACKAGES_STAGE2))
1078         "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/configure, \
1079                 $(PACKAGES) $(PACKAGES_STAGE2))
1080         "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h.in
1081         "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h.in
1082         "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h.in
1083         "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h.in
1084         "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h.in
1085
1086 .PHONY: all_libraries
1087
1088 .PHONY: bootstrapping-files
1089 bootstrapping-files: $(OTHER_LIBS)
1090 bootstrapping-files: includes/ghcautoconf.h
1091 bootstrapping-files: includes/DerivedConstants.h
1092 bootstrapping-files: includes/GHCConstants.h
1093
1094 .DELETE_ON_ERROR:
1095