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