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