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