1 # -----------------------------------------------------------------------------
3 # (c) 2009-2013 The University of Glasgow
5 # This file is part of the GHC build system.
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
11 # -----------------------------------------------------------------------------
15 # * remove old Makefiles, add new stubs for building in subdirs
17 # * docs/docbook-cheat-sheet/Makefile
19 # * docs/storage-mgmt/Makefile
21 # * rts/dotnet/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)
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
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.
41 # Approximate build order.
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
47 # * With bootstrapping compiler:
48 # o Build utils/ghc-cabal
49 # o Build utils/ghc-pkg
50 # o Build utils/hsc2hs
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)
61 # o Build utils/* (except haddock)
62 # o Build compiler (stage 2)
64 # o Build utils/haddock
65 # o Build compiler (stage 3) (optional)
70 .PHONY
: default
all haddock
72 # We need second expansion for the way we handle directories, so that
74 # expands to the directory of a rule that uses a % pattern.
80 ##################################################
81 # Check that we have a new enough 'make'
84 $(eval HAVE_EVAL
:= YES
)
86 ifeq "$(HAVE_EVAL)" "NO"
87 $(error Your make does not support eval. You need GNU make
>= 3.81)
90 ifeq "$(abspath /)" ""
91 $(error Your make does not support abspath. You need GNU make
>= 3.81)
93 ##################################################
96 # Catch make if it runs away into an infinite loop
97 ifeq "$(MAKE_RESTARTS)" ""
98 else ifeq "$(MAKE_RESTARTS)" "1"
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)
103 ifneq "$(CLEANING)" "YES"
107 # -----------------------------------------------------------------------------
108 # Misc GNU make utils
111 space
=$(nothing
) $(nothing
)
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:
120 # -----------------------------------------------------------------------------
123 # to see the effective value used for a Makefile variable, do
124 # make show VALUE=MY_VALUE
128 @echo
'$(VALUE)="$($(VALUE))"'
130 # echo is used by the nightly builders to query the build system for
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.
136 @printf
"$(subst %,%%,$(subst ",\",$(subst \
,\\\\,$($(VALUE
)))))"
138 # -----------------------------------------------------------------------------
139 # Include subsidiary build-system bits
143 ifeq "$(findstring clean,$(MAKECMDGOALS
))" ""
145 ifeq "$(ProjectVersion
)" ""
146 $(error Please run ./configure first)
152 # (Optional) build-specific configuration
153 include mk/custom-settings.mk
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)
161 ifeq "$(findstring v
,$(GhcLibWays
))" ""
162 $(error v is not in $$(GhcLibWays), and $$(DYNAMIC_GHC_PROGRAMS) is not YES)
165 ifeq "$(GhcProfiled
)" "YES
"
166 ifeq "$(findstring p
,$(GhcLibWays
))" ""
167 $(error p is not in $$(GhcLibWays), and $$(GhcProfiled) is YES)
176 # -----------------------------------------------------------------------------
177 # Utility definitions
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
186 # -----------------------------------------------------------------------------
187 # Macros for standard targets
189 include rules/all-target.mk
190 include rules/clean-target.mk
192 # -----------------------------------------------------------------------------
195 $(eval $(call clean-target,root,inplace,inplace/bin inplace/lib))
197 # -----------------------------------------------------------------------------
198 # Whether to build dependencies or not
200 # When we're just doing 'make clean' or 'make show', then we don't need
201 # to build dependencies.
203 ifneq "$(findstring clean,$(MAKECMDGOALS
))" ""
204 NO_INCLUDE_DEPS = YES
205 NO_INCLUDE_PKGDATA = YES
207 ifneq "$(findstring bootstrapping-files
,$(MAKECMDGOALS
))" ""
208 NO_INCLUDE_DEPS = YES
209 NO_INCLUDE_PKGDATA = YES
211 ifeq "$(findstring show
,$(MAKECMDGOALS
))" "show
"
212 NO_INCLUDE_DEPS = YES
213 # We want package-data.mk for show
216 # -----------------------------------------------------------------------------
219 include rules/way-prelims.mk
221 $(foreach way,$(ALL_WAYS),\
222 $(eval $(call way-prelims,$(way))))
224 ifeq "$(DYNAMIC_GHC_PROGRAMS
)" "YES
"
232 WINDOWS_DYN_PROG_RTS := rts
233 ifeq "$(GhcThreaded
)" "YES
"
234 WINDOWS_DYN_PROG_RTS := $(WINDOWS_DYN_PROG_RTS)_thr
236 ifeq "$(GhcDebugged
)" "YES
"
237 WINDOWS_DYN_PROG_RTS := $(WINDOWS_DYN_PROG_RTS)_debug
239 WINDOWS_DYN_PROG_RTS := $(WINDOWS_DYN_PROG_RTS)_dyn_LIB_NAME
241 # -----------------------------------------------------------------------------
244 include rules/distdir-opts.mk
245 include rules/distdir-way-opts.mk
247 # -----------------------------------------------------------------------------
248 # Finding source files and object files
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
257 # -----------------------------------------------------------------------------
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
"
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
273 # -----------------------------------------------------------------------------
274 # Building package-data.mk files from .cabal files
276 include rules/package-config.mk
278 # -----------------------------------------------------------------------------
279 # Building dependencies
281 include rules/dependencies.mk
282 include rules/build-dependencies.mk
283 include rules/include-dependencies.mk
285 # -----------------------------------------------------------------------------
286 # Dynamic library references
288 include rules/relative-dynlib-references.mk
290 # -----------------------------------------------------------------------------
291 # Build package-data.mk files
293 include rules/build-package-data.mk
295 # -----------------------------------------------------------------------------
296 # Build and install a program
298 include rules/build-prog.mk
299 include rules/shell-wrapper.mk
301 # -----------------------------------------------------------------------------
302 # Build a perl script
304 include rules/build-perl.mk
306 # -----------------------------------------------------------------------------
309 include rules/build-package.mk
310 include rules/build-package-way.mk
311 include rules/haddock.mk
312 include rules/tags-package.mk
313 include rules/foreachLibrary.mk
315 # -----------------------------------------------------------------------------
316 # Registering hand-written package descriptions (used in rts)
318 include rules/manual-package-config.mk
320 # -----------------------------------------------------------------------------
323 include rules/docbook.mk
325 # -----------------------------------------------------------------------------
328 include rules/bindist.mk
330 # -----------------------------------------------------------------------------
333 # Don't try to delete directories:
336 # Create build directories on demand. NB. the | below: this indicates
337 # that $(MKDIRHIER) is an order-only dependency, which means that this
338 # rule fires after building mkdirhier, but we won't try to recreate
339 # directories if mkdirhier changes.
343 # -----------------------------------------------------------------------------
346 ifeq "$(LAX_DEPENDENCIES
)" "YES
"
352 # This is a bit of a hack. When LAX_DEPS_FOLLOW is | some rules end up
355 # The first | signals the start of the order-only dependencies, but make
356 # treats the second | as a dependency. So we need to tell make how to
357 # build that dependency.
363 # -----------------------------------------------------------------------------
365 # The lists of packages that we *actually* going to build in each stage:
371 # Note that we need to add them to these variables in dependency
372 # order, as this is the order that they get configured in.
374 ifeq "$(CLEANING
)" "YES
"
376 define addLibraryForCleaning
377 # We just add all packages to both the stage 0 and stage 1 lists.
378 # Stage 2 gets cleaned in the same way as stage 1, so no need to
380 PACKAGES_STAGE0 += $1
381 PACKAGES_STAGE1 += $1
383 $(eval $(call foreachLibrary,addLibraryForCleaning))
387 # Packages that are built by stage0. These packages are dependencies of
388 # programs such as GHC and ghc-pkg, that we do not assume the stage0
389 # compiler already has installed (or up-to-date enough).
391 PACKAGES_STAGE0 = Cabal/Cabal hpc bin-package-db hoopl transformers
392 ifeq "$(Windows_Host
)" "NO
"
393 ifneq "$(HostOS_CPP
)" "ios
"
394 PACKAGES_STAGE0 += terminfo
398 PACKAGES_STAGE1 += ghc-prim
399 PACKAGES_STAGE1 += $(INTEGER_LIBRARY)
400 PACKAGES_STAGE1 += base
401 PACKAGES_STAGE1 += filepath
402 PACKAGES_STAGE1 += array
403 PACKAGES_STAGE1 += deepseq
404 PACKAGES_STAGE1 += bytestring
405 PACKAGES_STAGE1 += containers
406 PACKAGES_STAGE1 += old-locale
408 ifeq "$(Windows_Host
)" "YES
"
409 PACKAGES_STAGE1 += Win32
411 PACKAGES_STAGE1 += time
412 ifeq "$(Windows_Host
)" "NO
"
413 PACKAGES_STAGE1 += unix
416 PACKAGES_STAGE1 += directory
417 PACKAGES_STAGE1 += process
418 PACKAGES_STAGE1 += hpc
419 PACKAGES_STAGE1 += pretty
420 PACKAGES_STAGE1 += template-haskell
421 PACKAGES_STAGE1 += Cabal/Cabal
422 PACKAGES_STAGE1 += binary
423 PACKAGES_STAGE1 += bin-package-db
424 PACKAGES_STAGE1 += hoopl
425 PACKAGES_STAGE1 += transformers
427 ifneq "$(CrossCompiling
)" "YES
"
428 PACKAGES_STAGE2 += old-time
429 PACKAGES_STAGE2 += haskell98
430 PACKAGES_STAGE2 += haskell2010
433 # We normally install only the packages down to this point
434 REGULAR_INSTALL_PACKAGES := $(addprefix libraries/,$(PACKAGES_STAGE1))
435 ifeq "$(Stage1Only
)" "NO
"
436 REGULAR_INSTALL_PACKAGES += compiler
438 REGULAR_INSTALL_PACKAGES += $(addprefix libraries/,$(PACKAGES_STAGE2))
440 PACKAGES_STAGE1 += xhtml
441 ifeq "$(Windows_Target
)" "NO
"
442 ifneq "$(TargetOS_CPP
)" "ios
"
443 PACKAGES_STAGE1 += terminfo
446 PACKAGES_STAGE1 += haskeline
448 # If we have built the programs with dynamic libraries, then
449 # ghc will be dynamically linked against haskeline.so etc, so
450 # we need the dynamic libraries of everything down to here
451 REGULAR_INSTALL_DYNLIBS := $(addprefix libraries/,$(PACKAGES_STAGE1))
452 REGULAR_INSTALL_DYNLIBS += $(addprefix libraries/,$(PACKAGES_STAGE2))
453 REGULAR_INSTALL_DYNLIBS := $(filter-out $(REGULAR_INSTALL_PACKAGES),\
454 $(REGULAR_INSTALL_DYNLIBS))
456 ifneq "$(CrossCompiling
)" "YES
"
457 define addExtraPackage
459 # Do nothing; this package is already handled above
460 else ifeq "$2 $$(GhcProfiled
)" "dph YES
"
461 # Ignore the package: These packages need TH, which is incompatible
462 # with a profiled GHC
464 PACKAGES_STAGE2 += $1
467 $(eval $(call foreachLibrary,addExtraPackage))
470 # If we want to just install everything, then we want all the packages
471 SUPERSIZE_INSTALL_PACKAGES := $(addprefix libraries/,$(PACKAGES_STAGE1))
472 ifeq "$(Stage1Only
)" "NO
"
473 SUPERSIZE_INSTALL_PACKAGES += compiler
475 SUPERSIZE_INSTALL_PACKAGES += $(addprefix libraries/,$(PACKAGES_STAGE2))
478 ifeq "$(InstallExtraPackages
)" "NO
"
479 INSTALL_PACKAGES := $(REGULAR_INSTALL_PACKAGES)
480 ifeq "$(DYNAMIC_GHC_PROGRAMS
)" "YES
"
481 INSTALL_DYNLIBS := $(REGULAR_INSTALL_DYNLIBS)
484 INSTALL_PACKAGES := $(SUPERSIZE_INSTALL_PACKAGES)
489 # -------------------------------------------
490 # Dependencies between package-data.mk files
492 # We cannot run ghc-cabal to configure a package until we have
493 # configured and registered all of its dependencies. So the following
494 # hack forces all the configure steps to happen in exactly the following order:
496 # $(PACKAGES_STAGE1) ghc(stage2) $(PACKAGES_STAGE2)
498 # Ideally we should use the correct dependencies here to allow more
499 # parallelism, but we don't know the dependencies until we've
500 # generated the package-data.mk files.
502 libraries/$1/$2/package-data.mk : $$(fixed_pkg_prev)
503 fixed_pkg_prev:=libraries/$1/$2/package-data.mk
506 ifneq "$(BINDIST
)" "YES
"
508 $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
510 # the GHC package doesn't live in libraries/, so we add its dependency manually:
511 compiler/stage2/package-data.mk: $(fixed_pkg_prev)
512 fixed_pkg_prev:=compiler/stage2/package-data.mk
514 # and continue with PACKAGES_STAGE2, which depend on GHC:
515 $(foreach pkg,$(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
517 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
518 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
519 # haddock depends on ghc and some libraries, but depending on GHC's
520 # package-data.mk is sufficient, as that in turn depends on all the
522 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
523 utils/ghc-pwd/dist-install/package-data.mk: compiler/stage2/package-data.mk
524 utils/ghc-cabal/dist-install/package-data.mk: compiler/stage2/package-data.mk
526 utils/ghctags/dist-install/package-data.mk: compiler/stage2/package-data.mk
527 utils/dll-split/dist-install/package-data.mk: compiler/stage2/package-data.mk
528 utils/hpc/dist-install/package-data.mk: compiler/stage2/package-data.mk
529 utils/ghc-pkg/dist-install/package-data.mk: compiler/stage2/package-data.mk
530 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
531 utils/compare_sizes/dist-install/package-data.mk: compiler/stage2/package-data.mk
532 utils/runghc/dist-install/package-data.mk: compiler/stage2/package-data.mk
533 utils/mkUserGuidePart/dist/package-data.mk: compiler/stage2/package-data.mk
535 # add the final package.conf dependency: ghc-prim depends on RTS
536 libraries/ghc-prim/dist-install/package-data.mk : rts/dist/package.conf.inplace
539 # --------------------------------
540 # Misc package-related settings
542 # Run Haddock for the packages that will be installed. We need to handle
543 # compiler specially due to the different dist directory name.
544 $(foreach p,$(INSTALL_PACKAGES),$(eval $p_dist-install_DO_HADDOCK = YES))
545 compiler_stage2_DO_HADDOCK = YES
547 BOOT_PKG_CONSTRAINTS := \
548 $(foreach d,$(PACKAGES_STAGE0),\
549 $(foreach p,$(basename $(notdir $(wildcard libraries/$d/*.cabal))),\
550 --constraint "$p == $(shell grep
-i
"^Version:" libraries
/$d/$p.cabal | sed
"s/[^0-9.]//g")"))
552 # The actual .a and .so/.dll files: needed for dependencies.
553 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_v_LIB))
554 ifeq "$(BuildSharedLibs
)" "YES
"
555 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_dyn_LIB))
557 BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB))
559 # ----------------------------------------
560 # Special magic for the ghc-prim package
562 # We want the ghc-prim package to include the GHC.Prim module when it
563 # is registered, but not when it is built, because GHC.Prim is not a
564 # real source module, it is built-in to GHC. The old build system did
565 # this using Setup.hs, but we can't do that here, so we have a flag to
566 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
567 # remains compatible with the old build system for the time being).
568 # GHC.Prim module in the ghc-prim package with a flag:
570 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
572 # And then we strip it out again before building the package:
573 define libraries/ghc-prim_PACKAGE_MAGIC
574 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
577 PRIMOPS_TXT_STAGE1 = compiler/stage1/build/primops.txt
579 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
580 "$(genprimopcode_INPLACE
)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
582 # Required so that Haddock documents the primops.
583 libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
585 # ----------------------------------------
586 # Special magic for the integer package
588 ifneq "$(CLEANING
)" "YES
"
589 ifeq "$(INTEGER_LIBRARY
)" "integer-gmp
"
590 libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
591 else ifeq "$(INTEGER_LIBRARY
)" "integer-simple
"
592 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
594 $(error Unknown integer library: $(INTEGER_LIBRARY))
598 # -----------------------------------------------------------------------------
599 # Include build instructions from all subdirs
601 ifneq "$(BINDIST
)" "YES
"
602 BUILD_DIRS += utils/mkdirhier
605 ifeq "$(Windows_Host
)" "YES
"
606 BUILD_DIRS += utils/touchy
609 BUILD_DIRS += utils/unlit
610 BUILD_DIRS += utils/hp2ps
612 ifneq "$(GhcUnregisterised
)" "YES
"
613 BUILD_DIRS += driver/split
616 ifneq "$(BINDIST
)" "YES
"
617 BUILD_DIRS += utils/genprimopcode
621 BUILD_DIRS += driver/ghci
622 BUILD_DIRS += driver/ghc
623 BUILD_DIRS += driver/haddock
625 BUILD_DIRS += utils/deriveConstants
626 BUILD_DIRS += includes
629 ifneq "$(BINDIST
)" "YES
"
630 BUILD_DIRS += bindisttest
631 BUILD_DIRS += utils/genapply
634 ifneq "$(CLEANING
)" "YES
"
635 # These are deliberately in reverse order, so as to ensure that
636 # there is no need to have them in dependency order. That's important
637 # because it's tricky to ensure that they are in dependency order when
638 # cross-compiling, as some packages may only be in PACKAGES_STAGE0
639 # or PACKAGES_STAGE1.
640 BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE2))
641 BUILD_DIRS += $(patsubst %, libraries/%, $(PACKAGES_STAGE1))
642 BUILD_DIRS += $(patsubst %, libraries/%, $(filter-out $(PACKAGES_STAGE1),$(PACKAGES_STAGE0)))
643 BUILD_DIRS += $(wildcard libraries/dph)
647 ifeq "$(INTEGER_LIBRARY
)" "integer-gmp
"
648 BUILD_DIRS += libraries/integer-gmp/gmp
649 BUILD_DIRS += libraries/integer-gmp/mkGmpDerivedConstants
650 else ifneq "$(findstring clean,$(MAKECMDGOALS
))" ""
651 BUILD_DIRS += libraries/integer-gmp/gmp
652 BUILD_DIRS += libraries/integer-gmp/mkGmpDerivedConstants
655 BUILD_DIRS += utils/haddock
656 BUILD_DIRS += utils/haddock/doc
657 BUILD_DIRS += compiler
658 BUILD_DIRS += utils/hsc2hs
659 BUILD_DIRS += utils/ghc-pkg
660 BUILD_DIRS += utils/testremove
661 ifeq "$(Stage1Only
)" "NO
"
662 BUILD_DIRS += utils/ghctags
664 BUILD_DIRS += utils/dll-split
665 BUILD_DIRS += utils/ghc-pwd
666 BUILD_DIRS += utils/ghc-cabal
667 BUILD_DIRS += utils/hpc
668 BUILD_DIRS += utils/runghc
671 ifneq "$(BINDIST
)" "YES
"
672 ifneq "$(CrossCompiling
)-$(phase
)" "YES-final
"
673 BUILD_DIRS += utils/mkUserGuidePart
677 BUILD_DIRS += docs/users_guide
678 BUILD_DIRS += docs/man
679 BUILD_DIRS += utils/count_lines
680 BUILD_DIRS += utils/compare_sizes
682 # ----------------------------------------------
683 # Actually include all the sub-ghc.mk's
685 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
687 # A useful pseudo-target (must be after the include above, because it needs
688 # the value of things like $(libraries/base_dist-install_v_LIB).
690 stage1_libs : $(ALL_STAGE1_LIBS)
692 # ----------------------------------------------
693 # Per-package compiler flags
695 # If you want to add per-package compiler flags, this
696 # is the place to do it. Do it like this for package <pkg>
698 # libraries/<pkg>_dist-boot_HC_OPTS += -Wwarn
699 # libraries/<pkg>_dist-install_HC_OPTS += -Wwarn
701 # Add $(GhcLibHcOpts) to all package builds
702 $(foreach pkg,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
704 # Add $(GhcBootLibHcOpts) to all stage0 package builds
705 $(foreach pkg,$(PACKAGES_STAGE0),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
707 # -----------------------------------------------------------------------------
708 # Bootstrapping libraries
710 # We need to build a few libraries with the installed GHC, since GHC itself
711 # and some of the tools depend on them:
713 ifneq "$(BINDIST
)" "YES
"
715 ifneq "$(BOOTSTRAPPING_CONF
)" ""
716 ifeq "$(wildcard $(BOOTSTRAPPING_CONF
))" ""
717 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
721 $(eval $(call clean-target,root,bootstrapping_conf,$(BOOTSTRAPPING_CONF)))
723 # register the boot packages in strict sequence, because running
724 # multiple ghc-pkgs in parallel doesn't work (registrations may get
727 $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
728 utils/ghc-pkg/dist/package-data.mk: $(fixed_pkg_prev)
729 compiler/stage1/package-data.mk: $(fixed_pkg_prev)
732 ifneq "$(BINDIST
)" "YES
"
733 # Make sure we have all the GHCi libs by the time we've built
734 # ghc-stage2. DPH includes a bit of Template Haskell which needs the
735 # GHCi libs, and we don't have a better way to express that dependency.
737 GHCI_LIBS = $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_GHCI_LIB)) \
738 $(compiler_stage2_GHCI_LIB)
740 ifeq "$(UseArchivesForGhci
)" "NO
"
741 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(GHCI_LIBS)
744 ifeq "$(UseArchivesForGhci
)" "YES
"
750 # Deps for TH uses in libraries
751 $(foreach way, $(GhcLibWays),$(eval \
752 libraries/vector/dist-install/build/Data/Vector/Fusion/Stream/Monadic.$($(way)_osuf): \
753 $(libraries/primitive_dist-install_$(GHCI_lib_way)_LIB) \
757 # -----------------------------------------------
758 # Haddock-related bits
760 # Build the Haddock contents and index
761 ifeq "$(HADDOCK_DOCS
)" "YES
"
762 libraries/dist-haddock/index.html: $(haddock_INPLACE) $(ALL_HADDOCK_FILES)
763 cd libraries && sh gen_contents_index --intree
764 ifeq "$(phase
)" "final
"
765 $(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
767 INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
770 # -----------------------------------------------------------------------------
771 # Creating a local mingw copy on Windows
773 ifeq "$(Windows_Host
)" "YES
"
775 install : install_mingw
776 .PHONY: install_mingw
777 install_mingw : $(INPLACE_MINGW)
778 "$(CP
)" -Rp $(INPLACE_MINGW) $(prefix)
780 install : install_perl
782 install_perl : $(INPLACE_PERL)
783 "$(CP
)" -Rp $(INPLACE_PERL) $(prefix)
787 ifneq "$(BINDIST
)" "YES
"
788 $(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \
789 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
792 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
793 $(PRIMOPS_TXT_STAGE1) $$(genprimopcode_INPLACE) \
795 "$(genprimopcode_INPLACE
)" --make-haskell-source < $< > $@
803 # -----------------------------------------------------------------------------
806 install: install_libs install_packages install_libexecs \
807 install_bins install_topdirs
808 ifeq "$(HADDOCK_DOCS
)" "YES
"
809 install: install_docs
813 # $1 = libraries to install
814 # $2 = directory to install to
815 $(call INSTALL_DIR,$2)
819 $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,$2); \
820 $(RANLIB_CMD) $2/`basename $$i` ;; \
822 $(call INSTALL_PROGRAM,$(INSTALL_OPTS),$$i,$2) ; \
823 $(STRIP_CMD) $2/`basename $$i` ;; \
825 $(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,$2) ;; \
827 $(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,$2);; \
829 $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,$2); \
834 install_bins: $(INSTALL_BINS)
835 $(call INSTALL_DIR,"$(DESTDIR
)$(bindir)")
836 for i in $(INSTALL_BINS); do \
837 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR
)$(bindir)") ; \
840 install_libs: $(INSTALL_LIBS)
841 $(call installLibsTo, $(INSTALL_LIBS), "$(DESTDIR
)$(ghclibdir
)")
843 install_libexecs: $(INSTALL_LIBEXECS)
844 ifeq "$(INSTALL_LIBEXECS
)" ""
847 $(call INSTALL_DIR,"$(DESTDIR
)$(ghclibexecdir
)/bin
")
848 for i in $(INSTALL_LIBEXECS); do \
849 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR
)$(ghclibexecdir
)/bin
"); \
851 # We rename ghc-stage2, so that the right program name is used in error
853 "$(MV
)" "$(DESTDIR
)$(ghclibexecdir
)/bin
/ghc-stage
$(INSTALL_GHC_STAGE
)" "$(DESTDIR
)$(ghclibexecdir
)/bin
/ghc
"
856 install_topdirs: $(INSTALL_TOPDIRS)
857 $(call INSTALL_DIR,"$(DESTDIR
)$(topdir
)")
858 for i in $(INSTALL_TOPDIRS); do \
859 $(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR
)$(topdir
)"); \
862 install_docs: $(INSTALL_DOCS)
863 $(call INSTALL_DIR,"$(DESTDIR
)$(docdir
)")
864 ifneq "$(INSTALL_DOCS
)" ""
865 for i in $(INSTALL_DOCS); do \
866 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i,"$(DESTDIR
)$(docdir
)"); \
869 $(call INSTALL_DIR,"$(DESTDIR
)$(docdir
)/html
")
870 $(call INSTALL_DOC,$(INSTALL_OPTS),docs/index.html,"$(DESTDIR
)$(docdir
)/html
")
871 ifneq "$(INSTALL_LIBRARY_DOCS
)" ""
872 $(call INSTALL_DIR,"$(DESTDIR
)$(docdir
)/html
/libraries
")
873 for i in $(INSTALL_LIBRARY_DOCS); do \
874 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i,"$(DESTDIR
)$(docdir
)/html
/libraries
/"); \
876 $(call INSTALL_DATA,$(INSTALL_OPTS),libraries/prologue.txt,"$(DESTDIR
)$(docdir
)/html
/libraries
/")
877 $(call INSTALL_SCRIPT,$(INSTALL_OPTS),libraries/gen_contents_index,"$(DESTDIR
)$(docdir
)/html
/libraries
/")
879 ifneq "$(INSTALL_HTML_DOC_DIRS
)" ""
880 for i in $(INSTALL_HTML_DOC_DIRS); do \
881 $(call INSTALL_DIR,"$(DESTDIR
)$(docdir
)/html
/`basename $$i`"); \
882 $(call INSTALL_DOC,$(INSTALL_OPTS),$$i/*,"$(DESTDIR
)$(docdir
)/html
/`basename $$i`"); \
886 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
888 # Install packages in the right order, so that ghc-pkg doesn't complain.
889 # Also, install ghc-pkg first.
890 ifeq "$(Windows_Host
)" "NO
"
891 INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc
892 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc-pkg
894 INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
895 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
898 # Set the INSTALL_DISTDIR_p for each package; compiler is special
899 $(foreach p,$(filter-out compiler,$(INSTALL_PACKAGES)),\
900 $(eval INSTALL_DISTDIR_$p = dist-install))
901 INSTALL_DISTDIR_compiler = stage2
903 # Now we can do the installation
904 install_packages: install_libexecs
905 install_packages: rts/dist/package.conf.install
906 $(call INSTALL_DIR,"$(DESTDIR
)$(topdir
)")
907 $(call removeTrees,"$(INSTALLED_PACKAGE_CONF
)")
908 $(call INSTALL_DIR,"$(INSTALLED_PACKAGE_CONF
)")
909 $(call INSTALL_DIR,"$(DESTDIR
)$(topdir
)/rts-1.0
")
910 $(call installLibsTo, $(RTS_INSTALL_LIBS), "$(DESTDIR
)$(topdir
)/rts-1.0
")
911 $(foreach p, $(INSTALL_DYNLIBS), \
912 $(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
)"))
913 $(foreach p, $(INSTALL_PACKAGES), \
914 $(call make-command, \
915 "$(ghc-cabal_INPLACE
)" copy \
916 $p $(INSTALL_DISTDIR_$p) \
921 '$(docdir)/html/libraries' \
923 "$(INSTALLED_GHC_PKG_REAL
)" --force --global-package-db "$(INSTALLED_PACKAGE_CONF
)" update rts/dist/package.conf.install
924 $(foreach p, $(INSTALL_PACKAGES), \
925 $(call make-command, \
926 "$(ghc-cabal_INPLACE
)" register \
927 $p $(INSTALL_DISTDIR_$p) \
928 "$(INSTALLED_GHC_REAL
)" \
929 "$(INSTALLED_GHC_PKG_REAL
)" \
930 "$(DESTDIR
)$(topdir
)" \
934 '$(docdir)/html/libraries' \
935 $(RelocatableBuild)))
936 # when we install the packages above, ghc-pkg obeys umask when creating
937 # the package.conf files, but for everything else we specify the
938 # permissions. We therefore now fix the permissions of package.cache.
939 # This means "sudo make
install" does the right thing even if it runs
941 for f in '$(INSTALLED_PACKAGE_CONF)'/*; do $(CREATE_DATA) "$$f"; done
943 # -----------------------------------------------------------------------------
944 # Binary distributions
946 ifneq "$(CLEANING
)" "YES
"
947 # This rule seems to hold some files open on Windows which prevents
948 # cleaning, perhaps due to the $(wildcard).
950 $(eval $(call bindist,.,\
954 configure config.sub config.guess install-sh \
959 $(INPLACE_BIN)/mkdirhier \
960 utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
961 utils/ghc-pwd/dist-install/build/tmp/ghc-pwd \
962 $(BINDIST_WRAPPERS) \
963 $(BINDIST_PERL_SOURCES) \
967 $(includes_H_FILES) \
968 $(includes_DERIVEDCONSTANTS) \
969 $(includes_GHCCONSTANTS) \
971 $(INSTALL_LIBEXECS) \
972 $(INSTALL_LIBEXEC_SCRIPTS) \
975 $(INSTALL_MANPAGES) \
977 $(INSTALL_LIBRARY_DOCS) \
978 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
980 compiler/stage2/doc \
981 $(wildcard libraries/*/dist-install/doc/) \
982 $(wildcard libraries/*/*/dist-install/doc/) \
983 $(filter-out settings,$(INSTALL_LIBS)) \
984 $(RTS_INSTALL_LIBS) \
985 $(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
989 libraries/gen_contents_index \
990 libraries/prologue.txt \
991 $(wildcard libraries/dph/LICENSE \
992 libraries/dph/ghc-packages \
993 libraries/dph/ghc-packages2 \
994 libraries/dph/ghc-stage2-package) \
997 # mk/project.mk gets an absolute path, so we manually include it in
998 # the bindist with a relative path
1000 BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
1002 unix-binary-dist-prep:
1003 $(call removeTrees,bindistprep/)
1004 "$(MKDIRHIER
)" $(BIN_DIST_PREP_DIR)
1005 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
1006 echo "HADDOCK_DOCS
= $(HADDOCK_DOCS
)" >> $(BIN_DIST_MK)
1007 echo "BUILD_DOCBOOK_HTML
= $(BUILD_DOCBOOK_HTML
)" >> $(BIN_DIST_MK)
1008 echo "BUILD_DOCBOOK_PS
= $(BUILD_DOCBOOK_PS
)" >> $(BIN_DIST_MK)
1009 echo "BUILD_DOCBOOK_PDF
= $(BUILD_DOCBOOK_PDF
)" >> $(BIN_DIST_MK)
1010 echo "BUILD_MAN
= $(BUILD_MAN
)" >> $(BIN_DIST_MK)
1011 echo "override ghc-cabal_INPLACE
= utils
/ghc-cabal
/dist-install
/build
/tmp
/ghc-cabal-bindist
" >> $(BIN_DIST_MK)
1012 echo "UseSystemLibFFI
= $(UseSystemLibFFI
)" >> $(BIN_DIST_MK)
1013 cd $(BIN_DIST_PREP_DIR) && autoreconf
1014 $(call removeFiles,$(BIN_DIST_PREP_TAR))
1015 # h means "follow symlinks
", e.g. if aclocal.m4 is a symlink to a source
1016 # tree then we want to include the real file, not a symlink to it
1017 cd bindistprep && "$(TAR_CMD
)" hcf - -T ../bindist-list | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
1019 windows-binary-dist-prep:
1020 $(call removeTrees,bindistprep/)
1021 $(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
1022 cd bindistprep && "$(TAR_CMD
)" cf - $(BIN_DIST_NAME) | bzip2 -c > ../$(BIN_DIST_PREP_TAR_BZ2)
1024 # tryTimes tries to run its third argument multiple times, until it
1025 # succeeds. Don't call it directly; call try10Times instead.
1026 # The first and second argument to tryTimes are lists of values.
1027 # The length of the first argument is the number of times we have
1028 # already tried. The length of the second argument is the number more
1029 # times we will try.
1030 tryTimes = $(if $2, \
1031 { echo 'Try $(words x $1): $3' ; $3 ; } || \
1032 $(call tryTimes,x $1,$(wordlist 2,$(words $2),$2),$3), \
1035 # Try to run the argument 10 times. If all 10 fail, fail.
1036 try10Times = $(call tryTimes,,x x x x x x x x x x,$1) { echo Failed; false; }
1038 .PHONY: publish-binary-dist
1039 publish-binary-dist:
1040 $(call try10Times,$(PublishCp) $(BIN_DIST_TAR_BZ2) $(PublishLocation)/dist)
1042 ifeq "$(mingw32_TARGET_OS
)" "1"
1043 DOCDIR_TO_PUBLISH = $(BIN_DIST_INST_DIR)/doc
1045 DOCDIR_TO_PUBLISH = $(BIN_DIST_INST_DIR)/share/doc/ghc
1048 .PHONY: publish-docs
1050 $(call try10Times,$(PublishCp) -r $(DOCDIR_TO_PUBLISH)/* $(PublishLocation)/docs)
1052 # -----------------------------------------------------------------------------
1053 # Source distributions
1061 # A source dist is built from a complete build tree, because we
1062 # require some extra files not contained in a git checkout: the
1063 # output from Happy and Alex, for example.
1065 # The steps performed by 'make dist' are as follows:
1066 # - create a complete link-tree of the current build tree in /tmp
1067 # - run 'make distclean' on that tree
1068 # - remove a bunch of other files that we know shouldn't be in the dist
1069 # - tar up first the extralibs package, then the main source package
1072 # Directory in which we're going to build the src dist
1074 SRC_DIST_ROOT = sdistprep
1075 SRC_DIST_BASE_NAME = ghc-$(ProjectVersion)
1077 SRC_DIST_GHC_NAME = ghc-$(ProjectVersion)-src
1078 SRC_DIST_GHC_ROOT = $(SRC_DIST_ROOT)/ghc
1079 SRC_DIST_GHC_DIR = $(SRC_DIST_GHC_ROOT)/$(SRC_DIST_BASE_NAME)
1080 SRC_DIST_GHC_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_GHC_NAME).tar.bz2
1082 SRC_DIST_WINDOWS_TARBALLS_NAME = ghc-$(ProjectVersion)-windows-extra-src
1083 SRC_DIST_WINDOWS_TARBALLS_ROOT = $(SRC_DIST_ROOT)/windows-tarballs
1084 SRC_DIST_WINDOWS_TARBALLS_DIR = $(SRC_DIST_WINDOWS_TARBALLS_ROOT)/$(SRC_DIST_BASE_NAME)
1085 SRC_DIST_WINDOWS_TARBALLS_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_WINDOWS_TARBALLS_NAME).tar.bz2
1087 SRC_DIST_TESTSUITE_NAME = ghc-$(ProjectVersion)-testsuite
1088 SRC_DIST_TESTSUITE_ROOT = $(SRC_DIST_ROOT)/testsuite-ghc
1089 SRC_DIST_TESTSUITE_DIR = $(SRC_DIST_TESTSUITE_ROOT)/$(SRC_DIST_BASE_NAME)
1090 SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME).tar.bz2
1093 # Files to include in source distributions
1095 SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \
1096 utils docs rts compiler ghc driver libraries libffi-tarballs
1097 SRC_DIST_GHC_FILES += \
1098 configure.ac config.guess config.sub configure \
1099 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
1100 settings.in VERSION \
1101 boot packages ghc.mk
1104 echo $(ProjectVersion) >VERSION
1109 # $(call sdist_ghc_file,compiler,stage2,cmm,Foo/Bar,CmmLex,x)
1110 # to copy the generated file that replaces compiler/cmm/Foo/Bar/CmmLex.x, where
1111 # "stage2
" is the dist dir.
1112 define sdist_ghc_file
1113 "$(CP
)" $1/$2/build/$4/$5.hs $(SRC_DIST_GHC_DIR)/$1/$3/$4
1114 mv $(SRC_DIST_GHC_DIR)/$1/$3/$4/$5.$6 $(SRC_DIST_GHC_DIR)/$1/$3/$4/$5.$6.source
1117 .PHONY: sdist-ghc-prep
1119 $(call removeTrees,$(SRC_DIST_GHC_ROOT))
1120 $(call removeFiles,$(SRC_DIST_GHC_TARBALL))
1121 -mkdir $(SRC_DIST_ROOT)
1122 mkdir $(SRC_DIST_GHC_ROOT)
1123 mkdir $(SRC_DIST_GHC_DIR)
1124 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_DIRS); do mkdir $$i; ( cd $$i && lndir $(TOP)/$$i ); done
1125 cd $(SRC_DIST_GHC_DIR) && for i in $(SRC_DIST_GHC_FILES); do $(LN_S) $(TOP)/$$i .; done
1126 cd $(SRC_DIST_GHC_DIR) && $(MAKE) distclean
1127 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/tarballs/)
1128 $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/stamp/)
1129 $(call removeTrees,$(SRC_DIST_GHC_DIR)/compiler/stage[123])
1130 $(call removeFiles,$(SRC_DIST_GHC_DIR)/mk/build.mk)
1131 $(call sdist_ghc_file,compiler,stage2,cmm,,CmmLex,x)
1132 $(call sdist_ghc_file,compiler,stage2,cmm,,CmmParse,y)
1133 $(call sdist_ghc_file,compiler,stage2,parser,,Lexer,x)
1134 $(call sdist_ghc_file,compiler,stage2,parser,,Parser,y.pp)
1135 $(call sdist_ghc_file,compiler,stage2,parser,,ParserCore,y)
1136 $(call sdist_ghc_file,utils/hpc,dist-install,,,HpcParser,y)
1137 $(call sdist_ghc_file,utils/genprimopcode,dist,,,Lexer,x)
1138 $(call sdist_ghc_file,utils/genprimopcode,dist,,,Parser,y)
1139 $(call sdist_ghc_file,utils/haddock,dist,src,Haddock,Lex,x)
1140 $(call sdist_ghc_file,utils/haddock,dist,src,Haddock,Parse,y)
1141 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)
1143 .PHONY
: sdist-windows-tarballs-prep
1144 sdist-windows-tarballs-prep
:
1145 $(call removeTrees
,$(SRC_DIST_WINDOWS_TARBALLS_ROOT
))
1146 $(call removeFiles
,$(SRC_DIST_WINDOWS_TARBALLS_TARBALL
))
1147 -mkdir
$(SRC_DIST_ROOT
)
1148 mkdir
$(SRC_DIST_WINDOWS_TARBALLS_ROOT
)
1149 mkdir
$(SRC_DIST_WINDOWS_TARBALLS_DIR
)
1150 mkdir
$(SRC_DIST_WINDOWS_TARBALLS_DIR
)/ghc-tarballs
1151 cd
$(SRC_DIST_WINDOWS_TARBALLS_DIR
)/ghc-tarballs
&& lndir
$(TOP
)/ghc-tarballs
1152 $(call removeTrees
,$(SRC_DIST_WINDOWS_TARBALLS_DIR
)/ghc-tarballs
/.git
)
1154 .PHONY
: sdist-testsuite-prep
1155 sdist-testsuite-prep
:
1156 $(call removeTrees
,$(SRC_DIST_TESTSUITE_ROOT
))
1157 $(call removeFiles
,$(SRC_DIST_TESTSUITE_TARBALL
))
1158 -mkdir
$(SRC_DIST_ROOT
)
1159 mkdir
$(SRC_DIST_TESTSUITE_ROOT
)
1160 mkdir
$(SRC_DIST_TESTSUITE_DIR
)
1161 mkdir
$(SRC_DIST_TESTSUITE_DIR
)/testsuite
1162 cd
$(SRC_DIST_TESTSUITE_DIR
)/testsuite
&& lndir
$(TOP
)/testsuite
1163 $(call removeTrees
,$(SRC_DIST_TESTSUITE_DIR
)/testsuite
/.git
)
1166 sdist
: sdist-ghc-prep sdist-windows-tarballs-prep sdist-testsuite-prep
1167 cd
$(SRC_DIST_GHC_ROOT
) && "$(TAR_CMD)" chf
- $(SRC_DIST_BASE_NAME
) 2> src_ghc_log | bzip2
> $(TOP
)/$(SRC_DIST_GHC_TARBALL
)
1168 cd
$(SRC_DIST_WINDOWS_TARBALLS_ROOT
) && "$(TAR_CMD)" chf
- $(SRC_DIST_BASE_NAME
) 2> windows_extra_src_ghc_log | bzip2
> $(TOP
)/$(SRC_DIST_WINDOWS_TARBALLS_TARBALL
)
1169 cd
$(SRC_DIST_TESTSUITE_ROOT
) && "$(TAR_CMD)" chf
- $(SRC_DIST_BASE_NAME
) 2> testsuite_log | bzip2
> $(TOP
)/$(SRC_DIST_TESTSUITE_TARBALL
)
1171 sdist-manifest
: $(SRC_DIST_GHC_TARBALL
)
1172 tar tjf
$(SRC_DIST_GHC_TARBALL
) | sed
"s|^ghc-$(ProjectVersion)/||" |
sort >sdist-manifest
1174 # Upload the distribution(s)
1175 # Retrying is to work around buggy firewalls that corrupt large file transfers
1177 ifneq "$(PublishLocation)" ""
1179 $(call try10Times
,$(PublishCp
) $(SRC_DIST_GHC_TARBALL
) $(PublishLocation
)/dist)
1180 $(call try10Times
,$(PublishCp
) $(SRC_DIST_TESTSUITE_TARBALL
) $(PublishLocation
)/dist)
1183 # -----------------------------------------------------------------------------
1184 # sdisting libraries
1186 # Use manually, with e.g.:
1187 # make sdist_directory
1190 inplace
/bin
/ghc-cabal sdist libraries
/$* dist-install
1192 # -----------------------------------------------------------------------------
1197 CLEAN_FILES
+= libraries
/bootstrapping.conf
1198 CLEAN_FILES
+= libraries
/integer-gmp
/cbits
/GmpDerivedConstants.h
1200 # These are no longer generated, but we still clean them for a while
1201 # as they may still be in old GHC trees:
1202 CLEAN_FILES
+= includes
/GHCConstants.h
1203 CLEAN_FILES
+= includes
/DerivedConstants.h
1204 CLEAN_FILES
+= includes
/ghcautoconf.h
1205 CLEAN_FILES
+= includes
/ghcplatform.h
1206 CLEAN_FILES
+= utils
/ghc-pkg
/Version.hs
1207 CLEAN_FILES
+= compiler
/parser
/Parser.y
1208 CLEAN_FILES
+= compiler
/prelude
/primops.txt
1209 CLEAN_FILES
+= $(wildcard compiler
/primop
*incl
)
1211 clean : clean_files clean_libraries
1215 $(call removeFiles
,$(CLEAN_FILES
))
1217 .PHONY
: clean_libraries
1218 clean_libraries
: $(patsubst %,clean_libraries
/%_dist-install
,$(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
))
1219 clean_libraries
: $(patsubst %,clean_libraries
/%_dist-boot
,$(PACKAGES_STAGE0
))
1222 $(call removeTrees
,$(patsubst %, libraries
/%/dist, $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
)))
1223 $(call removeFiles
,$(wildcard $(patsubst %.in
, %, $(wildcard $(patsubst %, libraries
/%/*.buildinfo.in
, $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
))))))
1224 $(call removeFiles
,$(patsubst %, libraries
/%/config.log
, $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
)))
1225 $(call removeFiles
,$(patsubst %, libraries
/%/config.status
, $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
)))
1226 $(call removeFiles
,$(wildcard $(patsubst %, libraries
/%/include/Hs
*Config.h
, $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
))))
1228 # We have to define a clean target for each library manually, because the
1229 # libraries/*/ghc.mk files are not included when we're cleaning.
1230 ifeq "$(CLEANING)" "YES"
1231 $(foreach lib
,$(PACKAGES_STAGE0
),\
1232 $(eval
$(call clean-target
,libraries
/$(lib
),dist-boot
,libraries
/$(lib
)/dist-boot
)))
1233 $(foreach lib
,$(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
),\
1234 $(eval
$(call clean-target
,libraries
/$(lib
),dist-install
,libraries
/$(lib
)/dist-install
)))
1237 clean : clean_haddock_index
1238 .PHONY
: clean_haddock_index
1239 clean_haddock_index
:
1240 $(call removeTrees
,libraries
/dist-haddock
)
1242 clean : clean_bindistprep
1243 .PHONY
: clean_bindistprep
1245 $(call removeTrees
,bindistprep
/)
1248 # Clean the files that ./validate creates.
1249 $(call removeFiles
,mk
/are-validating.mk
)
1251 # Clean the files that we ask ./configure to create.
1252 $(call removeFiles
,mk
/config.mk
)
1253 $(call removeFiles
,mk
/install.mk
)
1254 $(call removeFiles
,mk
/project.mk
)
1255 $(call removeFiles
,compiler
/ghc.cabal
)
1256 $(call removeFiles
,ghc
/ghc-bin.cabal
)
1257 $(call removeFiles
,utils
/runghc
/runghc.cabal
)
1258 $(call removeFiles
,settings
)
1259 $(call removeFiles
,docs
/users_guide
/ug-book.xml
)
1260 $(call removeFiles
,docs
/users_guide
/ug-ent.xml
)
1261 $(call removeFiles
,docs
/index.html
)
1262 $(call removeFiles
,libraries
/prologue.txt
)
1263 $(call removeFiles
,distrib
/configure.ac
)
1265 # ./configure also makes these.
1266 $(call removeFiles
,mk
/config.h
)
1268 # Internal files generated by ./configure for itself.
1269 $(call removeFiles
,config.cache config.status config.log
)
1271 # ./configure build ghc-pwd in utils/ghc-pwd/dist-boot, so clean it up.
1272 $(call removeTrees
,utils
/ghc-pwd
/dist-boot
)
1274 # The root Makefile makes .old versions of some files that configure
1275 # generates, so we clean those too.
1276 $(call removeFiles
,mk
/config.mk.old
)
1277 $(call removeFiles
,mk
/project.mk.old
)
1278 $(call removeFiles
,compiler
/ghc.cabal.old
)
1280 # Clean the *Config.h files generated by library configure scripts
1281 $(call removeFiles
,libraries
/base
/include/HsBaseConfig.h
)
1282 $(call removeFiles
,libraries
/base
/include/EventConfig.h
)
1283 $(call removeFiles
,libraries
/directory
/include/HsDirectoryConfig.h
)
1284 $(call removeFiles
,libraries
/process
/include/HsProcessConfig.h
)
1285 $(call removeFiles
,libraries
/unix
/include/HsUnixConfig.h
)
1286 $(call removeFiles
,libraries
/time
/include/HsTimeConfig.h
)
1287 $(call removeFiles
,libraries
/old-time
/include/HsTimeConfig.h
)
1289 # The library configure scripts also like creating autom4te.cache
1290 # directories, so clean them all up.
1291 $(call removeTrees
,$(patsubst %, libraries
/%/autom4te.cache
, $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
)))
1293 # We make these when making or testing bindists
1294 $(call removeFiles
,bindist-list
)
1295 $(call removeTrees
,bindisttest
/a
)
1297 # Not sure why this is being cleaned here.
1298 $(call removeTrees
,includes
/dist-derivedconstants
)
1300 # Finally, clean the inplace tree.
1301 $(call removeTrees
,inplace
)
1303 maintainer-clean
: distclean
1304 $(call removeFiles
,configure mk
/config.h.in
)
1305 $(call removeTrees
,autom4te.cache
$(wildcard libraries
/*/autom4te.cache
))
1306 $(call removeFiles
,$(patsubst %, libraries
/%/GNUmakefile
, \
1307 $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
)))
1308 $(call removeFiles
,$(patsubst %, libraries
/%/ghc.mk
, $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
)))
1309 $(call removeFiles
,$(patsubst %, libraries
/%/configure
, \
1310 $(PACKAGES_STAGE1
) $(PACKAGES_STAGE2
)))
1311 $(call removeFiles
,libraries
/base
/include/HsBaseConfig.h.in
)
1312 $(call removeFiles
,libraries
/directory
/include/HsDirectoryConfig.h.in
)
1313 $(call removeFiles
,libraries
/process
/include/HsProcessConfig.h.in
)
1314 $(call removeFiles
,libraries
/unix
/include/HsUnixConfig.h.in
)
1315 $(call removeFiles
,libraries
/time
/include/HsTimeConfig.h.in
)
1316 $(call removeFiles
,libraries
/old-time
/include/HsTimeConfig.h.in
)
1318 .PHONY
: all_libraries
1320 .PHONY
: bootstrapping-files
1321 bootstrapping-files
: $(includes_H_CONFIG
)
1322 bootstrapping-files
: $(includes_DERIVEDCONSTANTS
)
1323 bootstrapping-files
: $(includes_GHCCONSTANTS
)
1324 bootstrapping-files
: $(libffi_HEADERS
)
1328 # -----------------------------------------------------------------------------
1330 ifeq "$(HADDOCK_DOCS)" "YES"
1331 BINDIST_HADDOCK_FLAG
= --with-haddock
="$(BINDIST_PREFIX)/bin/haddock"
1333 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
1334 BINDIST_LIBRARY_FLAGS
= --enable-shared
--disable-library-vanilla
1336 BINDIST_LIBRARY_FLAGS
= --enable-library-vanilla
--disable-shared
1338 BINDIST_LIBRARY_FLAGS
+= --disable-library-prof
1340 .PHONY
: validate_build_xhtml
1341 validate_build_xhtml
:
1342 cd libraries
/xhtml
&& "$(BINDIST_PREFIX)/bin/ghc" --make Setup
1343 cd libraries
/xhtml
&& .
/Setup configure
--with-ghc
="$(BINDIST_PREFIX)/bin/ghc" $(BINDIST_HADDOCK_FLAG
) $(BINDIST_LIBRARY_FLAGS
) --global
--builddir
=dist-bindist
--prefix="$(BINDIST_PREFIX)"
1344 cd libraries
/xhtml
&& .
/Setup build
--builddir
=dist-bindist
1345 ifeq "$(HADDOCK_DOCS)" "YES"
1346 cd libraries
/xhtml
&& .
/Setup haddock
--builddir
=dist-bindist
1348 cd libraries
/xhtml
&& .
/Setup
install --builddir
=dist-bindist
1349 cd libraries
/xhtml
&& .
/Setup
clean --builddir
=dist-bindist
1350 cd libraries
/xhtml
&& rm -f Setup Setup.exe Setup.hi Setup.o
1352 # -----------------------------------------------------------------------------
1353 # Numbered phase targets
1355 # In phase 1, we'll be building dependency files for most things
1356 # built by the bootstrapping compiler while make is 'include'ing
1357 # makefiles. But in order to build dependency files, we'll need to
1358 # build any automatically generated .hs files, which means that
1359 # we'll need to be able to build any tools that generate .hs files
1360 # etc. But in order to do that, we need to already know the
1361 # dependencies for those tools, so we build their dependency files
1363 .PHONY
: phase_0_builds
1364 # hsc2hs is needed, e.g. to make the .hs files for hpc.
1365 phase_0_builds
: $(utils
/hsc2hs_dist_depfile_haskell
)
1366 phase_0_builds
: $(utils
/hsc2hs_dist_depfile_c_asm
)
1367 # genprimopcode is needed to make the .hs-incl files that are in the
1369 phase_0_builds
: $(utils
/genprimopcode_dist_depfile_haskell
)
1370 phase_0_builds
: $(utils
/genprimopcode_dist_depfile_c_asm
)
1371 # deriveConstants is used to create header files included in the
1373 phase_0_builds
: $(utils
/deriveConstants_dist_depfile_haskell
)
1374 phase_0_builds
: $(utils
/deriveConstants_dist_depfile_c_asm
)
1376 .PHONY
: phase_1_builds
1377 phase_1_builds
: $(PACKAGE_DATA_MKS
)