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