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