root/ghc.mk

Revision 0f4925b6dfa40010bbf19e2824224b5a568d4f57, 43.7 KB (checked in by Ian Lynagh <igloo@…>, 9 days ago)

Use transformers directly, rather than using mtl

This means we no longer need mtl in a GHC tree.

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