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