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 # * 2744 check for presence of hsc2hs in ./configure
37 # * 2966 make sure --with-gcc does the right thing (#2966)
38 # * 3115 make ghc.cabal read-only
39 # * 2107 install the docs by default
40 # * 1693 make distclean
41 # * 2689 make maintainer-clean
42 # * 2619 bootstrapping using a newer GHC shouldn't fail
43 # for bogus reasons (picking the wrong version of the ghc package)
44 # * 2770 check which version of gcc we require
45 # * 3173 make install with DESTDIR
49 # * per-source-file dependencies instead of one .depend file?
50 # * eliminate undefined variables, and use --warn-undefined-variables?
51 # * perhaps we should make all the output dirs in the .depend rule, to
52 # avoid all these mkdirhier calls?
53 # * put outputs from different ways in different subdirs of distdir/build,
54 # then we don't have to use -osuf/-hisuf. We would have to install
55 # them in different places too, so we'd need ghc-pkg support for packages
57 # * make PACKAGES generated by configure or sh boot?
58 # * we should use a directory of package.conf files rather than a single
59 # file for the inplace package database, so that we can express
60 # dependencies more accurately. Otherwise it's possible to get into
61 # a state where the package database is out of date, and the build
62 # system doesn't know.
64 # NOTES on how to debug:
65 # make --debug=b --debug=m shows dependencies
66 # make -p prints all generated makefile rules and variables
67 # make show VALUE=VAR prints the value of VAR
68 # $(warning stuff) prints stuff when reading the makefile
72 # * With bootstrapping compiler:
73 # o Build libraries/{hpc,extensible-exceptions,Cabal}
74 # o Build utils/ghc-pkg
75 # o Build utils/ghc-cabal
76 # * With bootstrapping compiler and ghc-cabal:
77 # o Build utils/hsc2hs
78 # o Build libraries/hpc
79 # o Build compiler (stage 1)
81 # o generate package-data.mk and inplace-pkg-info
82 # o register each package into inplace/lib/package.conf
83 # o generate .depend for each package
86 # o Build utils/* (except haddock)
87 # o Build compiler (stage 2)
89 # o Build utils/haddock
90 # o Build compiler (stage 3)
97 # Just bring makefiles up to date:
98 .PHONY: just-makefiles
102 # -----------------------------------------------------------------------------
103 # Misc GNU make utils
106 space=$(nothing) $(nothing)
109 # Cancel all suffix rules. Ideally we'd like to have 'make -r' turned on
110 # by default, because that disables all the implicit rules, but there doesn't
111 # seem to be a good way to do that. This turns off all the old-style suffix
112 # rules, which does half the job and speeds up make quite a bit:
115 # -----------------------------------------------------------------------------
117 # to see the effective value used for a Makefile variable, do
118 # make show VALUE=MY_VALUE
122 @echo '$(VALUE)="$($(VALUE))"'
124 # -----------------------------------------------------------------------------
125 # Include subsidiary build-system bits
129 ifeq "$(ProjectVersion)" ""
130 $(error Please run ./configure first)
133 # (Optional) build-specific configuration
134 include mk/custom-settings.mk
136 ifeq "$(GhcLibWays)" ""
137 $(error $$(GhcLibWays) is empty, it must contain at least one way)
140 # -----------------------------------------------------------------------------
141 # Macros for standard targets
143 include rules/all-target.mk
144 include rules/clean-target.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.
158 NO_INCLUDE_PKGDATA = NO
159 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
160 NO_INCLUDE_DEPS = YES
161 NO_INCLUDE_PKGDATA = YES
163 ifeq "$(findstring show,$(MAKECMDGOALS))" "show"
164 NO_INCLUDE_DEPS = YES
165 # We want package-data.mk for show
168 # We don't haddock base3-compat, as it has the same package name as base
169 libraries/base3-compat_dist-install_DO_HADDOCK = NO
171 # We don't haddock the bootstrapping libraries
172 libraries/hpc_dist-boot_DO_HADDOCK = NO
173 libraries/Cabal_dist-boot_DO_HADDOCK = NO
174 libraries/extensible-exceptions_dist-boot_DO_HADDOCK = NO
175 libraries/filepath_dist-boot_DO_HADDOCK = NO
177 # -----------------------------------------------------------------------------
180 include rules/way-prelims.mk
182 $(foreach way,$(ALL_WAYS),\
183 $(eval $(call way-prelims,$(way))))
185 # -----------------------------------------------------------------------------
188 include rules/distdir-opts.mk
189 include rules/distdir-way-opts.mk
191 # -----------------------------------------------------------------------------
192 # Finding source files and object files
194 include rules/hs-sources.mk
195 include rules/c-sources.mk
196 include rules/includes-sources.mk
197 include rules/hs-objs.mk
198 include rules/c-objs.mk
200 # -----------------------------------------------------------------------------
203 include rules/hs-suffix-rules-srcdir.mk
204 include rules/hs-suffix-rules.mk
206 # -----------------------------------------------------------------------------
207 # Suffix rules for .hi files
209 include rules/hi-rule.mk
211 $(foreach way,$(ALL_WAYS),\
212 $(eval $(call hi-rule,$(way))))
214 #-----------------------------------------------------------------------------
215 # C-related suffix rules
217 include rules/c-suffix-rules.mk
219 # -----------------------------------------------------------------------------
220 # Building package-data.mk files from .cabal files
222 include rules/package-config.mk
224 # -----------------------------------------------------------------------------
225 # Building dependencies
227 include rules/build-dependencies.mk
229 # -----------------------------------------------------------------------------
230 # Build package-data.mk files
232 include rules/build-package-data.mk
234 # -----------------------------------------------------------------------------
235 # Build and install a program
237 include rules/build-prog.mk
238 include rules/shell-wrapper.mk
240 # -----------------------------------------------------------------------------
241 # Build a perl script
243 include rules/build-perl.mk
245 # -----------------------------------------------------------------------------
248 include rules/build-package.mk
249 include rules/build-package-way.mk
250 include rules/haddock.mk
252 # -----------------------------------------------------------------------------
253 # Registering hand-written package descriptions (used in libffi and rts)
255 include rules/manual-package-config.mk
257 # -----------------------------------------------------------------------------
260 include rules/docbook.mk
262 # -----------------------------------------------------------------------------
265 include rules/bindist.mk
267 # -----------------------------------------------------------------------------
270 # XXX generate from $(TOP)/packages
280 ifeq "$(Windows)" "YES"
292 extensible-exceptions \
302 BOOT_PKGS = Cabal hpc extensible-exceptions
304 # The actual .a files: needed for dependencies.
305 ALL_LIBS = $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_v_LIB))
306 BOOT_LIBS = $(foreach lib,$(BOOT_PKGS),$(libraries/$(lib)_dist-boot_v_LIB))
308 OTHER_LIBS = libffi/libHSffi.a libffi/HSffi.o
309 ifeq "$(HaveLibGmp)" "NO"
310 OTHER_LIBS += gmp/libgmp.a
313 # We cannot run ghc-cabal to configure a package until we have
314 # configured and registered all of its dependencies. So the following
315 # hack forces all the configure steps to happen in exactly the order
316 # given in the PACKAGES variable above. Ideally we should use the
317 # correct dependencies here to allow more parallelism, but we don't
318 # know the dependencies until we've generated the pacakge-data.mk
321 libraries/$1/$2/package-data.mk : $(GHC_PKG_INPLACE) $$(if $$(fixed_pkg_prev),libraries/$$(fixed_pkg_prev)/$2/package-data.mk)
325 ifneq "$(BINDIST)" "YES"
327 $(foreach pkg,$(PACKAGES),$(eval $(call fixed_pkg_dep,$(pkg),dist-install)))
329 # We assume that the stage2 compiler depends on all the libraries, so
330 # they all get added to the package database before we try to configure
332 compiler/stage2/package-data.mk: $(foreach pkg,$(PACKAGES),libraries/$(pkg)/dist-install/package-data.mk)
333 # haddock depends on ghc and some libraries, but depending on GHC's
334 # package-data.mk is sufficient, as that in turn depends on all the
336 utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk
338 utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
340 # add the final two package.conf dependencies: ghc-prim depends on RTS,
341 # and RTS depends on libffi.
342 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
343 rts/package.conf.inplace : libffi/package.conf.inplace
346 # -----------------------------------------------------------------------------
347 # Special magic for the ghc-prim package
349 # We want the ghc-prim package to include the GHC.Prim module when it
350 # is registered, but not when it is built, because GHC.Prim is not a
351 # real source module, it is built-in to GHC. The old build system did
352 # this using Setup.hs, but we can't do that here, so we have a flag to
353 # enable GHC.Prim in the .cabal file (so that the ghc-prim package
354 # remains compatible with the old build system for the time being).
355 # GHC.Prim module in the ghc-prim package with a flag:
357 libraries/ghc-prim_CONFIGURE_OPTS += --flag=include-ghc-prim
359 # And then we strip it out again before building the package:
360 define libraries/ghc-prim_PACKAGE_MAGIC
361 libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
364 PRIMOPS_TXT = $(GHC_COMPILER_DIR)/prelude/primops.txt
366 libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
367 $(MKDIRHIER) $(dir $@)
368 $(GENPRIMOP_INPLACE) --make-haskell-wrappers <$(PRIMOPS_TXT) >$@
370 libraries/ghc-prim/GHC/Prim.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT)
371 $(GENPRIMOP_INPLACE) --make-haskell-source <$(PRIMOPS_TXT) >$@
374 # -----------------------------------------------------------------------------
375 # Include build instructions from all subdirs
377 # See commentary in the top-level Makefile for why we divide the build
380 # Setting foo_dist_DISABLE=YES means "in directory foo, for build
381 # "dist", just read the package-data.mk file, do not build anything".
383 # We carefully engineer things so that we can build the
384 # package-data.mk files early on: they depend only on a few tools also
385 # built early. Having got the package-data.mk files built, we can
386 # restart make with up-to-date information about all the packages
387 # (this is phase 0). The remaining problem is the .depend files:
389 # - .depend files in libraries need the stage 1 compiler to build
390 # - ghc/stage1/.depend needs compiler/stage1 built
391 # - compiler/stage1/.depend needs the bootstrap libs built
393 # GHC 6.11+ can build a .depend file without having built the
394 # dependencies of the package, but we can't rely on the bootstrapping
395 # compiler being able to do this, which is why we have to separate the
396 # three phases above.
398 # So this is the final ordering:
400 # Phase 0 : all package-data.mk files
401 # (requires ghc-cabal, ghc-pkg, mkdirhier, dummy-ghc etc.)
402 # Phase 1 : .depend files for bootstrap libs
404 # Phase 2 : compiler/stage1/.depend
405 # (requires bootstrap libs and genprimopcode)
406 # Phase 3 : ghc/stage1/.depend
407 # (requires compiler/stage1)
409 # The rest : libraries/*/dist-install, compiler/stage2, ghc/stage2
413 ifneq "$(BINDIST)" "YES"
415 $(GHC_MKDEPENDC_DIR) \
422 libraries/Cabal/doc \
428 ifneq "$(BINDIST)" "YES"
441 ifneq "$(BINDIST)" "YES"
449 $(patsubst %, libraries/%, $(PACKAGES)) \
457 ifeq "$(Windows)" "YES"
462 # XXX libraries/% must come before any programs built with stage1, see
463 # Note [lib-depends].
466 $(foreach lib,$(BOOT_PKGS),$(eval \
467 libraries/$(lib)_dist-boot_DISABLE = YES))
470 ifneq "$(findstring $(phase),0 1)" ""
471 # We can build deps for compiler/stage1 in phase 2
472 compiler_stage1_DISABLE = YES
475 ifneq "$(findstring $(phase),0 1 2)" ""
476 ghc_stage1_DISABLE = YES
479 ifneq "$(findstring $(phase),0 1 2 3)" ""
480 # In phases 0-3, we disable stage2-3, the full libraries and haddock
481 utils/haddock_dist_DISABLE = YES
482 utils/runghc_dist_DISABLE = YES
483 utils/hpc_dist_DISABLE = YES
484 utils/hasktags_dist_DISABLE = YES
485 utils/hsc2hs_dist-install_DISABLE = YES
486 utils/ghc-pkg_dist-install_DISABLE = YES
487 compiler_stage2_DISABLE = YES
488 compiler_stage3_DISABLE = YES
489 ghc_stage2_DISABLE = YES
490 ghc_stage3_DISABLE = YES
491 $(foreach lib,$(PACKAGES),$(eval \
492 libraries/$(lib)_dist-install_DISABLE = YES))
495 include $(patsubst %, %/ghc.mk, $(BUILD_DIRS))
497 # We need -fno-warn-deprecated-flags to avoid failure with -Werror
498 GhcLibHcOpts += -fno-warn-deprecated-flags
499 ifeq "$(ghc_ge_609)" "YES"
500 GhcBootLibHcOpts += -fno-warn-deprecated-flags
503 # Add $(GhcLibHcOpts) to all library builds
504 $(foreach pkg,$(PACKAGES),$(eval libraries/$(pkg)_dist-install_HC_OPTS += $$(GhcLibHcOpts)))
506 # XXX we configure packages with the bootsrapping compiler (for
507 # dependency reasons, see the phase ordering), which doesn't
508 # necessarily support all the extensions we need, and Cabal filters
509 # out the ones it thinks aren't supported.
510 libraries/base3-compat_dist-install_HC_OPTS += -XPackageImports
512 # -----------------------------------------------------------------------------
513 # Bootstrapping libraries
515 # We need to build a few libraries with the installed GHC, since GHC itself
516 # and some of the tools depend on them:
518 ifneq "$(BINDIST)" "YES"
520 ifeq "$(wildcard $(BOOTSTRAPPING_CONF))" ""
521 $(shell echo "[]" >$(BOOTSTRAPPING_CONF))
524 $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
526 # These three libraries do not depend on each other, so we can build
529 $(eval $(call build-package,libraries/hpc,dist-boot,0))
530 $(eval $(call build-package,libraries/extensible-exceptions,dist-boot,0))
531 $(eval $(call build-package,libraries/Cabal,dist-boot,0))
533 # register the boot packages in strict sequence, because running
534 # multiple ghc-pkgs in parallel doesn't work (registrations may get
537 $(foreach pkg,$(BOOT_PKGS),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
539 compiler/stage1/package-data.mk : \
540 libraries/Cabal/dist-boot/package-data.mk \
541 libraries/hpc/dist-boot/package-data.mk \
542 libraries/extensible-exceptions/dist-boot/package-data.mk
544 # These are necessary because the bootstrapping compiler may not know
545 # about cross-package dependencies:
546 $(compiler_stage1_depfile) : $(BOOT_LIBS)
547 $(ghc_stage1_depfile) : $(compiler_stage1_v_LIB)
549 $(foreach pkg,$(BOOT_PKGS),$(eval libraries/$(pkg)_dist-boot_HC_OPTS += $$(GhcBootLibHcOpts)))
553 # -----------------------------------------------------------------------------
554 # Creating a local mingw copy on Windows
556 ifeq "$(Windows)" "YES"
558 # directories don't work well as dependencies, hence a stamp file
559 $(INPLACE)/stamp-mingw : $(MKDIRHIER)
560 $(MKDIRHIER) $(INPLACE_MINGW)/bin
561 GCC=`type -p $(WhatGccIsCalled)`; \
562 GccDir=`dirname $$GCC`; \
563 $(CP) -p $$GccDir/{gcc.exe,ar.exe,as.exe,dlltool.exe,dllwrap.exe,windres.exe} $(INPLACE_MINGW)/bin; \
564 $(CP) -Rp $$GccDir/../include $(INPLACE_MINGW); \
565 $(CP) -Rp $$GccDir/../lib $(INPLACE_MINGW); \
566 $(CP) -Rp $$GccDir/../libexec $(INPLACE_MINGW); \
567 $(CP) -Rp $$GccDir/../mingw32 $(INPLACE_MINGW)
568 touch $(INPLACE)/stamp-mingw
570 install : install_mingw
571 .PHONY: install_mingw
572 install_mingw : $(INPLACE_MINGW)
573 $(CP) -Rp $(INPLACE_MINGW) $(prefix)
575 $(INPLACE_LIB)/perl.exe $(INPLACE_LIB)/perl56.dll :
576 $(CP) $(GhcDir)../{perl.exe,perl56.dll} $(INPLACE_LIB)
580 libraries/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock: \
581 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs \
582 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs
584 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
585 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
586 $(MKDIRHIER) $(dir $@)
587 $(GENPRIMOP_INPLACE) --make-haskell-source < $< > $@
589 libraries/ghc-prim/dist-install/build/autogen/GHC/PrimopWrappers.hs: \
590 $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) $(MKDIRHIER)
591 $(MKDIRHIER) $(dir $@)
592 $(GENPRIMOP_INPLACE) --make-haskell-wrappers < $< > $@
594 # -----------------------------------------------------------------------------
597 install: install_packages install_libs install_libexecs install_headers \
598 install_libexec_scripts install_bins
600 install_bins: $(INSTALL_BINS)
601 $(INSTALL_DIR) $(DESTDIR)$(bindir)
602 for i in $(INSTALL_BINS); do \
603 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ; \
604 if test "$(darwin_TARGET_OS)" = "1"; then \
605 sh mk/fix_install_names.sh $(libdir) $(DESTDIR)$(bindir)/$$i ; \
609 install_libs: $(INSTALL_LIBS)
610 $(INSTALL_DIR) $(DESTDIR)$(libdir)
611 for i in $(INSTALL_LIBS); do \
614 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
615 $(RANLIB) $(DESTDIR)$(libdir)/`basename $$i` ;; \
617 $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
619 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
621 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
622 install_name_tool -id $(DESTDIR)$(libdir)/`basename $$i` $(DESTDIR)$(libdir)/`basename $$i` ;; \
624 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
628 install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
629 $(MKDIRHIER) $(DESTDIR)$(libexecdir)
630 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
631 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libexecdir); \
634 install_libexecs: $(INSTALL_LIBEXECS)
635 $(MKDIRHIER) $(DESTDIR)$(libexecdir)
636 for i in $(INSTALL_LIBEXECS); do \
637 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(libexecdir); \
640 install_headers: $(INSTALL_HEADERS)
641 $(INSTALL_DIR) $(DESTDIR)$(headerdir)
642 for i in $(INSTALL_HEADERS); do \
643 $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
646 INSTALLED_PACKAGE_CONF=$(DESTDIR)$(libdir)/package.conf
648 # Install packages in the right order, so that ghc-pkg doesn't complain.
649 # Also, install ghc-pkg first.
650 ifeq "$(Windows)" "NO"
651 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(libexecdir)/ghc-pkg
653 INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
656 install_packages: install_libexecs
657 install_packages: libffi/package.conf.install rts/package.conf.install
658 $(MKDIRHIER) $(DESTDIR)$(libdir)
659 echo "[]" > $(INSTALLED_PACKAGE_CONF)
660 $(INSTALLED_GHC_PKG_REAL) --force --global-conf $(INSTALLED_PACKAGE_CONF) update libffi/package.conf.install
661 $(INSTALLED_GHC_PKG_REAL) --force --global-conf $(INSTALLED_PACKAGE_CONF) update rts/package.conf.install
662 $(foreach p, $(PACKAGES),\
663 $(GHC_CABAL_INPLACE) install \
664 $(INSTALLED_GHC_PKG_REAL) \
665 $(INSTALLED_PACKAGE_CONF) \
666 libraries/$p dist-install \
667 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries' &&) true
668 $(GHC_CABAL_INPLACE) install \
669 $(INSTALLED_GHC_PKG_REAL) \
670 $(INSTALLED_PACKAGE_CONF) \
672 '$(DESTDIR)' '$(prefix)' '$(libdir)' '$(docdir)/libraries'
674 # -----------------------------------------------------------------------------
675 # Binary distributions
677 $(eval $(call bindist,.,\
679 configure config.sub config.guess \
683 $(INPLACE_BIN)/mkdirhier \
684 $(INPLACE_BIN)/ghc-cabal \
686 $(BINDIST_WRAPPERS) \
691 $(INSTALL_LIBEXECS) \
692 $(INSTALL_LIBEXEC_SCRIPTS) \
694 $(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
695 $(filter-out %/project.mk,$(filter-out mk/config.mk,$(MAKEFILE_LIST))) \
696 mk/fix_install_names.sh \
699 # mk/project.mk gets an absolute path, so we manually include it in
700 # the bindist with a relative path
703 $(RM) -rf $(BIN_DIST_NAME)
704 mkdir $(BIN_DIST_NAME)
705 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
706 ln -s ../distrib/configure-bin.ac $(BIN_DIST_NAME)/configure.ac
707 cd $(BIN_DIST_NAME) && autoreconf
708 $(RM) -f $(BIN_DIST_TAR)
709 # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
710 # tree then we want to include the real file, not a symlink to it
711 $(TAR) hcf $(BIN_DIST_TAR) -T $(BIN_DIST_LIST)
712 bzip2 < $(BIN_DIST_TAR) > $(BIN_DIST_TAR_BZ2)
714 # -----------------------------------------------------------------------------
715 # Source distributions
723 # A source dist is built from a complete build tree, because we
724 # require some extra files not contained in a darcs checkout: the
725 # output from Happy and Alex, for example.
727 # The steps performed by 'make dist' are as follows:
728 # - create a complete link-tree of the current build tree in /tmp
729 # - run 'make distclean' on that tree
730 # - remove a bunch of other files that we know shouldn't be in the dist
731 # - tar up first the extralibs package, then the main source package
734 # Directory in which we're going to build the src dist
736 SRC_DIST_NAME=ghc-$(ProjectVersion)
737 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
740 # Files to include in source distributions
742 SRC_DIST_DIRS = mk rules docs distrib bindisttest gmp libffi includes utils docs rts compiler ghc driver libraries
744 configure.ac config.guess config.sub configure \
745 aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
746 ghc.spec.in ghc.spec extra-gcc-opts.in VERSION boot ghc.mk
748 EXTRA_LIBS=$(patsubst %, $(SRC_DIST_NAME)/%, $(shell grep -E "extralibs|dph" packages | grep -v "^\#" | sed "s/ .*//"))
750 SRC_DIST_TARBALL = ghc-$(ProjectVersion)-src.tar.bz2
751 SRC_DIST_EXTRALIBS_TARBALL = ghc-$(ProjectVersion)-src-extralibs.tar.bz2
754 echo $(ProjectVersion) >VERSION
759 # $(call sdist_file,compiler,stage2,cmm,CmmLex,x)
760 # to copy the generated file that replaces compiler/cmm/CmmLex.x, where
761 # "stage2" is the dist dir.
763 if test -f $(TOP)/$1/$2/build/$4.hs; then \
764 $(CP) $(TOP)/$1/$2/build/$4.hs $1/$3/ ; \
765 mv $1/$3/$4.$5 $1/$3/$4.$5.source ;\
767 echo "does not exist: $1/$2//build/$4.hs"; \
773 $(RM) -rf $(SRC_DIST_DIR)
774 $(RM) $(SRC_DIST_NAME).tar.gz
775 mkdir $(SRC_DIST_DIR)
776 ( cd $(SRC_DIST_DIR) \
777 && for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i && lndir $(TOP)/$$i ); done \
778 && for i in $(SRC_DIST_FILES); do $(LN_S) $(TOP)/$$i .; done \
779 && $(MAKE) distclean \
780 && 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 \
781 && $(call sdist_file,compiler,stage2,cmm,CmmLex,x) \
782 && $(call sdist_file,compiler,stage2,cmm,CmmParse,y) \
783 && $(call sdist_file,compiler,stage2,main,ParsePkgConf,y) \
784 && $(call sdist_file,compiler,stage2,parser,HaddockLex,x) \
785 && $(call sdist_file,compiler,stage2,parser,HaddockParse,y) \
786 && $(call sdist_file,compiler,stage2,parser,Lexer,x) \
787 && $(call sdist_file,compiler,stage2,parser,Parser,y.pp) \
788 && $(call sdist_file,compiler,stage2,parser,ParserCore,y) \
789 && $(call sdist_file,utils/hpc,dist,,HpcParser,y) \
790 && $(call sdist_file,utils/genprimopcode,dist,,Lexer,x) \
791 && $(call sdist_file,utils/genprimopcode,dist,,Parser,y) \
792 && $(RM) -rf compiler/stage[123] mk/build.mk \
793 && $(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 \
798 $(TAR) chf - $(EXTRA_LIBS) | bzip2 >$(TOP)/$(SRC_DIST_EXTRALIBS_TARBALL)
799 $(RM) -rf $(EXTRA_LIBS)
800 $(TAR) chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(TOP)/$(SRC_DIST_TARBALL)
802 sdist-manifest : $(SRC_DIST_TARBALL)
803 tar tjf $(SRC_DIST_TARBALL) | sed "s|^ghc-$(ProjectVersion)/||" | sort >sdist-manifest
805 # Upload the distribution(s)
806 # Retrying is to work around buggy firewalls that corrupt large file transfers
808 ifneq "$(PublishLocation)" ""
810 @for i in 0 1 2 3 4 5 6 7 8 9; do \
811 echo "Try $$i: $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist"; \
812 if $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist; then break; fi; \
814 @for i in 0 1 2 3 4 5 6 7 8 9; do \
815 echo "Try $$i: $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist"; \
816 if $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist; then break; fi; \
820 # -----------------------------------------------------------------------------
831 $(RM) config.cache config.status config.log mk/config.h mk/stamp-h
832 $(RM) mk/config.mk mk/are-validating.mk
833 $(RM) extra-gcc-opts docs/users_guide/ug-book.xml
834 $(RM) compiler/ghc.cabal ghc/ghc-bin.cabal
835 $(RM) libraries/base/include/HsBaseConfig.h
836 $(RM) libraries/directory/include/HsDirectoryConfig.h
838 maintainer-clean : distclean
840 $(RM) libraries/*/GNUmakefile