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