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