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
143 # -----------------------------------------------------------------------------
146 $(eval $(call clean-target,inplace,,inplace))
148 # -----------------------------------------------------------------------------
149 # Whether to build dependencies or not
151 # When we're just doing 'make clean' or 'make show', then we don't need
152 # to build dependencies.
154 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
155 NO_INCLUDE_DEPS = YES
156 NO_INCLUDE_PKGDATA = YES
158 ifneq "$(findstring bootstrapping-files,$(MAKECMDGOALS))" ""
159 NO_INCLUDE_DEPS = YES
160 NO_INCLUDE_PKGDATA = YES
162 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
163 NO_INCLUDE_DEPS = YES
164 # We want package-data.mk for show
167 # We don't haddock base3-compat, as it has the same package name as base
168 libraries/base3-compat_dist-install_DO_HADDOCK = NO
170 # We don't haddock the bootstrapping libraries
171 libraries/hpc_dist-boot_DO_HADDOCK = NO
172 libraries/Cabal_dist-boot_DO_HADDOCK = NO
173 libraries/extensible-exceptions_dist-boot_DO_HADDOCK = NO
174 libraries/filepath_dist-boot_DO_HADDOCK = NO
176 # -----------------------------------------------------------------------------
179 include rules/way-prelims.mk
181 $(foreach way,$(ALL_WAYS),\
182 $(eval $(call way-prelims,$(way))))
184 # -----------------------------------------------------------------------------
187 include rules/distdir-opts.mk
188 include rules/distdir-way-opts.mk
190 # -----------------------------------------------------------------------------
191 # Finding source files and object files
193 include rules/hs-sources.mk
194 include rules/c-sources.mk
195 include rules/includes-sources.mk
196 include rules/hs-objs.mk
197 include rules/c-objs.mk
198 include rules/cmm-objs.mk
200 # -----------------------------------------------------------------------------
203 # Suffix rules cause "make clean" to fail on Windows (trac #3233)
204 # so we don't make any when cleaning.
205 ifneq "$(CLEANING)" "YES"
207 include rules/hs-suffix-rules-srcdir.mk
208 include rules/hs-suffix-rules.mk
210 # -----------------------------------------------------------------------------
211 # Suffix rules for .hi files
213 include rules/hi-rule.mk
215 $(foreach way,$(ALL_WAYS),\
216 $(eval $(call hi-rule,$(way))))
218 #-----------------------------------------------------------------------------
219 # C-related suffix rules
221 include rules/c-suffix-rules.mk
223 #-----------------------------------------------------------------------------
224 # CMM-related suffix rules
226 include rules/cmm-suffix-rules.mk
230 # -----------------------------------------------------------------------------
231 # Building package-data.mk files from .cabal files
233 include rules/package-config.mk
235 # -----------------------------------------------------------------------------
236 # Building dependencies
238 include rules/build-dependencies.mk
240 # -----------------------------------------------------------------------------
241 # Build package-data.mk files
243 include rules/build-package-data.mk
245 # -----------------------------------------------------------------------------
246 # Build and install a program
248 include rules/build-prog.mk
249 include rules/shell-wrapper.mk
251 # -----------------------------------------------------------------------------
252 # Build a perl script
254 include rules/build-perl.mk
256 # -----------------------------------------------------------------------------
259 include rules/build-package.mk
260 include rules/build-package-way.mk
261 include rules/haddock.mk
263 # -----------------------------------------------------------------------------
264 # Registering hand-written package descriptions (used in libffi and rts)
266 include rules/manual-package-config.mk
268 # -----------------------------------------------------------------------------
271 include rules/docbook.mk
273 # -----------------------------------------------------------------------------
276 include rules/bindist.mk
278 # -----------------------------------------------------------------------------
281 define addPackage # args: $1 = package, $2 = condition
283 ifeq "$$(CLEANING)" "YES"
295 $(eval $(call addPackage,ghc-prim))
296 ifeq "$(CLEANING)" "YES"
297 $(eval $(call addPackage,integer-gmp))
298 $(eval $(call addPackage,integer-simple))
300 $(eval $(call addPackage,$(INTEGER_LIBRARY)))
302 $(eval $(call addPackage,base))
303 $(eval $(call addPackage,filepath))
304 $(eval $(call addPackage,array))
305 $(eval $(call addPackage,bytestring))
306 $(eval $(call addPackage,containers))
308 $(eval $(call addPackage,Win32,($$(Windows),YES)))
309 $(eval $(call addPackage,unix,($$(Windows),NO)))
311 $(eval $(call addPackage,old-locale))
312 $(eval $(call addPackage,old-time))
313 $(eval $(call addPackage,time))
314 $(eval $(call addPackage,directory))
315 $(eval $(call addPackage,process))
316 $(eval $(call addPackage,random))
317 $(eval $(call addPackage,extensible-exceptions))
318 $(eval $(call addPackage,haskell98))
319 $(eval $(call addPackage,hpc))
320 $(eval $(call addPackage,pretty))
321 $(eval $(call addPackage,syb))
322 $(eval $(call addPackage,template-haskell))
323 $(eval $(call addPackage,base3-compat))
324 $(eval $(call addPackage,Cabal))
325 $(eval $(call addPackage,mtl))
326 $(eval $(call addPackage,utf8-string))
328 $(eval $(call addPackage,terminfo,($$(Windows),NO)))
330 $(eval $(call addPackage,haskeline))
332 ifneq "$(BootingFromHc)" "YES"
335 dph/dph-prim-interface \
342 BOOT_PKGS = Cabal hpc extensible-exceptions
344 # The actual .a and .so/.dll files: needed for dependencies.
345 ALL_STAGE1_LIBS = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_v_LIB))
346 ifeq "$(BuildSharedLibs)" "YES"
347 ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_dyn_LIB))
349 BOOT_LIBS = $(foreach lib,$(BOOT_PKGS),$(libraries/$(lib)_dist-boot_v_LIB))
351 OTHER_LIBS = libffi/libHSffi$(v_libsuf) libffi/HSffi.o
352 ifeq "$(BuildSharedLibs)" "YES"
353 OTHER_LIBS += libffi/libHSffi$(dyn_libsuf)
356 # We cannot run ghc-cabal to configure a package until we have
357 # configured and registered all of its dependencies. So the following
358 # hack forces all the configure steps to happen in exactly the order
359 # given in the PACKAGES variable above. Ideally we should use the
360 # correct dependencies here to allow more parallelism, but we don't
361 # know the dependencies until we've generated the pacakge-data.mk
364 libraries/$1/$2/package-data.mk : $$(GHC_PKG_INPLACE) $$(if $$(fixed_pkg_prev),libraries/$$(fixed_pkg_prev)/$2/package-data.mk)
368 ifneq "$(BINDIST)" "YES"
370 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
372 # We assume that the stage2 compiler depends on all the libraries, so
373 # they all get added to the package database before we try to configure
375 compiler/stage2/package-data.mk: $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),libraries/$(pkg)/dist-install/package-data.mk)
376 ghc/stage1/package-data.mk: compiler/stage1/package-data.mk
377 ghc/stage2/package-data.mk: compiler/stage2/package-data.mk
378 # haddock depends on ghc and some libraries, but depending on GHC's
379 # package-data.mk is sufficient, as that in turn depends on all the
381 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
383 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
385 # add the final two package.conf dependencies: ghc-prim depends on RTS,
386 # and RTS depends on libffi.
387 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
388 rts/package.conf.inplace : libffi/package.conf.inplace
391 # -----------------------------------------------------------------------------
392 # Special magic for the ghc-prim package
394 # We want the ghc-prim package to include the GHC.Prim module when it
395 # is registered, but not when it is built, because GHC.Prim is not a
396 # real source module, it is built-in to GHC. The old build system did
397 # this using Setup.hs, but we can't do that here, so we have a flag to
398 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
399 # remains compatible with the old build system for the time being).
400 # GHC.Prim module in the ghc-prim package with a flag:
402 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
404 # And then we strip it out again before building the package:
405 define libraries/ghc-prim_PACKAGE_MAGIC
406 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
409 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
411 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
412 "$(MKDIRHIER)" $(dir $@)
413 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
415 libraries/ghc-prim/GHC/Prim.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
416 "$(GENPRIMOP_INPLACE)" --make-haskell-source <$(PRIMOPS_TXT) >$@
419 # -----------------------------------------------------------------------------
420 # Include build instructions from all subdirs
422 # For the rationale behind the build phases, see
423 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
425 # Setting foo_dist_DISABLE=YES means "in directory foo, for build
426 # "dist", just read the package-data.mk file, do not build anything".
428 # We carefully engineer things so that we can build the
429 # package-data.mk files early on: they depend only on a few tools also
430 # built early. Having got the package-data.mk files built, we can
431 # restart make with up-to-date information about all the packages
432 # (this is phase 0). The remaining problem is the .depend files:
434 # - .depend files in libraries need the stage 1 compiler to build
435 # - ghc/stage1/.depend needs compiler/stage1 built
436 # - compiler/stage1/.depend needs the bootstrap libs built
438 # GHC 6.11+ can build a .depend file without having built the
439 # dependencies of the package, but we can't rely on the bootstrapping
440 # compiler being able to do this, which is why we have to separate the
441 # three phases above.
443 # So this is the final ordering:
445 # Phase 0 : all package-data.mk files
446 # (requires ghc-cabal, ghc-pkg, mkdirhier, dummy-ghc etc.)
447 # Phase 1 : .depend files for bootstrap libs
449 # Phase 2 : compiler/stage1/.depend
450 # (requires bootstrap libs and genprimopcode)
451 # Phase 3 : ghc/stage1/.depend
452 # (requires compiler/stage1)
454 # The rest : libraries/*/dist-install, compiler/stage2, ghc/stage2
458 ifneq "$(BINDIST)" "YES"
460 $(GHC_MKDEPENDC_DIR) \
466 libraries/Cabal/doc \
470 ifneq "$(GhcUnregisterised)" "YES"
476 ifneq "$(BINDIST)" "YES"
489 ifneq "$(BINDIST)" "YES"
499 ifneq "$(CLEANING)" "YES"
501 $(patsubst %, libraries/%, $(PACKAGES) $(PACKAGES_STAGE2))
502 ifneq "$(BootingFromHc)" "YES"
508 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
509 BUILD_DIRS += libraries/integer-gmp/gmp
519 ifeq "$(Windows)" "YES"
524 # XXX libraries/% must come before any programs built with stage1, see
525 # Note [lib-depends].
528 $(foreach lib,$(BOOT_PKGS),$(eval \
529 libraries/$(lib)_dist-boot_DISABLE = YES))
532 ifneq "$(findstring $(phase),0 1)" ""
533 # We can build deps for compiler/stage1 in phase 2
534 compiler_stage1_DISABLE = YES
537 ifneq "$(findstring $(phase),0 1 2)" ""
538 ghc_stage1_DISABLE = YES
541 ifneq "$(CLEANING)" "YES"
542 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
543 libraries/base_dist-install_CONFIGURE_OPTS += --flags=-integer-simple
545 ifeq "$(INTEGER_LIBRARY)" "integer-simple"
546 libraries/base_dist-install_CONFIGURE_OPTS += --flags=integer-simple
548 $(error Unknown integer library: $(INTEGER_LIBRARY))
553 ifneq "$(findstring $(phase),0 1 2 3)" ""
554 # In phases 0-3, we disable stage2-3, the full libraries and haddock
555 utils/haddock_dist_DISABLE = YES
556 utils/runghc_dist_DISABLE = YES
557 utils/hpc_dist_DISABLE = YES
558 utils/hsc2hs_dist-install_DISABLE = YES
559 utils/ghc-pkg_dist-install_DISABLE = YES
560 compiler_stage2_DISABLE = YES
561 compiler_stage3_DISABLE = YES
562 ghc_stage2_DISABLE = YES
563 ghc_stage3_DISABLE = YES
564 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),$(eval \
565 libraries/$(lib)_dist-install_DISABLE = YES))
568 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
570 # We need -fno-warn-deprecated-flags to avoid failure with -Werror
571 GhcLibHcOpts += -fno-warn-deprecated-flags
572 ifeq "$(ghc_ge_609)" "YES"
573 GhcBootLibHcOpts += -fno-warn-deprecated-flags
576 # Add $(GhcLibHcOpts) to all library builds
577 $(foreach pkg,$(PACKAGES) $(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
579 # XXX Hack; remove this
580 $(foreach pkg,$(PACKAGES_STAGE2),$(eval libraries/$(pkg)_dist-install_HC_OPTS += -Wwarn))
582 # XXX we configure packages with the bootstrapping compiler (for
583 # dependency reasons, see the phase ordering), which doesn't
584 # necessarily support all the extensions we need, and Cabal filters
585 # out the ones it thinks aren't supported.
586 libraries/base3-compat_dist-install_HC_OPTS += -XPackageImports
588 # A useful pseudo-target
590 stage1_libs : $(ALL_STAGE1_LIBS)
592 libraries/index.html: $(ALL_HADDOCK_FILES)
593 cd libraries && sh gen_contents_index --inplace
594 $(eval $(call all-target,library_doc_index,libraries/index.html))
595 INSTALL_LIBRARY_DOCS += libraries/*.html libraries/*.gif libraries/*.css libraries/*.js
597 # -----------------------------------------------------------------------------
598 # Bootstrapping libraries
600 # We need to build a few libraries with the installed GHC, since GHC itself
601 # and some of the tools depend on them:
603 ifneq "$(BINDIST)" "YES"
605 ifneq "$(BOOTSTRAPPING_CONF)" ""
606 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
607 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
611 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
613 # These three libraries do not depend on each other, so we can build
616 $(eval $(call build-package,libraries/hpc,dist-boot,0))
617 $(eval $(call build-package,libraries/extensible-exceptions,dist-boot,0))
618 $(eval $(call build-package,libraries/Cabal,dist-boot,0))
620 # register the boot packages in strict sequence, because running
621 # multiple ghc-pkgs in parallel doesn't work (registrations may get
624 $(foreach pkg,$(BOOT_PKGS),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
626 compiler/stage1/package-data.mk : \
627 libraries/Cabal/dist-boot/package-data.mk \
628 libraries/hpc/dist-boot/package-data.mk \
629 libraries/extensible-exceptions/dist-boot/package-data.mk
631 # These are necessary because the bootstrapping compiler may not know
632 # about cross-package dependencies:
633 $(compiler_stage1_depfile) : $(BOOT_LIBS)
634 $(ghc_stage1_depfile) : $(compiler_stage1_v_LIB)
636 $(foreach pkg,$(BOOT_PKGS),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
640 # -----------------------------------------------------------------------------
641 # Creating a local mingw copy on Windows
643 ifeq "$(Windows)" "YES"
645 # directories don't work well as dependencies, hence a stamp file
646 $(INPLACE)/stamp-mingw : $(MKDIRHIER)
647 $(MKDIRHIER) $(INPLACE_MINGW)/bin
648 GCC=`type -p $(WhatGccIsCalled)`; \
649 GccDir=`dirname $$GCC`; \
650 "$(CP)" -p $$GccDir/{gcc.exe,ar.exe,as.exe,dlltool.exe,dllwrap.exe,windres.exe} $(INPLACE_MINGW)/bin; \
651 "$(CP)" -Rp $$GccDir/../include $(INPLACE_MINGW); \
652 "$(CP)" -Rp $$GccDir/../lib $(INPLACE_MINGW); \
653 "$(CP)" -Rp $$GccDir/../libexec $(INPLACE_MINGW); \
654 "$(CP)" -Rp $$GccDir/../mingw32 $(INPLACE_MINGW)
655 touch $(INPLACE)/stamp-mingw
657 install : install_mingw
658 .PHONY: install_mingw
659 install_mingw : $(INPLACE_MINGW)
660 "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
662 $(INPLACE_LIB)/perl.exe $(INPLACE_LIB)/perl56.dll :
663 "$(CP)" $(GhcDir)../{perl.exe,perl56.dll} $(INPLACE_LIB)
667 libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock: \
668 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs \
669 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs
671 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
672 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
673 "$(MKDIRHIER)" $(dir $@)
674 "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
676 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
677 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
678 "$(MKDIRHIER)" $(dir $@)
679 "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers < $< > $@
681 # -----------------------------------------------------------------------------
684 install: install_packages install_libs install_libexecs install_headers \
685 install_libexec_scripts install_bins install_docs
687 install_bins: $(INSTALL_BINS)
688 $(INSTALL_DIR) $(DESTDIR)$(bindir)
689 for i in $(INSTALL_BINS); do \
690 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ; \
691 if test "$(darwin_TARGET_OS)" = "1"; then \
692 sh mk/fix_install_names.sh $(libdir) $(DESTDIR)$(bindir)/$$i ; \
696 install_libs: $(INSTALL_LIBS)
697 $(INSTALL_DIR) $(DESTDIR)$(libdir)
698 for i in $(INSTALL_LIBS); do \
701 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
702 $(RANLIB) $(DESTDIR)$(libdir)/`basename $$i` ;; \
704 $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
706 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
708 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
709 install_name_tool -id $(DESTDIR)$(libdir)/`basename $$i` $(DESTDIR)$(libdir)/`basename $$i` ;; \
711 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
715 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
716 $(INSTALL_DIR) $(DESTDIR)$(libexecdir)
717 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
718 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libexecdir); \
721 install_libexecs: $(INSTALL_LIBEXECS)
722 $(INSTALL_DIR) $(DESTDIR)$(libexecdir)
723 for i in $(INSTALL_LIBEXECS); do \
724 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(libexecdir); \
727 install_headers: $(INSTALL_HEADERS)
728 $(INSTALL_DIR) $(DESTDIR)$(headerdir)
729 for i in $(INSTALL_HEADERS); do \
730 $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
733 install_docs: $(INSTALL_HEADERS)
734 $(INSTALL_DIR) $(DESTDIR)$(docdir)
735 for i in $(INSTALL_DOCS); do \
736 $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir); \
738 $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html; \
739 for i in $(INSTALL_LIBRARY_DOCS); do \
740 $(INSTALL_DOC) $(INSTALL_OPTS) $$i $(DESTDIR)$(docdir)/libraries/; \
742 for i in $(INSTALL_HTML_DOC_DIRS); do \
743 $(INSTALL_DIR) $(INSTALL_OPTS) $(DESTDIR)$(docdir)/html/`basename $$i`; \
744 $(INSTALL_DOC) $(INSTALL_OPTS) $$i/* $(DESTDIR)$(docdir)/html/`basename $$i`; \
747 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(libdir)/package.conf
749 # Install packages in the right order, so that ghc-pkg doesn't complain.
750 # Also, install ghc-pkg first.
751 ifeq "$(Windows)" "NO"
752 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(libexecdir)/ghc-pkg
754 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
757 install_packages: install_libexecs
758 install_packages: libffi/package.conf.install rts/package.conf.install
759 $(INSTALL_DIR) $(DESTDIR)$(libdir)
760 "$(RM)" $(RM_OPTS) $(INSTALLED_PACKAGE_CONF)
761 $(CREATE_DATA) $(INSTALLED_PACKAGE_CONF)
762 echo "[]" >> $(INSTALLED_PACKAGE_CONF)
763 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update libffi/package.conf.install
764 "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf $(INSTALLED_PACKAGE_CONF) update rts/package.conf.install
765 $(foreach p, $(PACKAGES) $(PACKAGES_STAGE2),\
766 "$(GHC_CABAL_INPLACE)" install \
767 $(INSTALLED_GHC_PKG_REAL) \
768 $(INSTALLED_PACKAGE_CONF) \
769 libraries/$p dist-install \
770 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries' &&) true
771 "$(GHC_CABAL_INPLACE)" install \
772 $(INSTALLED_GHC_PKG_REAL) \
773 $(INSTALLED_PACKAGE_CONF) \
775 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries'
777 # -----------------------------------------------------------------------------
778 # Binary distributions
780 $(eval $(call bindist,.,\
782 configure config.sub config.guess install-sh \
786 $(INPLACE_BIN)/mkdirhier \
787 $(INPLACE_BIN)/ghc-cabal \
788 utils/ghc-pwd/ghc-pwd \
789 $(BINDIST_WRAPPERS) \
794 $(INSTALL_LIBEXECS) \
795 $(INSTALL_LIBEXEC_SCRIPTS) \
798 $(INSTALL_LIBRARY_DOCS) \
799 $(addsuffix /*,$(INSTALL_HTML_DOC_DIRS)) \
800 $(wildcard libraries/*/dist-install/doc/) \
801 $(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
802 $(filter-out %/project.mk,$(filter-out mk/config.mk,$(MAKEFILE_LIST))) \
803 mk/fix_install_names.sh \
806 libraries/dph/LICENSE \
808 # mk/project.mk gets an absolute path, so we manually include it in
809 # the bindist with a relative path
811 BIN_DIST_MK = $(BIN_DIST_NAME)/bindist.mk
814 "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
815 mkdir $(BIN_DIST_NAME)
816 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
817 echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
818 echo "LATEX_DOCS = $(LATEX_DOCS)" >> $(BIN_DIST_MK)
819 echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
820 echo "BUILD_DOCBOOK_PS = $(BUILD_DOCBOOK_PS)" >> $(BIN_DIST_MK)
821 echo "BUILD_DOCBOOK_PDF = $(BUILD_DOCBOOK_PDF)" >> $(BIN_DIST_MK)
822 ln -s ../distrib/configure-bin.ac $(BIN_DIST_NAME)/configure.ac
823 cd $(BIN_DIST_NAME) && autoreconf
824 "$(RM)" $(RM_OPTS) $(BIN_DIST_TAR)
825 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
826 # tree then we want to include the real file, not a symlink to it
827 "$(TAR)" hcf - -T $(BIN_DIST_LIST) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
830 "$(RM)" $(RM_OPTS) -r $(BIN_DIST_NAME)
831 $(MAKE) prefix=$(BIN_DIST_DIR) install
832 "$(TAR)" cf - $(BIN_DIST_NAME) | bzip2 -c > $(BIN_DIST_TAR_BZ2)
835 "$(ISCC)" /O. /F$(WINDOWS_INSTALLER_BASE) - < distrib/ghc.iss
837 nTimes = set -e; for i in `seq 1 $(1)`; do echo Try "$$i: $(2)"; if $(2); then break; fi; done
839 .PHONY: publish-binary-dist
841 $(call nTimes,10,$(PublishCp) $(BIN_DIST_TAR_BZ2) $(PublishLocation)/dist)
842 ifeq "$(mingw32_TARGET_OS)" "1"
843 $(call nTimes,10,$(PublishCp) $(WINDOWS_INSTALLER) $(PublishLocation)/dist)
848 $(call nTimes,10,$(PublishCp) -r bindisttest/installed/share/doc/ghc/* $(PublishLocation)/docs)
850 # -----------------------------------------------------------------------------
851 # Source distributions
859 # A source dist is built from a complete build tree, because we
860 # require some extra files not contained in a darcs checkout: the
861 # output from Happy and Alex, for example.
863 # The steps performed by 'make dist' are as follows:
864 # - create a complete link-tree of the current build tree in /tmp
865 # - run 'make distclean' on that tree
866 # - remove a bunch of other files that we know shouldn't be in the dist
867 # - tar up first the extralibs package, then the main source package
870 # Directory in which we're going to build the src dist
872 SRC_DIST_NAME=ghc-$(ProjectVersion)
873 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
876 # Files to include in source distributions
878 SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts compiler ghc driver libraries
880 configure.ac config.guess config.sub configure \
881 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
882 ghc.spec.in ghc.spec extra-gcc-opts.in VERSION \
883 boot boot-pkgs packages ghc.mk
885 SRC_DIST_TARBALL = $(SRC_DIST_NAME)-src.tar.bz2
888 echo $(ProjectVersion) >VERSION
893 # $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
894 # to copy the generated file that replaces compiler/cmm/CmmLex.x, where
895 # "stage2" is the dist dir.
897 if test -f $(TOP)/$1/$2/build/$4.hs; then \
898 "$(CP)" $(TOP)/$1/$2/build/$4.hs $1/$3/ ; \
899 mv $1/$3/$4.$5 $1/$3/$4.$5.source ;\
901 echo "does not exist: $1/$2//build/$4.hs"; \
907 "$(RM)" $(RM_OPTS) -r $(SRC_DIST_DIR)
908 "$(RM)" $(RM_OPTS) $(SRC_DIST_TARBALL)
909 mkdir $(SRC_DIST_DIR)
910 ( cd $(SRC_DIST_DIR) \
911 && for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i && lndir $(TOP)/$$i ); done \
912 && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done \
913 && $(MAKE) distclean \
914 && 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 \
915 && $(call sdist_file,compiler,stage2,cmm,CmmLex,x) \
916 && $(call sdist_file,compiler,stage2,cmm,CmmParse,y) \
917 && $(call sdist_file,compiler,stage2,main,ParsePkgConf,y) \
918 && $(call sdist_file,compiler,stage2,parser,HaddockLex,x) \
919 && $(call sdist_file,compiler,stage2,parser,HaddockParse,y) \
920 && $(call sdist_file,compiler,stage2,parser,Lexer,x) \
921 && $(call sdist_file,compiler,stage2,parser,Parser,y.pp) \
922 && $(call sdist_file,compiler,stage2,parser,ParserCore,y) \
923 && $(call sdist_file,utils/hpc,dist,,HpcParser,y) \
924 && $(call sdist_file,utils/genprimopcode,dist,,Lexer,x) \
925 && $(call sdist_file,utils/genprimopcode,dist,,Parser,y) \
926 && "$(RM)" $(RM_OPTS) -r compiler/stage[123] mk/build.mk \
927 && "$(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 \
932 "$(TAR)" chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
934 sdist-manifest : $(SRC_DIST_TARBALL)
935 tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
937 # Upload the distribution(s)
938 # Retrying is to work around buggy firewalls that corrupt large file transfers
940 ifneq "$(PublishLocation)" ""
942 $(call nTimes,10,$(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist)
945 ifeq "$(GhcUnregisterised)" "YES"
946 SRC_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
949 # -----------------------------------------------------------------------------
954 CLEAN_FILES += utils/ghc-pwd/ghc-pwd
955 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.exe
956 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.hi
957 CLEAN_FILES += utils/ghc-pwd/ghc-pwd.o
958 CLEAN_FILES += libraries/bootstrapping.conf
959 CLEAN_FILES += libraries/integer-gmp/gmp/gmp.h
960 CLEAN_FILES += libraries/integer-gmp/gmp/libgmp.a
961 CLEAN_FILES += libraries/integer-gmp/cbits/GmpDerivedConstants.h
962 CLEAN_FILES += libraries/integer-gmp/cbits/mkGmpDerivedConstants
964 clean : clean_files clean_libraries clean_gmp
968 "$(RM)" $(RM_OPTS) $(CLEAN_FILES)
971 "$(RM)" $(RM_OPTS) -r libraries/integer-gmp/gmp/objs
972 "$(RM)" $(RM_OPTS) -r libraries/integer-gmp/gmp/gmpbuild
974 .PHONY: clean_libraries
975 clean_libraries: $(patsubst %,clean_libraries/%_dist-install,$(PACKAGES) $(PACKAGES_STAGE2))
976 clean_libraries: $(patsubst %,clean_libraries/%_dist-boot,$(BOOT_PKGS))
979 "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/dist, $(PACKAGES) $(PACKAGES_STAGE2))
980 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/*.buildinfo, $(PACKAGES) $(PACKAGES_STAGE2))
982 # We have to define a clean target for each library manually, because the
983 # libraries/*/ghc.mk files are not included when we're cleaning.
984 ifeq "$(CLEANING)" "YES"
985 $(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),\
986 $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
990 "$(RM)" $(RM_OPTS) config.cache config.status config.log mk/config.h mk/stamp-h
991 "$(RM)" $(RM_OPTS) mk/config.mk mk/are-validating.mk mk/project.mk
992 "$(RM)" $(RM_OPTS) mk/config.mk.old mk/project.mk.old
993 "$(RM)" $(RM_OPTS) extra-gcc-opts docs/users_guide/ug-book.xml
994 "$(RM)" $(RM_OPTS) compiler/ghc.cabal compiler/ghc.cabal.old
995 "$(RM)" $(RM_OPTS) ghc/ghc-bin.cabal
996 "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h
997 "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h
998 "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h
999 "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h
1000 "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h
1002 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.log, $(PACKAGES) $(PACKAGES_STAGE2))
1003 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/config.status, $(PACKAGES) $(PACKAGES_STAGE2))
1004 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/include/Hs*Config.h, $(PACKAGES) $(PACKAGES_STAGE2))
1005 "$(RM)" $(RM_OPTS) -r $(patsubst %, libraries/%/autom4te.cache, $(PACKAGES) $(PACKAGES_STAGE2))
1007 maintainer-clean : distclean
1008 "$(RM)" $(RM_OPTS) configure mk/config.h.in
1009 "$(RM)" $(RM_OPTS) -r autom4te.cache libraries/*/autom4te.cache
1010 "$(RM)" $(RM_OPTS) ghc.spec
1011 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/GNUmakefile, \
1012 $(PACKAGES) $(PACKAGES_STAGE2))
1013 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/ghc.mk, $(PACKAGES) $(PACKAGES_STAGE2))
1014 "$(RM)" $(RM_OPTS) $(patsubst %, libraries/%/configure, \
1015 $(PACKAGES) $(PACKAGES_STAGE2))
1016 "$(RM)" $(RM_OPTS) libraries/base/include/HsBaseConfig.h.in
1017 "$(RM)" $(RM_OPTS) libraries/directory/include/HsDirectoryConfig.h.in
1018 "$(RM)" $(RM_OPTS) libraries/process/include/HsProcessConfig.h.in
1019 "$(RM)" $(RM_OPTS) libraries/unix/include/HsUnixConfig.h.in
1020 "$(RM)" $(RM_OPTS) libraries/old-time/include/HsTimeConfig.h.in
1022 .PHONY: all_libraries
1024 .PHONY: bootstrapping-files
1025 bootstrapping-files: $(OTHER_LIBS)
1026 bootstrapping-files: includes/ghcautoconf.h
1027 bootstrapping-files: includes/DerivedConstants.h
1028 bootstrapping-files: includes/GHCConstants.h