1 # -----------------------------------------------------------------------------
3 # (c) 2009 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://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11 # -----------------------------------------------------------------------------
15 # * finish installation
16 # * create doc index and contents
17 # * Windows: should we have ghc-pkg-<version>?
18 # * should we be stripping things?
19 # * install libgmp.a, gmp.h
20 # * need to fix Cabal for new Windows layout, see
21 # Distribution/Simple/GHC.configureToolchain.
22 # * remove old Makefiles, add new stubs for building in subdirs
24 # * docs/docbook-cheat-sheet/Makefile
25 # * docs/ext-core/Makefile
27 # * docs/storage-mgmt/Makefile
29 # * rts/dotnet/Makefile
31 # * optionally install stage3?
32 # * add Makefiles for the rest of the utils/ programs that aren't built
33 # by default (need to exclude them from 'make all' too)
35 # Tickets we can now close, or fix and close:
37 # * 1693 make distclean
38 # * 3173 make install with DESTDIR
42 # * per-source-file dependencies instead of one .depend file?
43 # * eliminate undefined variables, and use --warn-undefined-variables?
44 # * perhaps we should make all the output dirs in the .depend rule, to
45 # avoid all these mkdirhier calls?
46 # * put outputs from different ways in different subdirs of distdir/build,
47 # then we don't have to use -osuf/-hisuf. We would have to install
48 # them in different places too, so we'd need ghc-pkg support for packages
50 # * make PACKAGES generated by configure or sh boot?
51 # * we should use a directory of package.conf files rather than a single
52 # file for the inplace package database, so that we can express
53 # dependencies more accurately. Otherwise it's possible to get into
54 # a state where the package database is out of date, and the build
55 # system doesn't know.
57 # Approximate build order.
59 # The actual build order is defined by dependencies, and the phase
60 # ordering used to ensure correct ordering of makefile-generation; see
61 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
63 # * With bootstrapping compiler:
64 # o Build utils/ghc-cabal
65 # o Build utils/ghc-pkg
66 # o Build utils/hsc2hs
68 # o configure, generate package-data.mk and inplace-pkg-info
69 # o register each package into inplace/lib/package.conf
71 # * With bootstrapping compiler:
72 # o Build libraries/{filepath,hpc,extensible-exceptions,Cabal}
73 # o Build compiler (stage 1)
77 # o Build utils/* (except haddock)
78 # o Build compiler (stage 2)
80 # o Build utils/haddock
81 # o Build compiler (stage 3) (optional)
86 .PHONY: default all haddock
90 # Just bring makefiles up to date:
91 .PHONY: just-makefiles
95 # -----------------------------------------------------------------------------
99 space=$(nothing) $(nothing)
102 # Cancel all suffix rules. Ideally we'd like to have 'make -r' turned on
103 # by default, because that disables all the implicit rules, but there doesn't
104 # seem to be a good way to do that. This turns off all the old-style suffix
105 # rules, which does half the job and speeds up make quite a bit:
108 # -----------------------------------------------------------------------------
110 # to see the effective value used for a Makefile variable, do
111 # make show VALUE=MY_VALUE
115 @echo '$(VALUE)="$($(VALUE))"'
117 # -----------------------------------------------------------------------------
118 # Include subsidiary build-system bits
122 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
124 ifeq "$(ProjectVersion)" ""
125 $(error Please run ./configure first)
129 # (Optional) build-specific configuration
130 include mk/custom-settings.mk
132 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
133 ifeq "$(GhcLibWays)" ""
134 $(error $$(GhcLibWays) is empty, it must contain at least one way)
138 # -----------------------------------------------------------------------------
139 # Macros for standard targets
141 include rules/all-target.mk
142 include rules/clean-target.mk
144 # -----------------------------------------------------------------------------
147 $(eval $(call clean-target,inplace,,inplace))
149 # -----------------------------------------------------------------------------
150 # Whether to build dependencies or not
152 # When we're just doing 'make clean' or 'make show', then we don't need
153 # to build dependencies.
155 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
156 NO_INCLUDE_DEPS = YES
157 NO_INCLUDE_PKGDATA = YES
159 ifneq "$(findstring bootstrapping-files,$(MAKECMDGOALS))" ""
160 NO_INCLUDE_DEPS = YES
161 NO_INCLUDE_PKGDATA = YES
163 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
164 NO_INCLUDE_DEPS = YES
165 # We want package-data.mk for show
168 # We don't haddock base3-compat, as it has the same package name as base
169 libraries/base3-compat_dist-install_DO_HADDOCK = NO
171 # We don't haddock the bootstrapping libraries
172 libraries/hpc_dist-boot_DO_HADDOCK = NO
173 libraries/Cabal_dist-boot_DO_HADDOCK = NO
174 libraries/extensible-exceptions_dist-boot_DO_HADDOCK = NO
175 libraries/filepath_dist-boot_DO_HADDOCK = NO
177 # -----------------------------------------------------------------------------
180 include rules/way-prelims.mk
182 $(foreach way,$(ALL_WAYS),\
183 $(eval $(call way-prelims,$(way))))
185 # -----------------------------------------------------------------------------
188 include rules/distdir-opts.mk
189 include rules/distdir-way-opts.mk
191 # -----------------------------------------------------------------------------
192 # Finding source files and object files
194 include rules/hs-sources.mk
195 include rules/c-sources.mk
196 include rules/includes-sources.mk
197 include rules/hs-objs.mk
198 include rules/c-objs.mk
199 include rules/cmm-objs.mk
201 # -----------------------------------------------------------------------------
204 # Suffix rules cause "make clean" to fail on Windows (trac #3233)
205 # so we don't make any when cleaning.
206 ifneq "$(CLEANING)" "YES"
208 include rules/hs-suffix-rules-srcdir.mk
209 include rules/hs-suffix-rules.mk
211 # -----------------------------------------------------------------------------
212 # Suffix rules for .hi files
214 include rules/hi-rule.mk
216 $(foreach way,$(ALL_WAYS),\
217 $(eval $(call hi-rule,$(way))))
219 #-----------------------------------------------------------------------------
220 # C-related suffix rules
222 include rules/c-suffix-rules.mk
224 #-----------------------------------------------------------------------------
225 # CMM-related suffix rules
227 include rules/cmm-suffix-rules.mk
231 # -----------------------------------------------------------------------------
232 # Building package-data.mk files from .cabal files
234 include rules/package-config.mk
236 # -----------------------------------------------------------------------------
237 # Building dependencies
239 include rules/build-dependencies.mk
241 # -----------------------------------------------------------------------------
242 # Build package-data.mk files
244 include rules/build-package-data.mk
246 # -----------------------------------------------------------------------------
247 # Build and install a program
249 include rules/build-prog.mk
250 include rules/shell-wrapper.mk
252 # -----------------------------------------------------------------------------
253 # Build a perl script
255 include rules/build-perl.mk
257 # -----------------------------------------------------------------------------
260 include rules/build-package.mk
261 include rules/build-package-way.mk
262 include rules/haddock.mk
264 # -----------------------------------------------------------------------------
265 # Registering hand-written package descriptions (used in libffi and rts)
267 include rules/manual-package-config.mk
269 # -----------------------------------------------------------------------------
272 include rules/docbook.mk
274 # -----------------------------------------------------------------------------
277 include rules/bindist.mk
279 # -----------------------------------------------------------------------------
282 define addPackage # args: $1 = package, $2 = condition
284 ifeq "$$(CLEANING)" "YES"
296 $(eval $(call addPackage,ghc-prim))
297 ifeq "$(CLEANING)" "YES"
298 $(eval $(call addPackage,integer-gmp))
299 $(eval $(call addPackage,integer-simple))
301 $(eval $(call addPackage,$(INTEGER_LIBRARY)))
303 $(eval $(call addPackage,base))
304 $(eval $(call addPackage,filepath))
305 $(eval $(call addPackage,array))
306 $(eval $(call addPackage,bytestring))
307 $(eval $(call addPackage,containers))
309 $(eval $(call addPackage,Win32,($$(Windows),YES)))
310 $(eval $(call addPackage,unix,($$(Windows),NO)))
312 $(eval $(call addPackage,old-locale))
313 $(eval $(call addPackage,old-time))
314 $(eval $(call addPackage,time))
315 $(eval $(call addPackage,directory))
316 $(eval $(call addPackage,process))
317 $(eval $(call addPackage,random))
318 $(eval $(call addPackage,extensible-exceptions))
319 $(eval $(call addPackage,haskell98))
320 $(eval $(call addPackage,hpc))
321 $(eval $(call addPackage,pretty))
322 $(eval $(call addPackage,syb))
323 $(eval $(call addPackage,template-haskell))
324 $(eval $(call addPackage,base3-compat))
325 $(eval $(call addPackage,Cabal))
326 $(eval $(call addPackage,mtl))
327 $(eval $(call addPackage,utf8-string))
329 $(eval $(call addPackage,terminfo,($$(Windows),NO)))
331 $(eval $(call addPackage,haskeline))
333 ifneq "$(BootingFromHc)" "YES"
336 dph/dph-prim-interface \
343 BOOT_PKGS = Cabal hpc extensible-exceptions
345 # The actual .a and .so/.dll files: needed for dependencies.
346 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_v_LIB))
347 ifeq "$(BuildSharedLibs)" "YES"
348 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_dyn_LIB))
350 BOOT_LIBS = $(foreach lib,$(BOOT_PKGS),$(libraries/$(lib)_dist-boot_v_LIB))
352 OTHER_LIBS = libffi/libHSffi$(v_libsuf) libffi/HSffi.o
353 ifeq "$(BuildSharedLibs)" "YES"
354 OTHER_LIBS += libffi/libHSffi$(dyn_libsuf)
357 # We cannot run ghc-cabal to configure a package until we have
358 # configured and registered all of its dependencies. So the following
359 # hack forces all the configure steps to happen in exactly the order
360 # given in the PACKAGES variable above. Ideally we should use the
361 # correct dependencies here to allow more parallelism, but we don't
362 # know the dependencies until we've generated the pacakge-data.mk
365 libraries/$1/$2/package-data.mk : $$(GHC_PKG_INPLACE) $$(if $$(fixed_pkg_prev),libraries/$$(fixed_pkg_prev)/$2/package-data.mk)
369 ifneq "$(BINDIST)" "YES"
371 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
373 # We assume that the stage2 compiler depends on all the libraries, so
374 # they all get added to the package database before we try to configure
376 compiler/stage2/package-data.mk: $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),libraries/$(pkg)/dist-install/package-data.mk)
377 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
378 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
379 # haddock depends on ghc and some libraries, but depending on GHC's
380 # package-data.mk is sufficient, as that in turn depends on all the
382 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
384 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
386 # add the final two package.conf dependencies: ghc-prim depends on RTS,
387 # and RTS depends on libffi.
388 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
389 rts/package.conf.inplace : libffi/package.conf.inplace
392 # -----------------------------------------------------------------------------
393 # Special magic for the ghc-prim package
395 # We want the ghc-prim package to include the GHC.Prim module when it
396 # is registered, but not when it is built, because GHC.Prim is not a
397 # real source module, it is built-in to GHC. The old build system did
398 # this using Setup.hs, but we can't do that here, so we have a flag to
399 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
400 # remains compatible with the old build system for the time being).
401 # GHC.Prim module in the ghc-prim package with a flag:
403 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
405 # And then we strip it out again before building the package:
406 define libraries/ghc-prim_PACKAGE_MAGIC
407 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
410 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
412 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
413 "$(MKDIRHIER)" $(dir $@)
414 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
416 libraries/ghc-prim/GHC/Prim.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
417 "$(GENPRIMOP_INPLACE)" --make-haskell-source <$(PRIMOPS_TXT) >$@
420 # -----------------------------------------------------------------------------
421 # Include build instructions from all subdirs
423 # For the rationale behind the build phases, see
424 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
426 # Setting foo_dist_DISABLE=YES means "in directory foo, for build
427 # "dist", just read the package-data.mk file, do not build anything".
429 # We carefully engineer things so that we can build the
430 # package-data.mk files early on: they depend only on a few tools also
431 # built early. Having got the package-data.mk files built, we can
432 # restart make with up-to-date information about all the packages
433 # (this is phase 0). The remaining problem is the .depend files:
435 # - .depend files in libraries need the stage 1 compiler to build
436 # - ghc/stage1/.depend needs compiler/stage1 built
437 # - compiler/stage1/.depend needs the bootstrap libs built
439 # GHC 6.11+ can build a .depend file without having built the
440 # dependencies of the package, but we can't rely on the bootstrapping
441 # compiler being able to do this, which is why we have to separate the
442 # three phases above.
444 # So this is the final ordering:
446 # Phase 0 : all package-data.mk files
447 # (requires ghc-cabal, ghc-pkg, mkdirhier, dummy-ghc etc.)
448 # Phase 1 : .depend files for bootstrap libs
450 # Phase 2 : compiler/stage1/.depend
451 # (requires bootstrap libs and genprimopcode)
452 # Phase 3 : ghc/stage1/.depend
453 # (requires compiler/stage1)
455 # The rest : libraries/*/dist-install, compiler/stage2, ghc/stage2
459 ifneq "$(BINDIST)" "YES"
461 $(GHC_MKDEPENDC_DIR) \
467 libraries/Cabal/doc \
471 ifneq "$(GhcUnregisterised)" "YES"
477 ifneq "$(BINDIST)" "YES"
490 ifneq "$(BINDIST)" "YES"
500 ifneq "$(CLEANING)" "YES"
502 $(patsubst %, libraries/%, $(PACKAGES) $(PACKAGES_STAGE2))
503 ifneq "$(BootingFromHc)" "YES"
509 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
510 BUILD_DIRS += libraries/integer-gmp/gmp
520 ifeq "$(Windows)" "YES"
525 # XXX libraries/% must come before any programs built with stage1, see
526 # Note [lib-depends].
529 $(foreach lib,$(BOOT_PKGS),$(eval \
530 libraries/$(lib)_dist-boot_DISABLE = YES))
533 ifneq "$(findstring $(phase),0 1)" ""
534 # We can build deps for compiler/stage1 in phase 2
535 compiler_stage1_DISABLE = YES
538 ifneq "$(findstring $(phase),0 1 2)" ""
539 ghc_stage1_DISABLE = YES
542 ifneq "$(CLEANING)" "YES"
543 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
544 libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
546 ifeq "$(INTEGER_LIBRARY)" "integer-simple"
547 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
549 $(error Unknown integer library: $(INTEGER_LIBRARY))
554 ifneq "$(findstring $(phase),0 1 2 3)" ""
555 # In phases 0-3, we disable stage2-3, the full libraries and haddock
556 utils/haddock_dist_DISABLE = YES
557 utils/runghc_dist_DISABLE = YES
558 utils/hpc_dist_DISABLE = YES
559 utils/hsc2hs_dist-install_DISABLE = YES
560 utils/ghc-pkg_dist-install_DISABLE = YES
561 compiler_stage2_DISABLE = YES
562 compiler_stage3_DISABLE = YES
563 ghc_stage2_DISABLE = YES
564 ghc_stage3_DISABLE = YES
565 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),$(eval \
566 libraries/$(lib)_dist-install_DISABLE = YES))
569 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
571 # We need -fno-warn-deprecated-flags to avoid failure with -Werror
572 GhcLibHcOpts += -fno-warn-deprecated-flags
573 ifeq "$(ghc_ge_609)" "YES"
574 GhcBootLibHcOpts += -fno-warn-deprecated-flags
577 # Add $(GhcLibHcOpts) to all library builds
578 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
580 # XXX Hack; remove this
581 $(foreach pkg,$(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += -Wwarn))
583 # XXX we configure packages with the bootstrapping compiler (for
584 # dependency reasons, see the phase ordering), which doesn't
585 # necessarily support all the extensions we need, and Cabal filters
586 # out the ones it thinks aren't supported.
587 libraries/base3-compat_dist-install_HC_OPTS += -XPackageImports
589 # A useful pseudo-target
591 stage1_libs : $(ALL_STAGE1_LIBS)
593 # -----------------------------------------------------------------------------
594 # Bootstrapping libraries
596 # We need to build a few libraries with the installed GHC, since GHC itself
597 # and some of the tools depend on them:
599 ifneq "$(BINDIST)" "YES"
601 ifneq "$(BOOTSTRAPPING_CONF)" ""
602 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
603 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
607 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
609 # These three libraries do not depend on each other, so we can build
612 $(eval $(call build-package,libraries/hpc,dist-boot,0))
613 $(eval $(call build-package,libraries/extensible-exceptions,dist-boot,0))
614 $(eval $(call build-package,libraries/Cabal,dist-boot,0))
616 # register the boot packages in strict sequence, because running
617 # multiple ghc-pkgs in parallel doesn't work (registrations may get
620 $(foreach pkg,$(BOOT_PKGS),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
622 compiler/stage1/package-data.mk : \
623 libraries/Cabal/dist-boot/package-data.mk \
624 libraries/hpc/dist-boot/package-data.mk \
625 libraries/extensible-exceptions/dist-boot/package-data.mk
627 # These are necessary because the bootstrapping compiler may not know
628 # about cross-package dependencies:
629 $(compiler_stage1_depfile) : $(BOOT_LIBS)
630 $(ghc_stage1_depfile) : $(compiler_stage1_v_LIB)
632 $(foreach pkg,$(BOOT_PKGS),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
636 # -----------------------------------------------------------------------------
637 # Creating a local mingw copy on Windows
639 ifeq "$(Windows)" "YES"
641 # directories don't work well as dependencies, hence a stamp file
642 $(INPLACE)/stamp-mingw : $(MKDIRHIER)
643 $(MKDIRHIER) $(INPLACE_MINGW)/bin
644 GCC=`type -p $(WhatGccIsCalled)`; \
645 GccDir=`dirname $$GCC`; \
646 "$(CP)" -p $$GccDir/{gcc.exe,ar.exe,as.exe,dlltool.exe,dllwrap.exe,windres.exe} $(INPLACE_MINGW)/bin; \
647 "$(CP)" -Rp $$GccDir/../include $(INPLACE_MINGW); \
648 "$(CP)" -Rp $$GccDir/../lib $(INPLACE_MINGW); \
649 "$(CP)" -Rp $$GccDir/../libexec $(INPLACE_MINGW); \
650 "$(CP)" -Rp $$GccDir/../mingw32 $(INPLACE_MINGW)
651 touch $(INPLACE)/stamp-mingw
653 install : install_mingw
654 .PHONY: install_mingw
655 install_mingw : $(INPLACE_MINGW)
656 "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
658 $(INPLACE_LIB)/perl.exe $(INPLACE_LIB)/perl56.dll :
659 "$(CP)" $(GhcDir)../{perl.exe,perl56.dll} $(INPLACE_LIB)
663 libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock: \
664 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs \
665 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs
667 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
668 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
669 "$(MKDIRHIER)" $(dir $@)
670 "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
672 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
673 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
674 "$(MKDIRHIER)" $(dir $@)
675 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers < $< > $@
677 # -----------------------------------------------------------------------------
680 install: install_packages install_libs install_libexecs install_headers \
681 install_libexec_scripts install_bins install_docs
683 install_bins: $(INSTALL_BINS)
684 $(INSTALL_DIR) $(DESTDIR)$(bindir)
685 for i in $(INSTALL_BINS); do \
686 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ; \
687 if test "$(darwin_TARGET_OS)" = "1"; then \
688 sh mk/fix_install_names.sh $(libdir) $(DESTDIR)$(bindir)/$$i ; \
692 install_libs: $(INSTALL_LIBS)
693 $(INSTALL_DIR) $(DESTDIR)$(libdir)
694 for i in $(INSTALL_LIBS); do \
697 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
698 $(RANLIB) $(DESTDIR)$(libdir)/`basename $$i` ;; \
700 $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
702 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
704 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
705 install_name_tool -id $(DESTDIR)$(libdir)/`basename $$i` $(DESTDIR)$(libdir)/`basename $$i` ;; \
707 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
711 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
712 "$(MKDIRHIER)" $(DESTDIR)$(libexecdir)
713 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
714 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libexecdir); \
717 install_libexecs: $(INSTALL_LIBEXECS)
718 "$(MKDIRHIER)" $(DESTDIR)$(libexecdir)
719 for i in $(INSTALL_LIBEXECS); do \
720 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(libexecdir); \
723 install_headers: $(INSTALL_HEADERS)
724 $(INSTALL_DIR) $(DESTDIR)$(headerdir)
725 for i in $(INSTALL_HEADERS); do \
726 $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
729 install_docs: $(INSTALL_HEADERS)
730 $(INSTALL_DIR) $(DESTDIR)$(docdir)
731 for i in $(INSTALL_DOCS); do \
732 $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir); \
734 $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html; \
735 for i in $(INSTALL_HTML_DOC_DIRS); do \
736 $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html/`basename $$i`; \
737 $(INSTALL_DOC) $(INSTALL_OPTS) $$i/* $(DESTDIR)$(docdir)/html/`basename $$i`; \
740 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(libdir)/package.conf
742 # Install packages in the right order, so that ghc-pkg doesn't complain.
743 # Also, install ghc-pkg first.
744 ifeq "$(Windows)" "NO"
745 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(libexecdir)/ghc-pkg
747 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
750 install_packages: install_libexecs
751 install_packages: libffi/package.conf.install rts/package.conf.install
752 "$(MKDIRHIER)" $(DESTDIR)$(libdir)
753 echo "[]" > $(INSTALLED_PACKAGE_CONF)
754 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update libffi/package.conf.install
755 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update rts/package.conf.install
756 $(foreach p, $(PACKAGES) $(PACKAGES_STAGE2),\
757 "$(GHC_CABAL_INPLACE)" install \
758 $(INSTALLED_GHC_PKG_REAL) \
759 $(INSTALLED_PACKAGE_CONF) \
760 libraries/$p dist-install \
761 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries' &&) true
762 "$(GHC_CABAL_INPLACE)" install \
763 $(INSTALLED_GHC_PKG_REAL) \
764 $(INSTALLED_PACKAGE_CONF) \
766 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries'
768 # -----------------------------------------------------------------------------
769 # Binary distributions
771 $(eval $(call bindist,.,\
773 configure config.sub config.guess install-sh \
777 $(INPLACE_BIN)/mkdirhier \
778 $(INPLACE_BIN)/ghc-cabal \
779 utils/ghc-pwd/ghc-pwd \
780 $(BINDIST_WRAPPERS) \
785 $(INSTALL_LIBEXECS) \
786 $(INSTALL_LIBEXEC_SCRIPTS) \
789 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
790 $(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
791 $(filter-out %/project.mk,$(filter-out mk/config.mk,$(MAKEFILE_LIST))) \
792 mk/fix_install_names.sh \
795 libraries/dph/LICENSE \
797 # mk/project.mk gets an absolute path, so we manually include it in
798 # the bindist with a relative path
800 BIN_DIST_MK = $(BIN_DIST_NAME)/bindist.mk
803 "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
804 mkdir $(BIN_DIST_NAME)
805 set -e; for i in LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh extra-gcc-opts.in ghc.mk inplace; do ln -s ../$$i $(BIN_DIST_NAME)/; done
806 echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
807 echo "LATEX_DOCS = $(LATEX_DOCS)" >> $(BIN_DIST_MK)
808 echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
809 echo "BUILD_DOCBOOK_PS = $(BUILD_DOCBOOK_PS)" >> $(BIN_DIST_MK)
810 echo "BUILD_DOCBOOK_PDF = $(BUILD_DOCBOOK_PDF)" >> $(BIN_DIST_MK)
811 ln -s ../distrib/configure-bin.ac $(BIN_DIST_NAME)/configure.ac
812 cd $(BIN_DIST_NAME) && autoreconf
813 "$(RM)" $(RM_OPTS) $(BIN_DIST_TAR)
814 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
815 # tree then we want to include the real file, not a symlink to it
816 "$(TAR)" hcf - -T $(BIN_DIST_LIST) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
819 "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
820 $(MAKE) prefix=$(BIN_DIST_DIR) install
821 "$(TAR)" cf - $(BIN_DIST_NAME) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
824 "$(ISCC)" /O. /F$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
826 nTimes = set -e; for i in `seq 1 $(1)`; do echo Try "$$i: $(2)"; if $(2); then break; fi; done
828 .PHONY: publish-binary-dist
830 $(call nTimes,10,$(PublishCp) $(BIN_DIST_TAR_BZ2) $(PublishLocation)/dist)
831 ifeq "$(mingw32_TARGET_OS)" "1"
832 $(call nTimes,10,$(PublishCp) $(WINDOWS_INSTALLER) $(PublishLocation)/dist)
837 $(call nTimes,10,$(PublishCp) -r bindisttest/installed/share/doc/ghc/* $(PublishLocation)/docs)
839 # -----------------------------------------------------------------------------
840 # Source distributions
848 # A source dist is built from a complete build tree, because we
849 # require some extra files not contained in a darcs checkout: the
850 # output from Happy and Alex, for example.
852 # The steps performed by 'make dist' are as follows:
853 # - create a complete link-tree of the current build tree in /tmp
854 # - run 'make distclean' on that tree
855 # - remove a bunch of other files that we know shouldn't be in the dist
856 # - tar up first the extralibs package, then the main source package
859 # Directory in which we're going to build the src dist
861 SRC_DIST_NAME=ghc-$(ProjectVersion)
862 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
865 # Files to include in source distributions
867 SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts compiler ghc driver libraries
869 configure.ac config.guess config.sub configure \
870 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
871 ghc.spec.in ghc.spec extra-gcc-opts.in VERSION \
872 boot boot-pkgs packages ghc.mk
874 SRC_DIST_TARBALL = $(SRC_DIST_NAME)-src.tar.bz2
877 echo $(ProjectVersion) >VERSION
882 # $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
883 # to copy the generated file that replaces compiler/cmm/CmmLex.x, where
884 # "stage2" is the dist dir.
886 if test -f $(TOP)/$1/$2/build/$4.hs; then \
887 "$(CP)" $(TOP)/$1/$2/build/$4.hs $1/$3/ ; \
888 mv $1/$3/$4.$5 $1/$3/$4.$5.source ;\
890 echo "does not exist: $1/$2//build/$4.hs"; \
896 "$(RM)" $(RM_OPTS) -r $(SRC_DIST_DIR)
897 "$(RM)" $(RM_OPTS) $(SRC_DIST_TARBALL)
898 mkdir $(SRC_DIST_DIR)
899 ( cd $(SRC_DIST_DIR) \
900 && for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i && lndir $(TOP)/$$i ); done \
901 && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done \
902 && $(MAKE) distclean \
903 && if test -f $(TOP)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs; then "$(CP)" $(TOP)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs libraries/haskell-src/Language/Haskell/ ; mv libraries/haskell-src/Language/Haskell/Parser.ly libraries/haskell-src/Language/Haskell/Parser.ly.source ; fi \
904 && $(call sdist_file,compiler,stage2,cmm,CmmLex,x) \
905 && $(call sdist_file,compiler,stage2,cmm,CmmParse,y) \
906 && $(call sdist_file,compiler,stage2,main,ParsePkgConf,y) \
907 && $(call sdist_file,compiler,stage2,parser,HaddockLex,x) \
908 && $(call sdist_file,compiler,stage2,parser,HaddockParse,y) \
909 && $(call sdist_file,compiler,stage2,parser,Lexer,x) \
910 && $(call sdist_file,compiler,stage2,parser,Parser,y.pp) \
911 && $(call sdist_file,compiler,stage2,parser,ParserCore,y) \
912 && $(call sdist_file,utils/hpc,dist,,HpcParser,y) \
913 && $(call sdist_file,utils/genprimopcode,dist,,Lexer,x) \
914 && $(call sdist_file,utils/genprimopcode,dist,,Parser,y) \
915 && "$(RM)" $(RM_OPTS) -r compiler/stage[123] mk/build.mk \
916 && "$(FIND)" $(SRC_DIST_DIRS) \( -name _darcs -o -name SRC -o -name "autom4te*" -o -name "*~" -o -name ".cvsignore" -o -name "\#*" -o -name ".\#*" -o -name "log" -o -name "*-SAVE" -o -name "*.orig" -o -name "*.rej" -o -name "*-darcs-backup*" \) -print | xargs "$(RM)" $(RM_OPTS) -r \
921 "$(TAR)" chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
923 sdist-manifest : $(SRC_DIST_TARBALL)
924 tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
926 # Upload the distribution(s)
927 # Retrying is to work around buggy firewalls that corrupt large file transfers
929 ifneq "$(PublishLocation)" ""
931 $(call nTimes,10,$(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist)
934 ifeq "$(GhcUnregisterised)" "YES"
935 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
938 # -----------------------------------------------------------------------------
943 CLEAN_FILES += utils/ghc-pwd/ghc-pwd
944 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.exe
945 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.hi
946 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.o
947 CLEAN_FILES += libraries/bootstrapping.conf
949 clean : clean_files clean_libraries
953 "$(RM)" $(RM_OPTS) $(CLEAN_FILES)
955 .PHONY: clean_libraries
956 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES) $(PACKAGES_STAGE2))
957 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(BOOT_PKGS))
960 "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/dist, $(PACKAGES) $(PACKAGES_STAGE2))
961 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/*.buildinfo, $(PACKAGES) $(PACKAGES_STAGE2))
963 # We have to define a clean target for each library manually, because the
964 # libraries/*/ghc.mk files are not included when we're cleaning.
965 ifeq "$(CLEANING)" "YES"
966 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),\
967 $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
971 "$(RM)" $(RM_OPTS) config.cache config.status config.log mk/config.h mk/stamp-h
972 "$(RM)" $(RM_OPTS) mk/config.mk mk/are-validating.mk mk/project.mk
973 "$(RM)" $(RM_OPTS) mk/config.mk.old mk/project.mk.old
974 "$(RM)" $(RM_OPTS) extra-gcc-opts docs/users_guide/ug-book.xml
975 "$(RM)" $(RM_OPTS) compiler/ghc.cabal compiler/ghc.cabal.old
976 "$(RM)" $(RM_OPTS) ghc/ghc-bin.cabal
977 "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h
978 "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h
979 "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h
980 "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h
981 "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h
983 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.log, $(PACKAGES) $(PACKAGES_STAGE2))
984 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.status, $(PACKAGES) $(PACKAGES_STAGE2))
985 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES) $(PACKAGES_STAGE2))
986 "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/autom4te.cache, $(PACKAGES) $(PACKAGES_STAGE2))
988 maintainer-clean : distclean
989 "$(RM)" $(RM_OPTS) configure mk/config.h.in
990 "$(RM)" $(RM_OPTS) -r autom4te.cache libraries/*/autom4te.cache
991 "$(RM)" $(RM_OPTS) ghc.spec
992 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/GNUmakefile, \
993 $(PACKAGES) $(PACKAGES_STAGE2))
994 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/ghc.mk, $(PACKAGES) $(PACKAGES_STAGE2))
995 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/configure, \
996 $(PACKAGES) $(PACKAGES_STAGE2))
997 "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h.in
998 "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h.in
999 "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h.in
1000 "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h.in
1001 "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h.in
1003 .PHONY: all_libraries
1005 .PHONY: bootstrapping-files
1006 bootstrapping-files: $(OTHER_LIBS)
1007 bootstrapping-files: includes/ghcautoconf.h
1008 bootstrapping-files: includes/DerivedConstants.h
1009 bootstrapping-files: includes/GHCConstants.h