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 # * Windows: should we have ghc-pkg-<version>?
17 # * should we be stripping things?
18 # * install libgmp.a, gmp.h
19 # * need to fix Cabal for new Windows layout, see
20 # Distribution/Simple/GHC.configureToolchain.
21 # * remove old Makefiles, add new stubs for building in subdirs
23 # * docs/docbook-cheat-sheet/Makefile
24 # * docs/ext-core/Makefile
26 # * docs/storage-mgmt/Makefile
28 # * rts/dotnet/Makefile
30 # * optionally install stage3?
31 # * add Makefiles for the rest of the utils/ programs that aren't built
32 # by default (need to exclude them from 'make all' too)
34 # Tickets we can now close, or fix and close:
36 # * 1693 make distclean
37 # * 3173 make install with DESTDIR
41 # * per-source-file dependencies instead of one .depend file?
42 # * eliminate undefined variables, and use --warn-undefined-variables?
43 # * perhaps we should make all the output dirs in the .depend rule, to
44 # avoid all these mkdirhier calls?
45 # * put outputs from different ways in different subdirs of distdir/build,
46 # then we don't have to use -osuf/-hisuf. We would have to install
47 # them in different places too, so we'd need ghc-pkg support for packages
49 # * make PACKAGES generated by configure or sh boot?
50 # * we should use a directory of package.conf files rather than a single
51 # file for the inplace package database, so that we can express
52 # dependencies more accurately. Otherwise it's possible to get into
53 # a state where the package database is out of date, and the build
54 # system doesn't know.
56 # Approximate build order.
58 # The actual build order is defined by dependencies, and the phase
59 # ordering used to ensure correct ordering of makefile-generation; see
60 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
62 # * With bootstrapping compiler:
63 # o Build utils/ghc-cabal
64 # o Build utils/ghc-pkg
65 # o Build utils/hsc2hs
67 # o configure, generate package-data.mk and inplace-pkg-info
68 # o register each package into inplace/lib/package.conf
70 # * With bootstrapping compiler:
71 # o Build libraries/{filepath,hpc,extensible-exceptions,Cabal}
72 # o Build compiler (stage 1)
76 # o Build utils/* (except haddock)
77 # o Build compiler (stage 2)
79 # o Build utils/haddock
80 # o Build compiler (stage 3) (optional)
85 .PHONY: default all haddock
89 # Just bring makefiles up to date:
90 .PHONY: just-makefiles
94 # -----------------------------------------------------------------------------
98 space=$(nothing) $(nothing)
101 # Cancel all suffix rules. Ideally we'd like to have 'make -r' turned on
102 # by default, because that disables all the implicit rules, but there doesn't
103 # seem to be a good way to do that. This turns off all the old-style suffix
104 # rules, which does half the job and speeds up make quite a bit:
107 # -----------------------------------------------------------------------------
109 # to see the effective value used for a Makefile variable, do
110 # make show VALUE=MY_VALUE
114 @echo '$(VALUE)="$($(VALUE))"'
116 # -----------------------------------------------------------------------------
117 # Include subsidiary build-system bits
121 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
123 ifeq "$(ProjectVersion)" ""
124 $(error Please run ./configure first)
128 # (Optional) build-specific configuration
129 include mk/custom-settings.mk
131 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
132 ifeq "$(GhcLibWays)" ""
133 $(error $$(GhcLibWays) is empty, it must contain at least one way)
137 # -----------------------------------------------------------------------------
138 # Macros for standard targets
140 include rules/all-target.mk
141 include rules/clean-target.mk
144 include rules/mkdep.mk
146 # -----------------------------------------------------------------------------
149 $(eval $(call clean-target,inplace,,inplace))
151 # -----------------------------------------------------------------------------
152 # Whether to build dependencies or not
154 # When we're just doing 'make clean' or 'make show', then we don't need
155 # to build dependencies.
157 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
158 NO_INCLUDE_DEPS = YES
159 NO_INCLUDE_PKGDATA = YES
161 ifneq "$(findstring bootstrapping-files,$(MAKECMDGOALS))" ""
162 NO_INCLUDE_DEPS = YES
163 NO_INCLUDE_PKGDATA = YES
165 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
166 NO_INCLUDE_DEPS = YES
167 # We want package-data.mk for show
170 # We don't haddock base3-compat, as it has the same package name as base
171 libraries/base3-compat_dist-install_DO_HADDOCK = NO
173 # We don't haddock the bootstrapping libraries
174 libraries/hpc_dist-boot_DO_HADDOCK = NO
175 libraries/Cabal_dist-boot_DO_HADDOCK = NO
176 libraries/extensible-exceptions_dist-boot_DO_HADDOCK = NO
177 libraries/filepath_dist-boot_DO_HADDOCK = NO
179 # -----------------------------------------------------------------------------
182 include rules/way-prelims.mk
184 $(foreach way,$(ALL_WAYS),\
185 $(eval $(call way-prelims,$(way))))
187 # -----------------------------------------------------------------------------
190 include rules/distdir-opts.mk
191 include rules/distdir-way-opts.mk
193 # -----------------------------------------------------------------------------
194 # Finding source files and object files
196 include rules/hs-sources.mk
197 include rules/c-sources.mk
198 include rules/includes-sources.mk
199 include rules/hs-objs.mk
200 include rules/c-objs.mk
201 include rules/cmm-objs.mk
203 # -----------------------------------------------------------------------------
206 # Suffix rules cause "make clean" to fail on Windows (trac #3233)
207 # so we don't make any when cleaning.
208 ifneq "$(CLEANING)" "YES"
210 include rules/hs-suffix-rules-srcdir.mk
211 include rules/hs-suffix-rules.mk
213 # -----------------------------------------------------------------------------
214 # Suffix rules for .hi files
216 include rules/hi-rule.mk
218 $(foreach way,$(ALL_WAYS),\
219 $(eval $(call hi-rule,$(way))))
221 #-----------------------------------------------------------------------------
222 # C-related suffix rules
224 include rules/c-suffix-rules.mk
226 #-----------------------------------------------------------------------------
227 # CMM-related suffix rules
229 include rules/cmm-suffix-rules.mk
233 # -----------------------------------------------------------------------------
234 # Building package-data.mk files from .cabal files
236 include rules/package-config.mk
238 # -----------------------------------------------------------------------------
239 # Building dependencies
241 include rules/build-dependencies.mk
243 # -----------------------------------------------------------------------------
244 # Build package-data.mk files
246 include rules/build-package-data.mk
248 # -----------------------------------------------------------------------------
249 # Build and install a program
251 include rules/build-prog.mk
252 include rules/shell-wrapper.mk
254 # -----------------------------------------------------------------------------
255 # Build a perl script
257 include rules/build-perl.mk
259 # -----------------------------------------------------------------------------
262 include rules/build-package.mk
263 include rules/build-package-way.mk
264 include rules/haddock.mk
266 # -----------------------------------------------------------------------------
267 # Registering hand-written package descriptions (used in libffi and rts)
269 include rules/manual-package-config.mk
271 # -----------------------------------------------------------------------------
274 include rules/docbook.mk
276 # -----------------------------------------------------------------------------
279 include rules/bindist.mk
281 # -----------------------------------------------------------------------------
284 define addPackage # args: $1 = package, $2 = condition
286 ifeq "$$(CLEANING)" "YES"
298 $(eval $(call addPackage,ghc-prim))
299 ifeq "$(CLEANING)" "YES"
300 $(eval $(call addPackage,integer-gmp))
301 $(eval $(call addPackage,integer-simple))
303 $(eval $(call addPackage,$(INTEGER_LIBRARY)))
305 $(eval $(call addPackage,base))
306 $(eval $(call addPackage,filepath))
307 $(eval $(call addPackage,array))
308 $(eval $(call addPackage,bytestring))
309 $(eval $(call addPackage,containers))
311 $(eval $(call addPackage,Win32,($$(Windows),YES)))
312 $(eval $(call addPackage,unix,($$(Windows),NO)))
314 $(eval $(call addPackage,old-locale))
315 $(eval $(call addPackage,old-time))
316 $(eval $(call addPackage,time))
317 $(eval $(call addPackage,directory))
318 $(eval $(call addPackage,process))
319 $(eval $(call addPackage,random))
320 $(eval $(call addPackage,extensible-exceptions))
321 $(eval $(call addPackage,haskell98))
322 $(eval $(call addPackage,hpc))
323 $(eval $(call addPackage,pretty))
324 $(eval $(call addPackage,syb))
325 $(eval $(call addPackage,template-haskell))
326 $(eval $(call addPackage,base3-compat))
327 $(eval $(call addPackage,Cabal))
328 $(eval $(call addPackage,mtl))
329 $(eval $(call addPackage,utf8-string))
331 $(eval $(call addPackage,terminfo,($$(Windows),NO)))
333 $(eval $(call addPackage,haskeline))
335 ifneq "$(BootingFromHc)" "YES"
338 dph/dph-prim-interface \
345 BOOT_PKGS = Cabal hpc extensible-exceptions
347 # The actual .a and .so/.dll files: needed for dependencies.
348 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_v_LIB))
349 ifeq "$(BuildSharedLibs)" "YES"
350 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_dyn_LIB))
352 BOOT_LIBS = $(foreach lib,$(BOOT_PKGS),$(libraries/$(lib)_dist-boot_v_LIB))
354 OTHER_LIBS = libffi/libHSffi$(v_libsuf) libffi/HSffi.o
355 ifeq "$(BuildSharedLibs)" "YES"
356 OTHER_LIBS += libffi/libHSffi$(dyn_libsuf)
359 # We cannot run ghc-cabal to configure a package until we have
360 # configured and registered all of its dependencies. So the following
361 # hack forces all the configure steps to happen in exactly the order
362 # given in the PACKAGES variable above. Ideally we should use the
363 # correct dependencies here to allow more parallelism, but we don't
364 # know the dependencies until we've generated the pacakge-data.mk
367 libraries/$1/$2/package-data.mk : $$(GHC_PKG_INPLACE) $$(if $$(fixed_pkg_prev),libraries/$$(fixed_pkg_prev)/$2/package-data.mk)
371 ifneq "$(BINDIST)" "YES"
373 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
375 # We assume that the stage2 compiler depends on all the libraries, so
376 # they all get added to the package database before we try to configure
378 compiler/stage2/package-data.mk: $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),libraries/$(pkg)/dist-install/package-data.mk)
379 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
380 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
381 # haddock depends on ghc and some libraries, but depending on GHC's
382 # package-data.mk is sufficient, as that in turn depends on all the
384 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
386 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
388 # add the final two package.conf dependencies: ghc-prim depends on RTS,
389 # and RTS depends on libffi.
390 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
391 rts/package.conf.inplace : libffi/package.conf.inplace
394 # -----------------------------------------------------------------------------
395 # Special magic for the ghc-prim package
397 # We want the ghc-prim package to include the GHC.Prim module when it
398 # is registered, but not when it is built, because GHC.Prim is not a
399 # real source module, it is built-in to GHC. The old build system did
400 # this using Setup.hs, but we can't do that here, so we have a flag to
401 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
402 # remains compatible with the old build system for the time being).
403 # GHC.Prim module in the ghc-prim package with a flag:
405 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
407 # And then we strip it out again before building the package:
408 define libraries/ghc-prim_PACKAGE_MAGIC
409 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
412 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
414 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
415 "$(MKDIRHIER)" $(dir $@)
416 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
418 libraries/ghc-prim/GHC/Prim.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
419 "$(GENPRIMOP_INPLACE)" --make-haskell-source <$(PRIMOPS_TXT) >$@
422 # -----------------------------------------------------------------------------
423 # Include build instructions from all subdirs
425 # For the rationale behind the build phases, see
426 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
428 # Setting foo_dist_DISABLE=YES means "in directory foo, for build
429 # "dist", just read the package-data.mk file, do not build anything".
431 # We carefully engineer things so that we can build the
432 # package-data.mk files early on: they depend only on a few tools also
433 # built early. Having got the package-data.mk files built, we can
434 # restart make with up-to-date information about all the packages
435 # (this is phase 0). The remaining problem is the .depend files:
437 # - .depend files in libraries need the stage 1 compiler to build
438 # - ghc/stage1/.depend needs compiler/stage1 built
439 # - compiler/stage1/.depend needs the bootstrap libs built
441 # GHC 6.11+ can build a .depend file without having built the
442 # dependencies of the package, but we can't rely on the bootstrapping
443 # compiler being able to do this, which is why we have to separate the
444 # three phases above.
446 # So this is the final ordering:
448 # Phase 0 : all package-data.mk files
449 # (requires ghc-cabal, ghc-pkg, mkdirhier, dummy-ghc etc.)
450 # Phase 1 : .depend files for bootstrap libs
452 # Phase 2 : compiler/stage1/.depend
453 # (requires bootstrap libs and genprimopcode)
454 # Phase 3 : ghc/stage1/.depend
455 # (requires compiler/stage1)
457 # The rest : libraries/*/dist-install, compiler/stage2, ghc/stage2
461 ifneq "$(BINDIST)" "YES"
463 $(GHC_MKDEPENDC_DIR) \
469 libraries/Cabal/doc \
473 ifneq "$(GhcUnregisterised)" "YES"
479 ifneq "$(BINDIST)" "YES"
492 ifneq "$(BINDIST)" "YES"
502 ifneq "$(CLEANING)" "YES"
504 $(patsubst %, libraries/%, $(PACKAGES) $(PACKAGES_STAGE2))
505 ifneq "$(BootingFromHc)" "YES"
511 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
512 BUILD_DIRS += libraries/integer-gmp/gmp
522 ifeq "$(Windows)" "YES"
527 # XXX libraries/% must come before any programs built with stage1, see
528 # Note [lib-depends].
531 $(foreach lib,$(BOOT_PKGS),$(eval \
532 libraries/$(lib)_dist-boot_DISABLE = YES))
535 ifneq "$(findstring $(phase),0 1)" ""
536 # We can build deps for compiler/stage1 in phase 2
537 compiler_stage1_DISABLE = YES
540 ifneq "$(findstring $(phase),0 1 2)" ""
541 ghc_stage1_DISABLE = YES
544 ifneq "$(CLEANING)" "YES"
545 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
546 libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
548 ifeq "$(INTEGER_LIBRARY)" "integer-simple"
549 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
551 $(error Unknown integer library: $(INTEGER_LIBRARY))
556 ifneq "$(findstring $(phase),0 1 2 3)" ""
557 # In phases 0-3, we disable stage2-3, the full libraries and haddock
558 utils/haddock_dist_DISABLE = YES
559 utils/runghc_dist_DISABLE = YES
560 utils/hpc_dist_DISABLE = YES
561 utils/hsc2hs_dist-install_DISABLE = YES
562 utils/ghc-pkg_dist-install_DISABLE = YES
563 compiler_stage2_DISABLE = YES
564 compiler_stage3_DISABLE = YES
565 ghc_stage2_DISABLE = YES
566 ghc_stage3_DISABLE = YES
567 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),$(eval \
568 libraries/$(lib)_dist-install_DISABLE = YES))
571 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
573 # We need -fno-warn-deprecated-flags to avoid failure with -Werror
574 GhcLibHcOpts += -fno-warn-deprecated-flags
575 ifeq "$(ghc_ge_609)" "YES"
576 GhcBootLibHcOpts += -fno-warn-deprecated-flags
579 # Add $(GhcLibHcOpts) to all library builds
580 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
582 # XXX Hack; remove this
583 $(foreach pkg,$(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += -Wwarn))
585 # XXX we configure packages with the bootstrapping compiler (for
586 # dependency reasons, see the phase ordering), which doesn't
587 # necessarily support all the extensions we need, and Cabal filters
588 # out the ones it thinks aren't supported.
589 libraries/base3-compat_dist-install_HC_OPTS += -XPackageImports
591 # A useful pseudo-target
593 stage1_libs : $(ALL_STAGE1_LIBS)
595 libraries/index.html: $(ALL_HADDOCK_FILES)
596 cd libraries && sh gen_contents_index --inplace
597 $(eval $(call all-target,library_doc_index,libraries/index.html))
598 INSTALL_LIBRARY_DOCS += libraries/*.html libraries/*.gif libraries/*.css libraries/*.js
600 # -----------------------------------------------------------------------------
601 # Bootstrapping libraries
603 # We need to build a few libraries with the installed GHC, since GHC itself
604 # and some of the tools depend on them:
606 ifneq "$(BINDIST)" "YES"
608 ifneq "$(BOOTSTRAPPING_CONF)" ""
609 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
610 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
614 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
616 # These three libraries do not depend on each other, so we can build
619 $(eval $(call build-package,libraries/hpc,dist-boot,0))
620 $(eval $(call build-package,libraries/extensible-exceptions,dist-boot,0))
621 $(eval $(call build-package,libraries/Cabal,dist-boot,0))
623 # register the boot packages in strict sequence, because running
624 # multiple ghc-pkgs in parallel doesn't work (registrations may get
627 $(foreach pkg,$(BOOT_PKGS),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
629 compiler/stage1/package-data.mk : \
630 libraries/Cabal/dist-boot/package-data.mk \
631 libraries/hpc/dist-boot/package-data.mk \
632 libraries/extensible-exceptions/dist-boot/package-data.mk
634 # These are necessary because the bootstrapping compiler may not know
635 # about cross-package dependencies:
636 $(compiler_stage1_depfile) : $(BOOT_LIBS)
637 $(ghc_stage1_depfile) : $(compiler_stage1_v_LIB)
639 $(foreach pkg,$(BOOT_PKGS),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
643 # -----------------------------------------------------------------------------
644 # Creating a local mingw copy on Windows
646 ifeq "$(Windows)" "YES"
648 # directories don't work well as dependencies, hence a stamp file
649 $(INPLACE)/stamp-mingw : $(MKDIRHIER)
650 $(MKDIRHIER) $(INPLACE_MINGW)/bin
651 GCC=`type -p $(WhatGccIsCalled)`; \
652 GccDir=`dirname $$GCC`; \
653 "$(CP)" -p $$GccDir/{gcc.exe,ar.exe,as.exe,dlltool.exe,dllwrap.exe,windres.exe} $(INPLACE_MINGW)/bin; \
654 "$(CP)" -Rp $$GccDir/../include $(INPLACE_MINGW); \
655 "$(CP)" -Rp $$GccDir/../lib $(INPLACE_MINGW); \
656 "$(CP)" -Rp $$GccDir/../libexec $(INPLACE_MINGW); \
657 "$(CP)" -Rp $$GccDir/../mingw32 $(INPLACE_MINGW)
658 touch $(INPLACE)/stamp-mingw
660 install : install_mingw
661 .PHONY: install_mingw
662 install_mingw : $(INPLACE_MINGW)
663 "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
665 $(INPLACE_LIB)/perl.exe $(INPLACE_LIB)/perl56.dll :
666 "$(CP)" $(GhcDir)../{perl.exe,perl56.dll} $(INPLACE_LIB)
670 libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock: \
671 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs \
672 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs
674 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
675 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
676 "$(MKDIRHIER)" $(dir $@)
677 "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
679 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
680 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
681 "$(MKDIRHIER)" $(dir $@)
682 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers < $< > $@
684 # -----------------------------------------------------------------------------
687 install: install_packages install_libs install_libexecs install_headers \
688 install_libexec_scripts install_bins install_docs
690 install_bins: $(INSTALL_BINS)
691 $(INSTALL_DIR) $(DESTDIR)$(bindir)
692 for i in $(INSTALL_BINS); do \
693 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ; \
694 if test "$(darwin_TARGET_OS)" = "1"; then \
695 sh mk/fix_install_names.sh $(libdir) $(DESTDIR)$(bindir)/$$i ; \
699 install_libs: $(INSTALL_LIBS)
700 $(INSTALL_DIR) $(DESTDIR)$(libdir)
701 for i in $(INSTALL_LIBS); do \
704 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
705 $(RANLIB) $(DESTDIR)$(libdir)/`basename $$i` ;; \
707 $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
709 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
711 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
712 install_name_tool -id $(DESTDIR)$(libdir)/`basename $$i` $(DESTDIR)$(libdir)/`basename $$i` ;; \
714 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
718 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
719 $(INSTALL_DIR) $(DESTDIR)$(libexecdir)
720 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
721 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libexecdir); \
724 install_libexecs: $(INSTALL_LIBEXECS)
725 $(INSTALL_DIR) $(DESTDIR)$(libexecdir)
726 for i in $(INSTALL_LIBEXECS); do \
727 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(libexecdir); \
730 install_headers: $(INSTALL_HEADERS)
731 $(INSTALL_DIR) $(DESTDIR)$(headerdir)
732 for i in $(INSTALL_HEADERS); do \
733 $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
736 install_docs: $(INSTALL_HEADERS)
737 $(INSTALL_DIR) $(DESTDIR)$(docdir)
738 for i in $(INSTALL_DOCS); do \
739 $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir); \
741 $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html; \
742 $(INSTALL_DOC) $(INSTALL_OPTS) docs/index.html $(DESTDIR)$(docdir)/html; \
743 for i in $(INSTALL_LIBRARY_DOCS); do \
744 $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir)/html/libraries/; \
746 for i in $(INSTALL_HTML_DOC_DIRS); do \
747 $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html/`basename $$i`; \
748 $(INSTALL_DOC) $(INSTALL_OPTS) $$i/* $(DESTDIR)$(docdir)/html/`basename $$i`; \
751 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(libdir)/package.conf
753 # Install packages in the right order, so that ghc-pkg doesn't complain.
754 # Also, install ghc-pkg first.
755 ifeq "$(Windows)" "NO"
756 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(libexecdir)/ghc-pkg
758 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
761 install_packages: install_libexecs
762 install_packages: libffi/package.conf.install rts/package.conf.install
763 $(INSTALL_DIR) $(DESTDIR)$(libdir)
764 "$(RM)" $(RM_OPTS) $(INSTALLED_PACKAGE_CONF)
765 $(CREATE_DATA) $(INSTALLED_PACKAGE_CONF)
766 echo "[]" >> $(INSTALLED_PACKAGE_CONF)
767 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update libffi/package.conf.install
768 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update rts/package.conf.install
769 $(foreach p, $(PACKAGES) $(PACKAGES_STAGE2),\
770 "$(GHC_CABAL_INPLACE)" install \
771 $(INSTALLED_GHC_PKG_REAL) \
772 $(INSTALLED_PACKAGE_CONF) \
773 libraries/$p dist-install \
774 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/html/libraries' &&) true
775 "$(GHC_CABAL_INPLACE)" install \
776 $(INSTALLED_GHC_PKG_REAL) \
777 $(INSTALLED_PACKAGE_CONF) \
779 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/html/libraries'
781 # -----------------------------------------------------------------------------
782 # Binary distributions
784 # This is split in 2 because of the shell argument limit
785 $(eval $(call bindist,root1,\
787 configure config.sub config.guess install-sh \
791 $(INPLACE_BIN)/mkdirhier \
792 $(INPLACE_BIN)/ghc-cabal \
793 utils/ghc-pwd/ghc-pwd \
794 $(BINDIST_WRAPPERS) \
799 $(INSTALL_LIBEXECS) \
800 $(INSTALL_LIBEXEC_SCRIPTS) \
803 $(INSTALL_LIBRARY_DOCS) \
805 $(eval $(call bindist,root2,\
806 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
808 $(wildcard libraries/*/dist-install/doc/) \
809 $(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
810 $(filter-out %/project.mk,$(filter-out mk/config.mk,$(MAKEFILE_LIST))) \
811 mk/fix_install_names.sh \
814 libraries/dph/LICENSE \
816 # mk/project.mk gets an absolute path, so we manually include it in
817 # the bindist with a relative path
819 BIN_DIST_MK = $(BIN_DIST_NAME)/bindist.mk
822 "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
823 mkdir $(BIN_DIST_NAME)
824 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
825 echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
826 echo "LATEX_DOCS = $(LATEX_DOCS)" >> $(BIN_DIST_MK)
827 echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
828 echo "BUILD_DOCBOOK_PS = $(BUILD_DOCBOOK_PS)" >> $(BIN_DIST_MK)
829 echo "BUILD_DOCBOOK_PDF = $(BUILD_DOCBOOK_PDF)" >> $(BIN_DIST_MK)
830 ln -s ../distrib/configure-bin.ac $(BIN_DIST_NAME)/configure.ac
831 cd $(BIN_DIST_NAME) && autoreconf
832 "$(RM)" $(RM_OPTS) $(BIN_DIST_TAR)
833 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
834 # tree then we want to include the real file, not a symlink to it
835 "$(TAR)" hcf - -T $(BIN_DIST_LIST) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
838 "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
839 $(MAKE) prefix=$(BIN_DIST_DIR) install
840 "$(TAR)" cf - $(BIN_DIST_NAME) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
843 "$(ISCC)" /O. /F$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
845 nTimes = set -e; for i in `seq 1 $(1)`; do echo Try "$$i: $(2)"; if $(2); then break; fi; done
847 .PHONY: publish-binary-dist
849 $(call nTimes,10,$(PublishCp) $(BIN_DIST_TAR_BZ2) $(PublishLocation)/dist)
850 ifeq "$(mingw32_TARGET_OS)" "1"
851 $(call nTimes,10,$(PublishCp) $(WINDOWS_INSTALLER) $(PublishLocation)/dist)
856 $(call nTimes,10,$(PublishCp) -r bindisttest/installed/share/doc/ghc/* $(PublishLocation)/docs)
858 # -----------------------------------------------------------------------------
859 # Source distributions
867 # A source dist is built from a complete build tree, because we
868 # require some extra files not contained in a darcs checkout: the
869 # output from Happy and Alex, for example.
871 # The steps performed by 'make dist' are as follows:
872 # - create a complete link-tree of the current build tree in /tmp
873 # - run 'make distclean' on that tree
874 # - remove a bunch of other files that we know shouldn't be in the dist
875 # - tar up first the extralibs package, then the main source package
878 # Directory in which we're going to build the src dist
880 SRC_DIST_NAME=ghc-$(ProjectVersion)
881 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
884 # Files to include in source distributions
886 SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts compiler ghc driver libraries
888 configure.ac config.guess config.sub configure \
889 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
890 ghc.spec.in ghc.spec extra-gcc-opts.in VERSION \
891 boot boot-pkgs packages ghc.mk
893 SRC_DIST_TARBALL = $(SRC_DIST_NAME)-src.tar.bz2
896 echo $(ProjectVersion) >VERSION
901 # $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
902 # to copy the generated file that replaces compiler/cmm/CmmLex.x, where
903 # "stage2" is the dist dir.
905 if test -f $(TOP)/$1/$2/build/$4.hs; then \
906 "$(CP)" $(TOP)/$1/$2/build/$4.hs $1/$3/ ; \
907 mv $1/$3/$4.$5 $1/$3/$4.$5.source ;\
909 echo "does not exist: $1/$2//build/$4.hs"; \
915 "$(RM)" $(RM_OPTS) -r $(SRC_DIST_DIR)
916 "$(RM)" $(RM_OPTS) $(SRC_DIST_TARBALL)
917 mkdir $(SRC_DIST_DIR)
918 ( cd $(SRC_DIST_DIR) \
919 && for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i && lndir $(TOP)/$$i ); done \
920 && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done \
921 && $(MAKE) distclean \
922 && 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 \
923 && $(call sdist_file,compiler,stage2,cmm,CmmLex,x) \
924 && $(call sdist_file,compiler,stage2,cmm,CmmParse,y) \
925 && $(call sdist_file,compiler,stage2,main,ParsePkgConf,y) \
926 && $(call sdist_file,compiler,stage2,parser,HaddockLex,x) \
927 && $(call sdist_file,compiler,stage2,parser,HaddockParse,y) \
928 && $(call sdist_file,compiler,stage2,parser,Lexer,x) \
929 && $(call sdist_file,compiler,stage2,parser,Parser,y.pp) \
930 && $(call sdist_file,compiler,stage2,parser,ParserCore,y) \
931 && $(call sdist_file,utils/hpc,dist,,HpcParser,y) \
932 && $(call sdist_file,utils/genprimopcode,dist,,Lexer,x) \
933 && $(call sdist_file,utils/genprimopcode,dist,,Parser,y) \
934 && "$(RM)" $(RM_OPTS) -r compiler/stage[123] mk/build.mk \
935 && "$(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 \
940 "$(TAR)" chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
942 sdist-manifest : $(SRC_DIST_TARBALL)
943 tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
945 # Upload the distribution(s)
946 # Retrying is to work around buggy firewalls that corrupt large file transfers
948 ifneq "$(PublishLocation)" ""
950 $(call nTimes,10,$(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist)
953 ifeq "$(GhcUnregisterised)" "YES"
954 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
957 # -----------------------------------------------------------------------------
962 CLEAN_FILES += utils/ghc-pwd/ghc-pwd
963 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.exe
964 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.hi
965 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.o
966 CLEAN_FILES += libraries/bootstrapping.conf
967 CLEAN_FILES += libraries/integer-gmp/gmp/gmp.h
968 CLEAN_FILES += libraries/integer-gmp/gmp/libgmp.a
969 CLEAN_FILES += libraries/integer-gmp/cbits/GmpDerivedConstants.h
970 CLEAN_FILES += libraries/integer-gmp/cbits/mkGmpDerivedConstants
972 clean : clean_files clean_libraries clean_gmp
976 "$(RM)" $(RM_OPTS) $(CLEAN_FILES)
979 "$(RM)" $(RM_OPTS) -r libraries/integer-gmp/gmp/objs
980 "$(RM)" $(RM_OPTS) -r libraries/integer-gmp/gmp/gmpbuild
982 .PHONY: clean_libraries
983 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES) $(PACKAGES_STAGE2))
984 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(BOOT_PKGS))
987 "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/dist, $(PACKAGES) $(PACKAGES_STAGE2))
988 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/*.buildinfo, $(PACKAGES) $(PACKAGES_STAGE2))
990 # We have to define a clean target for each library manually, because the
991 # libraries/*/ghc.mk files are not included when we're cleaning.
992 ifeq "$(CLEANING)" "YES"
993 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),\
994 $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
998 "$(RM)" $(RM_OPTS) config.cache config.status config.log mk/config.h mk/stamp-h
999 "$(RM)" $(RM_OPTS) mk/config.mk mk/are-validating.mk mk/project.mk
1000 "$(RM)" $(RM_OPTS) mk/config.mk.old mk/project.mk.old
1001 "$(RM)" $(RM_OPTS) extra-gcc-opts docs/users_guide/ug-book.xml
1002 "$(RM)" $(RM_OPTS) compiler/ghc.cabal compiler/ghc.cabal.old
1003 "$(RM)" $(RM_OPTS) ghc/ghc-bin.cabal
1004 "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h
1005 "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h
1006 "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h
1007 "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h
1008 "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h
1010 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.log, $(PACKAGES) $(PACKAGES_STAGE2))
1011 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.status, $(PACKAGES) $(PACKAGES_STAGE2))
1012 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES) $(PACKAGES_STAGE2))
1013 "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/autom4te.cache, $(PACKAGES) $(PACKAGES_STAGE2))
1015 maintainer-clean : distclean
1016 "$(RM)" $(RM_OPTS) configure mk/config.h.in
1017 "$(RM)" $(RM_OPTS) -r autom4te.cache libraries/*/autom4te.cache
1018 "$(RM)" $(RM_OPTS) ghc.spec
1019 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/GNUmakefile, \
1020 $(PACKAGES) $(PACKAGES_STAGE2))
1021 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/ghc.mk, $(PACKAGES) $(PACKAGES_STAGE2))
1022 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/configure, \
1023 $(PACKAGES) $(PACKAGES_STAGE2))
1024 "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h.in
1025 "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h.in
1026 "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h.in
1027 "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h.in
1028 "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h.in
1030 .PHONY: all_libraries
1032 .PHONY: bootstrapping-files
1033 bootstrapping-files: $(OTHER_LIBS)
1034 bootstrapping-files: includes/ghcautoconf.h
1035 bootstrapping-files: includes/DerivedConstants.h
1036 bootstrapping-files: includes/GHCConstants.h