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