3 # Before we can merge the new build system into HEAD:
5 # * finish installation
6 # * other documentation
7 # * create doc index and contents
8 # * Windows: should we have ghc-pkg-<version>?
9 # * should we be stripping things?
10 # * install libgmp.a, gmp.h
11 # * finish binary distributions
12 # * need to fix Cabal for new Windows layout, see
13 # Distribution/Simple/GHC.configureToolchain.
15 # As we merge the new build system into HEAD:
17 # * remove old Makefiles, add new stubs for building in subdirs
18 # * utils/hsc2hs/Makefile
19 # * utils/haddock/Makefile
20 # * mk/oldconfig.mk.in
22 # Once the new build system is in HEAD, and before 6.12:
24 # * docbook PDFs, e.g. "dblatex -T db2latex users_guide.xml"
26 # * optionally install stage3?
27 # * why does so much stuff get rebuilt after re-configuring?
28 # * shared libraries, way dyn
29 # * add pointers to wiki docs from the build system source
30 # * get HC bootstrapping working
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 # * 2966 make sure --with-gcc does the right thing (#2966)
37 # * 1693 make distclean
38 # * 2689 make maintainer-clean
39 # * 3173 make install with DESTDIR
43 # * per-source-file dependencies instead of one .depend file?
44 # * eliminate undefined variables, and use --warn-undefined-variables?
45 # * perhaps we should make all the output dirs in the .depend rule, to
46 # avoid all these mkdirhier calls?
47 # * put outputs from different ways in different subdirs of distdir/build,
48 # then we don't have to use -osuf/-hisuf. We would have to install
49 # them in different places too, so we'd need ghc-pkg support for packages
51 # * make PACKAGES generated by configure or sh boot?
52 # * we should use a directory of package.conf files rather than a single
53 # file for the inplace package database, so that we can express
54 # dependencies more accurately. Otherwise it's possible to get into
55 # a state where the package database is out of date, and the build
56 # system doesn't know.
58 # NOTES on how to debug:
59 # make --debug=b --debug=m shows dependencies
60 # make -p prints all generated makefile rules and variables
61 # make show VALUE=VAR prints the value of VAR
62 # $(warning stuff) prints stuff when reading the makefile
64 # Approximate build order.
66 # The actual build order is defined by dependencies, and the phase
67 # ordering used to ensure correct ordering of makefile-generation; see
68 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering
70 # * With bootstrapping compiler:
71 # o Build utils/ghc-cabal
72 # o Build utils/ghc-pkg
73 # o Build utils/hsc2hs
75 # o configure, generate package-data.mk and inplace-pkg-info
76 # o register each package into inplace/lib/package.conf
78 # * With bootstrapping compiler:
79 # o Build libraries/{filepath,hpc,extensible-exceptions,Cabal}
80 # o Build compiler (stage 1)
84 # o Build utils/* (except haddock)
85 # o Build compiler (stage 2)
87 # o Build utils/haddock
88 # o Build compiler (stage 3) (optional)
95 # Just bring makefiles up to date:
96 .PHONY: just-makefiles
100 # -----------------------------------------------------------------------------
101 # Misc GNU make utils
104 space=$(nothing) $(nothing)
107 # Cancel all suffix rules. Ideally we'd like to have 'make -r' turned on
108 # by default, because that disables all the implicit rules, but there doesn't
109 # seem to be a good way to do that. This turns off all the old-style suffix
110 # rules, which does half the job and speeds up make quite a bit:
113 # -----------------------------------------------------------------------------
115 # to see the effective value used for a Makefile variable, do
116 # make show VALUE=MY_VALUE
120 @echo '$(VALUE)="$($(VALUE))"'
122 # -----------------------------------------------------------------------------
123 # Include subsidiary build-system bits
127 ifeq "$(ProjectVersion)" ""
128 $(error Please run ./configure first)
131 # (Optional) build-specific configuration
132 include mk/custom-settings.mk
134 ifeq "$(GhcLibWays)" ""
135 $(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.
156 NO_INCLUDE_PKGDATA = NO
157 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
158 NO_INCLUDE_DEPS = YES
159 NO_INCLUDE_PKGDATA = YES
161 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
162 NO_INCLUDE_DEPS = YES
163 # We want package-data.mk for show
166 # We don't haddock base3-compat, as it has the same package name as base
167 libraries/base3-compat_dist-install_DO_HADDOCK = NO
169 # We don't haddock the bootstrapping libraries
170 libraries/hpc_dist-boot_DO_HADDOCK = NO
171 libraries/Cabal_dist-boot_DO_HADDOCK = NO
172 libraries/extensible-exceptions_dist-boot_DO_HADDOCK = NO
173 libraries/filepath_dist-boot_DO_HADDOCK = NO
175 # -----------------------------------------------------------------------------
178 include rules/way-prelims.mk
180 $(foreach way,$(ALL_WAYS),\
181 $(eval $(call way-prelims,$(way))))
183 # -----------------------------------------------------------------------------
186 include rules/distdir-opts.mk
187 include rules/distdir-way-opts.mk
189 # -----------------------------------------------------------------------------
190 # Finding source files and object files
192 include rules/hs-sources.mk
193 include rules/c-sources.mk
194 include rules/includes-sources.mk
195 include rules/hs-objs.mk
196 include rules/c-objs.mk
198 # -----------------------------------------------------------------------------
201 include rules/hs-suffix-rules-srcdir.mk
202 include rules/hs-suffix-rules.mk
204 # -----------------------------------------------------------------------------
205 # Suffix rules for .hi files
207 include rules/hi-rule.mk
209 $(foreach way,$(ALL_WAYS),\
210 $(eval $(call hi-rule,$(way))))
212 #-----------------------------------------------------------------------------
213 # C-related suffix rules
215 include rules/c-suffix-rules.mk
217 # -----------------------------------------------------------------------------
218 # Building package-data.mk files from .cabal files
220 include rules/package-config.mk
222 # -----------------------------------------------------------------------------
223 # Building dependencies
225 include rules/build-dependencies.mk
227 # -----------------------------------------------------------------------------
228 # Build package-data.mk files
230 include rules/build-package-data.mk
232 # -----------------------------------------------------------------------------
233 # Build and install a program
235 include rules/build-prog.mk
236 include rules/shell-wrapper.mk
238 # -----------------------------------------------------------------------------
239 # Build a perl script
241 include rules/build-perl.mk
243 # -----------------------------------------------------------------------------
246 include rules/build-package.mk
247 include rules/build-package-way.mk
248 include rules/haddock.mk
250 # -----------------------------------------------------------------------------
251 # Registering hand-written package descriptions (used in libffi and rts)
253 include rules/manual-package-config.mk
255 # -----------------------------------------------------------------------------
258 include rules/docbook.mk
260 # -----------------------------------------------------------------------------
263 include rules/bindist.mk
265 # -----------------------------------------------------------------------------
268 # XXX generate from $(TOP)/packages
278 ifeq "$(Windows)" "YES"
290 extensible-exceptions \
300 BOOT_PKGS = Cabal hpc extensible-exceptions
302 # The actual .a files: needed for dependencies.
303 ALL_LIBS = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_v_LIB))
304 BOOT_LIBS = $(foreach lib,$(BOOT_PKGS),$(libraries/$(lib)_dist-boot_v_LIB))
306 OTHER_LIBS = libffi/libHSffi.a libffi/HSffi.o
307 ifeq "$(HaveLibGmp)" "NO"
308 OTHER_LIBS += gmp/libgmp.a
311 # We cannot run ghc-cabal to configure a package until we have
312 # configured and registered all of its dependencies. So the following
313 # hack forces all the configure steps to happen in exactly the order
314 # given in the PACKAGES variable above. Ideally we should use the
315 # correct dependencies here to allow more parallelism, but we don't
316 # know the dependencies until we've generated the pacakge-data.mk
319 libraries/$1/$2/package-data.mk : $(GHC_PKG_INPLACE) $$(if $$(fixed_pkg_prev),libraries/$$(fixed_pkg_prev)/$2/package-data.mk)
323 ifneq "$(BINDIST)" "YES"
325 $(foreach pkg,$(PACKAGES),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
327 # We assume that the stage2 compiler depends on all the libraries, so
328 # they all get added to the package database before we try to configure
330 compiler/stage2/package-data.mk: $(foreach pkg,$(PACKAGES),libraries/$(pkg)/dist-install/package-data.mk)
331 # haddock depends on ghc and some libraries, but depending on GHC's
332 # package-data.mk is sufficient, as that in turn depends on all the
334 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
336 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
338 # add the final two package.conf dependencies: ghc-prim depends on RTS,
339 # and RTS depends on libffi.
340 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
341 rts/package.conf.inplace : libffi/package.conf.inplace
344 # -----------------------------------------------------------------------------
345 # Special magic for the ghc-prim package
347 # We want the ghc-prim package to include the GHC.Prim module when it
348 # is registered, but not when it is built, because GHC.Prim is not a
349 # real source module, it is built-in to GHC. The old build system did
350 # this using Setup.hs, but we can't do that here, so we have a flag to
351 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
352 # remains compatible with the old build system for the time being).
353 # GHC.Prim module in the ghc-prim package with a flag:
355 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
357 # And then we strip it out again before building the package:
358 define libraries/ghc-prim_PACKAGE_MAGIC
359 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
362 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
364 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
365 $(MKDIRHIER) $(dir $@)
366 $(GENPRIMOP_INPLACE) --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
368 libraries/ghc-prim/GHC/Prim.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
369 $(GENPRIMOP_INPLACE) --make-haskell-source <$(PRIMOPS_TXT) >$@
372 # -----------------------------------------------------------------------------
373 # Include build instructions from all subdirs
375 # See commentary in the top-level Makefile for why we divide the build
378 # Setting foo_dist_DISABLE=YES means "in directory foo, for build
379 # "dist", just read the package-data.mk file, do not build anything".
381 # We carefully engineer things so that we can build the
382 # package-data.mk files early on: they depend only on a few tools also
383 # built early. Having got the package-data.mk files built, we can
384 # restart make with up-to-date information about all the packages
385 # (this is phase 0). The remaining problem is the .depend files:
387 # - .depend files in libraries need the stage 1 compiler to build
388 # - ghc/stage1/.depend needs compiler/stage1 built
389 # - compiler/stage1/.depend needs the bootstrap libs built
391 # GHC 6.11+ can build a .depend file without having built the
392 # dependencies of the package, but we can't rely on the bootstrapping
393 # compiler being able to do this, which is why we have to separate the
394 # three phases above.
396 # So this is the final ordering:
398 # Phase 0 : all package-data.mk files
399 # (requires ghc-cabal, ghc-pkg, mkdirhier, dummy-ghc etc.)
400 # Phase 1 : .depend files for bootstrap libs
402 # Phase 2 : compiler/stage1/.depend
403 # (requires bootstrap libs and genprimopcode)
404 # Phase 3 : ghc/stage1/.depend
405 # (requires compiler/stage1)
407 # The rest : libraries/*/dist-install, compiler/stage2, ghc/stage2
411 ifneq "$(BINDIST)" "YES"
413 $(GHC_MKDEPENDC_DIR) \
420 libraries/Cabal/doc \
426 ifneq "$(BINDIST)" "YES"
439 ifneq "$(BINDIST)" "YES"
447 $(patsubst %, libraries/%, $(PACKAGES)) \
455 ifeq "$(Windows)" "YES"
460 # XXX libraries/% must come before any programs built with stage1, see
461 # Note [lib-depends].
464 $(foreach lib,$(BOOT_PKGS),$(eval \
465 libraries/$(lib)_dist-boot_DISABLE = YES))
468 ifneq "$(findstring $(phase),0 1)" ""
469 # We can build deps for compiler/stage1 in phase 2
470 compiler_stage1_DISABLE = YES
473 ifneq "$(findstring $(phase),0 1 2)" ""
474 ghc_stage1_DISABLE = YES
477 ifneq "$(findstring $(phase),0 1 2 3)" ""
478 # In phases 0-3, we disable stage2-3, the full libraries and haddock
479 utils/haddock_dist_DISABLE = YES
480 utils/runghc_dist_DISABLE = YES
481 utils/hpc_dist_DISABLE = YES
482 utils/hasktags_dist_DISABLE = YES
483 utils/hsc2hs_dist-install_DISABLE = YES
484 utils/ghc-pkg_dist-install_DISABLE = YES
485 compiler_stage2_DISABLE = YES
486 compiler_stage3_DISABLE = YES
487 ghc_stage2_DISABLE = YES
488 ghc_stage3_DISABLE = YES
489 $(foreach lib,$(PACKAGES),$(eval \
490 libraries/$(lib)_dist-install_DISABLE = YES))
493 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
495 # We need -fno-warn-deprecated-flags to avoid failure with -Werror
496 GhcLibHcOpts += -fno-warn-deprecated-flags
497 ifeq "$(ghc_ge_609)" "YES"
498 GhcBootLibHcOpts += -fno-warn-deprecated-flags
501 # Add $(GhcLibHcOpts) to all library builds
502 $(foreach pkg,$(PACKAGES),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
504 # XXX we configure packages with the bootsrapping compiler (for
505 # dependency reasons, see the phase ordering), which doesn't
506 # necessarily support all the extensions we need, and Cabal filters
507 # out the ones it thinks aren't supported.
508 libraries/base3-compat_dist-install_HC_OPTS += -XPackageImports
510 # -----------------------------------------------------------------------------
511 # Bootstrapping libraries
513 # We need to build a few libraries with the installed GHC, since GHC itself
514 # and some of the tools depend on them:
516 ifneq "$(BINDIST)" "YES"
518 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
519 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
522 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
524 # These three libraries do not depend on each other, so we can build
527 $(eval $(call build-package,libraries/hpc,dist-boot,0))
528 $(eval $(call build-package,libraries/extensible-exceptions,dist-boot,0))
529 $(eval $(call build-package,libraries/Cabal,dist-boot,0))
531 # register the boot packages in strict sequence, because running
532 # multiple ghc-pkgs in parallel doesn't work (registrations may get
535 $(foreach pkg,$(BOOT_PKGS),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
537 compiler/stage1/package-data.mk : \
538 libraries/Cabal/dist-boot/package-data.mk \
539 libraries/hpc/dist-boot/package-data.mk \
540 libraries/extensible-exceptions/dist-boot/package-data.mk
542 # These are necessary because the bootstrapping compiler may not know
543 # about cross-package dependencies:
544 $(compiler_stage1_depfile) : $(BOOT_LIBS)
545 $(ghc_stage1_depfile) : $(compiler_stage1_v_LIB)
547 $(foreach pkg,$(BOOT_PKGS),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
551 # -----------------------------------------------------------------------------
552 # Creating a local mingw copy on Windows
554 ifeq "$(Windows)" "YES"
556 # directories don't work well as dependencies, hence a stamp file
557 $(INPLACE)/stamp-mingw : $(MKDIRHIER)
558 $(MKDIRHIER) $(INPLACE_MINGW)/bin
559 GCC=`type -p $(WhatGccIsCalled)`; \
560 GccDir=`dirname $$GCC`; \
561 $(CP) -p $$GccDir/{gcc.exe,ar.exe,as.exe,dlltool.exe,dllwrap.exe,windres.exe} $(INPLACE_MINGW)/bin; \
562 $(CP) -Rp $$GccDir/../include $(INPLACE_MINGW); \
563 $(CP) -Rp $$GccDir/../lib $(INPLACE_MINGW); \
564 $(CP) -Rp $$GccDir/../libexec $(INPLACE_MINGW); \
565 $(CP) -Rp $$GccDir/../mingw32 $(INPLACE_MINGW)
566 touch $(INPLACE)/stamp-mingw
568 install : install_mingw
569 .PHONY: install_mingw
570 install_mingw : $(INPLACE_MINGW)
571 $(CP) -Rp $(INPLACE_MINGW) $(prefix)
573 $(INPLACE_LIB)/perl.exe $(INPLACE_LIB)/perl56.dll :
574 $(CP) $(GhcDir)../{perl.exe,perl56.dll} $(INPLACE_LIB)
578 libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock: \
579 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs \
580 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs
582 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
583 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
584 $(MKDIRHIER) $(dir $@)
585 $(GENPRIMOP_INPLACE) --make-haskell-source < $< > $@
587 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
588 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
589 $(MKDIRHIER) $(dir $@)
590 $(GENPRIMOP_INPLACE) --make-haskell-wrappers < $< > $@
592 # -----------------------------------------------------------------------------
595 install: install_packages install_libs install_libexecs install_headers \
596 install_libexec_scripts install_bins
598 install_bins: $(INSTALL_BINS)
599 $(INSTALL_DIR) $(DESTDIR)$(bindir)
600 for i in $(INSTALL_BINS); do \
601 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ; \
602 if test "$(darwin_TARGET_OS)" = "1"; then \
603 sh mk/fix_install_names.sh $(libdir) $(DESTDIR)$(bindir)/$$i ; \
607 install_libs: $(INSTALL_LIBS)
608 $(INSTALL_DIR) $(DESTDIR)$(libdir)
609 for i in $(INSTALL_LIBS); do \
612 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
613 $(RANLIB) $(DESTDIR)$(libdir)/`basename $$i` ;; \
615 $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
617 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
619 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
620 install_name_tool -id $(DESTDIR)$(libdir)/`basename $$i` $(DESTDIR)$(libdir)/`basename $$i` ;; \
622 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
626 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
627 $(MKDIRHIER) $(DESTDIR)$(libexecdir)
628 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
629 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libexecdir); \
632 install_libexecs: $(INSTALL_LIBEXECS)
633 $(MKDIRHIER) $(DESTDIR)$(libexecdir)
634 for i in $(INSTALL_LIBEXECS); do \
635 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(libexecdir); \
638 install_headers: $(INSTALL_HEADERS)
639 $(INSTALL_DIR) $(DESTDIR)$(headerdir)
640 for i in $(INSTALL_HEADERS); do \
641 $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
644 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(libdir)/package.conf
646 # Install packages in the right order, so that ghc-pkg doesn't complain.
647 # Also, install ghc-pkg first.
648 ifeq "$(Windows)" "NO"
649 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(libexecdir)/ghc-pkg
651 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
654 install_packages: install_libexecs
655 install_packages: libffi/package.conf.install rts/package.conf.install
656 $(MKDIRHIER) $(DESTDIR)$(libdir)
657 echo "[]" > $(INSTALLED_PACKAGE_CONF)
658 $(INSTALLED_GHC_PKG_REAL) --force --global-conf $(INSTALLED_PACKAGE_CONF) update libffi/package.conf.install
659 $(INSTALLED_GHC_PKG_REAL) --force --global-conf $(INSTALLED_PACKAGE_CONF) update rts/package.conf.install
660 $(foreach p, $(PACKAGES),\
661 $(GHC_CABAL_INPLACE) install \
662 $(INSTALLED_GHC_PKG_REAL) \
663 $(INSTALLED_PACKAGE_CONF) \
664 libraries/$p dist-install \
665 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries' &&) true
666 $(GHC_CABAL_INPLACE) install \
667 $(INSTALLED_GHC_PKG_REAL) \
668 $(INSTALLED_PACKAGE_CONF) \
670 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries'
672 # -----------------------------------------------------------------------------
673 # Binary distributions
675 $(eval $(call bindist,.,\
677 configure config.sub config.guess \
681 $(INPLACE_BIN)/mkdirhier \
682 $(INPLACE_BIN)/ghc-cabal \
684 $(BINDIST_WRAPPERS) \
689 $(INSTALL_LIBEXECS) \
690 $(INSTALL_LIBEXEC_SCRIPTS) \
692 $(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
693 $(filter-out %/project.mk,$(filter-out mk/config.mk,$(MAKEFILE_LIST))) \
694 mk/fix_install_names.sh \
697 # mk/project.mk gets an absolute path, so we manually include it in
698 # the bindist with a relative path
701 $(RM) -rf $(BIN_DIST_NAME)
702 mkdir $(BIN_DIST_NAME)
703 set -e; for i in LICENSE compiler ghc rts libraries utils gmp docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess extra-gcc-opts.in ghc.mk inplace; do ln -s ../$$i $(BIN_DIST_NAME)/; done
704 ln -s ../distrib/configure-bin.ac $(BIN_DIST_NAME)/configure.ac
705 cd $(BIN_DIST_NAME) && autoreconf
706 $(RM) -f $(BIN_DIST_TAR)
707 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
708 # tree then we want to include the real file, not a symlink to it
709 $(TAR) hcf $(BIN_DIST_TAR) -T $(BIN_DIST_LIST)
710 bzip2 < $(BIN_DIST_TAR) > $(BIN_DIST_TAR_BZ2)
712 # -----------------------------------------------------------------------------
713 # Source distributions
721 # A source dist is built from a complete build tree, because we
722 # require some extra files not contained in a darcs checkout: the
723 # output from Happy and Alex, for example.
725 # The steps performed by 'make dist' are as follows:
726 # - create a complete link-tree of the current build tree in /tmp
727 # - run 'make distclean' on that tree
728 # - remove a bunch of other files that we know shouldn't be in the dist
729 # - tar up first the extralibs package, then the main source package
732 # Directory in which we're going to build the src dist
734 SRC_DIST_NAME=ghc-$(ProjectVersion)
735 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
738 # Files to include in source distributions
740 SRC_DIST_DIRS = mk rules docs distrib bindisttest gmp libffi includes utils docs rts compiler ghc driver libraries
742 configure.ac config.guess config.sub configure \
743 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
744 ghc.spec.in ghc.spec extra-gcc-opts.in VERSION boot ghc.mk
746 EXTRA_LIBS=$(patsubst %, $(SRC_DIST_NAME)/%, $(shell grep -E "extralibs|dph" packages | grep -v "^\#" | sed "s/ .*//"))
748 SRC_DIST_TARBALL = ghc-$(ProjectVersion)-src.tar.bz2
749 SRC_DIST_EXTRALIBS_TARBALL = ghc-$(ProjectVersion)-src-extralibs.tar.bz2
752 echo $(ProjectVersion) >VERSION
757 # $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
758 # to copy the generated file that replaces compiler/cmm/CmmLex.x, where
759 # "stage2" is the dist dir.
761 if test -f $(TOP)/$1/$2/build/$4.hs; then \
762 $(CP) $(TOP)/$1/$2/build/$4.hs $1/$3/ ; \
763 mv $1/$3/$4.$5 $1/$3/$4.$5.source ;\
765 echo "does not exist: $1/$2//build/$4.hs"; \
771 $(RM) -rf $(SRC_DIST_DIR)
772 $(RM) $(SRC_DIST_NAME).tar.gz
773 mkdir $(SRC_DIST_DIR)
774 ( cd $(SRC_DIST_DIR) \
775 && for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i && lndir $(TOP)/$$i ); done \
776 && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done \
777 && $(MAKE) distclean \
778 && 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 \
779 && $(call sdist_file,compiler,stage2,cmm,CmmLex,x) \
780 && $(call sdist_file,compiler,stage2,cmm,CmmParse,y) \
781 && $(call sdist_file,compiler,stage2,main,ParsePkgConf,y) \
782 && $(call sdist_file,compiler,stage2,parser,HaddockLex,x) \
783 && $(call sdist_file,compiler,stage2,parser,HaddockParse,y) \
784 && $(call sdist_file,compiler,stage2,parser,Lexer,x) \
785 && $(call sdist_file,compiler,stage2,parser,Parser,y.pp) \
786 && $(call sdist_file,compiler,stage2,parser,ParserCore,y) \
787 && $(call sdist_file,utils/hpc,dist,,HpcParser,y) \
788 && $(call sdist_file,utils/genprimopcode,dist,,Lexer,x) \
789 && $(call sdist_file,utils/genprimopcode,dist,,Parser,y) \
790 && $(RM) -rf compiler/stage[123] mk/build.mk \
791 && $(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) -rf \
796 $(TAR) chf - $(EXTRA_LIBS) | bzip2 >$(TOP)/$(SRC_DIST_EXTRALIBS_TARBALL)
797 $(RM) -rf $(EXTRA_LIBS)
798 $(TAR) chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
800 sdist-manifest : $(SRC_DIST_TARBALL)
801 tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
803 # Upload the distribution(s)
804 # Retrying is to work around buggy firewalls that corrupt large file transfers
806 ifneq "$(PublishLocation)" ""
808 @for i in 0 1 2 3 4 5 6 7 8 9; do \
809 echo "Try $$i: $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist"; \
810 if $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist; then break; fi; \
812 @for i in 0 1 2 3 4 5 6 7 8 9; do \
813 echo "Try $$i: $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist"; \
814 if $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist; then break; fi; \
818 # -----------------------------------------------------------------------------
829 $(RM) config.cache config.status config.log mk/config.h mk/stamp-h
830 $(RM) mk/config.mk mk/are-validating.mk
831 $(RM) extra-gcc-opts docs/users_guide/ug-book.xml
832 $(RM) compiler/ghc.cabal ghc/ghc-bin.cabal
833 $(RM) libraries/base/include/HsBaseConfig.h
834 $(RM) libraries/directory/include/HsDirectoryConfig.h
836 maintainer-clean : distclean
838 $(RM) libraries/*/GNUmakefile