Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GHC new build system megapatch

  • Loading branch information...
commit 34cc75e1a62638f2833815746ebce0a9114dc26b 1 parent 74e1368
@igfoo igfoo authored
Showing with 6,150 additions and 6,372 deletions.
  1. +113 −633 Makefile
  2. +2 −2 bindisttest/Makefile
  3. +18 −2 boot
  4. +31 −0 compiler/LICENSE
  5. +10 −497 compiler/Makefile
  6. +18 −1 compiler/ghc.cabal.in
  7. +432 −0 compiler/ghc.mk
  8. +18 −10 compiler/main/DriverMkDepend.hs
  9. +58 −142 compiler/main/SysTools.lhs
  10. +8 −2 compiler/rename/RnNames.lhs
  11. +109 −17 configure.ac
  12. +2 −2 distrib/configure-bin.ac
  13. +0 −3  docs/ext-core/Makefile
  14. +0 −1  docs/man/Makefile
  15. +7 −0 docs/users_guide/ghc.mk
  16. +0 −18 driver/ghc-pkg/Makefile
  17. +11 −0 driver/ghc.mk
  18. +10 −0 driver/ghc/ghc.mk
  19. +3 −63 driver/ghci/Makefile
  20. +50 −0 driver/ghci/ghc.mk
  21. +3 −26 driver/mangler/Makefile
  22. +7 −0 driver/mangler/ghc.mk
  23. +0 −14 driver/runhaskell/Makefile
  24. +3 −21 driver/split/Makefile
  25. +7 −0 driver/split/ghc.mk
  26. +841 −0 ghc.mk
  27. +3 −0  ghc.spec.in
  28. +0 −2  ghc/Main.hs
  29. +11 −150 ghc/Makefile
  30. +3 −0  ghc/ghc-bin.cabal.in
  31. +127 −0 ghc/ghc.mk
  32. +0 −2  ghc/ghc.wrapper
  33. +0 −127 gmp/Makefile
  34. +124 −0 gmp/ghc.mk
  35. BIN  gmp/gmp-4.2.1-nodoc.tar.gz
  36. BIN  gmp/tarball/gmp-4.2.4-nodoc.tar.bz2
  37. +3 −202 includes/Makefile
  38. +1 −1  includes/Regs.h
  39. +1 −1  includes/Stg.h
  40. +179 −0 includes/ghc.mk
  41. +3 −199 libffi/Makefile
  42. +193 −0 libffi/ghc.mk
  43. 0  libffi/{libffi-autotools-update.patch → libffi.autotools-update.patch}
  44. 0  libffi/{libffi-dllize-3.0.6.patch → libffi.dllize-3.0.6.patch}
  45. +3 −3 libffi/package.conf.in
  46. 0  libffi/{ → tarball}/libffi-3.0.6.tar.gz
  47. +0 −441 libraries/Makefile
  48. +0 −45 mk/bindist.mk
  49. +0 −82 mk/boilerplate.mk
  50. +3 −5 mk/build.mk.sample
  51. +0 −129 mk/cabal-flags.mk
  52. +0 −68 mk/cabal.mk
  53. +120 −339 mk/config.mk.in
  54. +4 −4 mk/custom-settings.mk
  55. +0 −307 mk/install.mk
  56. +1,416 −0 mk/old-config.mk.in
  57. +0 −109 mk/opts.mk
  58. +0 −315 mk/package.mk
  59. +0 −277 mk/paths.mk
  60. +143 −0 mk/project.mk.in
  61. +0 −101 mk/recurse.mk
  62. +34 −0 mk/sub-makefile.mk
  63. +0 −392 mk/suffix.mk
  64. +0 −701 mk/target.mk
  65. +2 −2 mk/validate-settings.mk
  66. +1 −1  rts/Capability.h
  67. +1 −1  rts/Interpreter.c
  68. +3 −496 rts/Makefile
  69. +393 −0 rts/ghc.mk
  70. +5 −5 rts/package.conf.in
  71. +7 −0 rules/all-target.mk
  72. +16 −0 rules/bindist.mk
  73. +48 −0 rules/build-dependencies.mk
  74. +16 −0 rules/build-package-data.mk
  75. +52 −0 rules/build-package-way.mk
  76. +135 −0 rules/build-package.mk
  77. +45 −0 rules/build-perl.mk
  78. +139 −0 rules/build-prog.mk
  79. +5 −0 rules/c-objs.mk
  80. +4 −0 rules/c-sources.mk
  81. +60 −0 rules/c-suffix-rules.mk
  82. +9 −0 rules/clean-target.mk
  83. +60 −0 rules/distdir-opts.mk
  84. +78 −0 rules/distdir-way-opts.mk
  85. +24 −0 rules/docbook.mk
  86. +27 −0 rules/haddock.mk
  87. +25 −0 rules/hi-rule.mk
  88. +5 −0 rules/hs-objs.mk
  89. +46 −0 rules/hs-sources.mk
  90. +70 −0 rules/hs-suffix-rules-srcdir.mk
  91. +17 −0 rules/hs-suffix-rules.mk
  92. +14 −0 rules/includes-sources.mk
  93. +33 −0 rules/manual-package-config.mk
  94. +41 −0 rules/package-config.mk
  95. +63 −0 rules/shell-wrapper.mk
  96. +13 −0 rules/way-prelims.mk
  97. +3 −29 utils/genapply/Makefile
  98. +16 −0 utils/genapply/ghc.mk
  99. +3 −10 utils/genprimopcode/Makefile
  100. +4 −0 utils/genprimopcode/ghc.mk
  101. +246 −0 utils/ghc-cabal/ghc-cabal.hs
  102. +54 −0 utils/ghc-cabal/ghc.mk
  103. +29 −26 utils/ghc-pkg/Main.hs
  104. +3 −21 utils/ghc-pkg/Makefile
  105. +69 −0 utils/ghc-pkg/ghc.mk
  106. +3 −5 utils/hasktags/Makefile
  107. +10 −0 utils/hasktags/ghc.mk
  108. +1 −1  utils/hp2ps/Main.h
  109. +3 −20 utils/hp2ps/Makefile
  110. +10 −0 utils/hp2ps/ghc.mk
  111. 0  utils/hpc/{Hpc.hs → Main.hs}
  112. +3 −5 utils/hpc/Makefile
  113. +7 −0 utils/hpc/ghc.mk
  114. +0 −13 utils/installPackage/Makefile
  115. +0 −28 utils/installPackage/installPackage.cabal
  116. +0 −154 utils/installPackage/installPackage.hs
  117. +3 −24 utils/mkdependC/Makefile
  118. +12 −0 utils/mkdependC/ghc.mk
  119. +2 −0  utils/mkdependC/mkdependC.prl
  120. +3 −17 utils/mkdirhier/Makefile
  121. +11 −0 utils/mkdirhier/ghc.mk
  122. +0 −2  utils/parallel/Makefile
  123. +3 −12 utils/runghc/Makefile
  124. +29 −0 utils/runghc/ghc.mk
  125. +1 −3 utils/runghc/runghc.hs
  126. +5 −0 utils/touchy/ghc.mk
  127. +1 −0  utils/touchy/touchy.c
  128. +3 −25 utils/unlit/Makefile
  129. +9 −0 utils/unlit/ghc.mk
  130. +9 −15 utils/unlit/unlit.c
  131. +6 −1 validate
View
746 Makefile
@@ -1,663 +1,143 @@
-############################################################################
-#
-# This is the top-level Makefile for GHC
-#
-# Targets:
-#
-# bootstrap (DEFAULT)
-# Builds GHC, then builds the libraries,
-# then uses this GHC ("stage 1") to build itself
-# ("stage 2").
-#
-# bootstrap2
-# Same as bootstrap
-#
-# bootstrap3
-# bootstrap2 + we build GHC one more time ("stage 3")
-#
-# stage1
-# Just build up to stage 1
-#
-# stage2
-# Just build stage 2 (stage 1 must be built)
-#
-# stage3
-# Just build stage 3 (stage 2 must be built)
-#
-# all
-# Same as bootstrap
-#
-# install
-# Install everything, including stage 2 compiler by default
-# (override with stage=3, for example).
-#
-# dist
-# Make a source dist (WARNING: runs 'make distclean' first)
-#
-# binary-dist
-# Builds a binary distribution
-#
-# framework-pkg [MacOS only]
-# Builds /Library/Frameworks/GHC.framework wrapped into a Mac
-# installer package
-#
-# framework-binary-dist [MacOS only]
-# Builds GHC.framework encapsulating a binary distribution
-# (to give a relocatable framework)
-#
-# hc-file-bundle
-# Builds an HC-file bundle, for bootstrapping
-#
-# clean, distclean, maintainer-clean
-# Increasing levels of cleanliness
-#
-############################################################################
-TOP=.
-include $(TOP)/mk/boilerplate.mk
+ifeq "$(wildcard distrib/)" ""
-#
-# Order is important! It's e.g. necessary to descend into include/
-# before the rest to have a config.h, etc.
-#
-# If we're booting from .hc files, swap the order
-# we descend into subdirs - to boot utils must be before driver.
-#
-.PHONY: stage1 stage2 stage3 bootstrap bootstrap2 bootstrap3
+# We're in a bindist
-# We can't 'make boot' in libraries until stage1 is built
-ifeq "$(BootingFromHc)" "YES"
-SUBDIRS_BUILD = includes compiler docs utils driver
-else
-SUBDIRS_BUILD = includes utils driver docs compiler libraries/Cabal/doc
-endif
+.PHONY: default
+default:
+ @echo 'Run "make install" to install'
+ @false
-SUBDIRS = gmp libffi includes utils docs rts compiler ghc driver libraries libraries/Cabal/doc
+.PHONY: install
+install:
+ $(MAKE) -r --no-print-directory -f ghc.mk install BINDIST=YES NO_INCLUDE_DEPS=YES
-check-all: check-packages check-tools
-
-# Sanity check that all the boot libraries are in the tree, to catch
-# failure to run darcs-all.
-check-packages :
- @ds=`grep "^[^# ][^ ]* *[^ ][^ ]* *[^ ][^ ]*$$" packages | sed "s/ .*//"`;\
- for d in $$ds; do \
- if test ! -d $$d; then \
- echo "Looks like you're missing $$d,"; \
- echo "maybe you haven't done './darcs-all get'?"; \
- exit 1; \
- fi \
- done
- @if test ! -f libraries/base/configure; then \
- echo "Looks like you're missing base's configure script."; \
- echo "Did you run 'sh boot' at the top level?"; \
- exit 1; \
- fi
-
-HAVE_EVAL := NO
-$(eval HAVE_EVAL := YES)
-
-check-tools:
-ifeq "$(HSCOLOUR_SRCS) $(HSCOLOUR)" "YES "
- @echo "HsColour needed but wasn't found."
- @echo "Set HSCOLOUR_SRCS=NO if you don't want to use it"
- exit 1
-endif
-ifeq "$(HAVE_EVAL)" "NO"
- @echo "Your make doesn't support eval. You need GNU make >= 3.80"
- exit 1
-endif
- @:
-
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-ifneq "$(WhatGccIsCalled)" ""
-GCC_LIB_DEP = stamp.inplace-gcc-lib
-endif
-endif
-
-stage1 : $(GCC_LIB_DEP) check-all
- $(MAKE) -C libraries boot
- $(MAKE) -C gmp all
- $(MAKE) -C utils/mkdependC boot
- $(MAKE) -C utils with-bootstrapping-compiler
- @case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
- for i in $(SUBDIRS_BUILD); do \
- echo "------------------------------------------------------------------------"; \
- echo "== $(MAKE) boot $(MFLAGS);"; \
- echo " in $(shell pwd)/$$i"; \
- echo "------------------------------------------------------------------------"; \
- $(MAKE) --no-print-directory -C $$i $(MFLAGS) boot; \
- if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
- done; \
- for i in $(SUBDIRS_BUILD); do \
- echo "------------------------------------------------------------------------"; \
- echo "== $(MAKE) all $(MFLAGS);"; \
- echo " in $(shell pwd)/$$i"; \
- echo "------------------------------------------------------------------------"; \
- $(MAKE) --no-print-directory -C $$i $(MFLAGS) all; \
- if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
- done
- $(MAKE) -C libffi all
- $(MAKE) -C rts boot
- $(MAKE) -C rts
- $(MAKE) -C libraries all
-
-# When making distributions (i.e., whether with binary-dist or using the
-# vanilla install target to create an installer package), we can have problems
-# if some things (e.g. ghc-pkg) are compiled with the bootstrapping compiler
-# and some (e.g. the stage 2 compiler) with the stage1 compiler. See #1860 for
-# an example. Thus, we explicitly build a second version with the stage 1
-# compiler of all utils that get installed and of all extra support binaries
-# includes in binary dists.
-stage2 : check-all
- $(MAKE) -C compiler stage=2 boot
- $(MAKE) -C compiler stage=2
- $(MAKE) -C utils with-stage-2
- $(MAKE) -C libraries stage=2 all
-ifeq "$(HADDOCK_DOCS)" "YES"
- $(MAKE) -C libraries doc
- $(MAKE) -C compiler doc stage=2
-endif
+.PHONY: show
+show:
+ $(MAKE) -r --no-print-directory -f ghc.mk $@
-stage3 : check-all
- $(MAKE) -C compiler stage=3 boot
- $(MAKE) -C compiler stage=3
-
-bootstrap : bootstrap2
-
-bootstrap2 : stage1
- $(MAKE) stage2
-
-bootstrap3 : bootstrap2
- $(MAKE) stage3
-
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-ifneq "$(WhatGccIsCalled)" ""
-all :: stamp.inplace-gcc-lib
-
-.PHONY: stamp.inplace-gcc-lib
-
-# This is a hack to make Cabal able to find ld when we run tests with
-# the inplace ghc. We should probably install all the gcc stuff in our
-# tree somewhere, and then have install copy it from there rather than
-# from the filesystem.
-stamp.inplace-gcc-lib:
- $(RM) -r ghc/gcc-lib
- mkdir ghc/gcc-lib
- cp $(LD) ghc/gcc-lib
- touch $@
-
-clean ::
- $(RM) -r ghc/gcc-lib
- $(RM) -f inplace-gcc-lib
-endif
-endif
-
-all :: bootstrap
-
-# -----------------------------------------------------------------------------
-# Installing
-
-# We want to install the stage 2 bootstrapped compiler by default, but we let
-# the user override this by saying 'make install stage=1', for example.
-ifeq "$(stage)" ""
-INSTALL_STAGE = stage=2
else
-INSTALL_STAGE =
-endif
-
-install-strip:
- $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
-
-# Same as default rule, but we pass $(INSTALL_STAGE) to $(MAKE) too
-install :: check-packages
- $(MKDIRHIER) $(DESTDIR)$(datadir)
- echo "[]" > $(DESTDIR)$(datadir)/package.conf
- @case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
- for i in $(SUBDIRS); do \
- echo "------------------------------------------------------------------------"; \
- echo "== $(MAKE) $@ $(MFLAGS);"; \
- echo " in $(shell pwd)/$$i"; \
- echo "------------------------------------------------------------------------"; \
- $(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
- if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
- done
-
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-# These files need to be in the InstallShield
-# INSTALL_DATAS rather than INSTALL_DOCS is used so these files go
-# in the top-level directory of the distribution
-INSTALL_DATAS += ANNOUNCE LICENSE README
-endif
-# If installing on Windows with MinGW32, copy the gcc compiler, headers and libs
-# and the perl interpreter and dll into the GHC prefix directory.
-# Gcc and Perl source locations derived from configuration data.
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-ifneq "$(WhatGccIsCalled)" ""
-install ::
- -mkdir $(prefix)/gcc-lib
- -mkdir $(prefix)/include
- -mkdir $(prefix)/include/mingw
- -cp -rp $(GccDir)../include/* $(prefix)/include/mingw
- -cp -rp $(GccDir)../lib/gcc-lib/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
- -cp -rp $(GccDir)../lib/gcc/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
- -cp -rp $(GccDir)../libexec/gcc/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
- -cp $(GccDir)../lib/*.* $(prefix)/gcc-lib
- -cp $(GccDir)gcc.exe $(prefix)
- -cp $(GccDir)as.exe $(prefix)/gcc-lib
- -cp $(GccDir)ld.exe $(prefix)/gcc-lib
- -cp $(GccDir)dllwrap.exe $(prefix)/gcc-lib
- -cp $(GccDir)dlltool.exe $(prefix)/gcc-lib
- -cp $(GhcDir)../perl.exe $(prefix)
- -cp $(GhcDir)../perl56.dll $(prefix)
-endif
-endif
-
-# Install gcc-extra-opts
-install ::
- $(INSTALL_DIR) $(DESTDIR)$(libdir)
- $(INSTALL_DATA) $(INSTALL_OPTS) extra-gcc-opts $(DESTDIR)$(libdir)
+# The problem we need to solve is as follows.
+#
+# GNU make supports included Makefiles, and it is clever enough to try
+# to update those Makefiles when they are out-of-date or missing. It
+# first reads all the Makefiles, and then tries to build each one if
+# it is out-of-date, using the rules in the Makefiles themselves.
+# When it has brought all the Makefiles up-to-date, it restarts itself
+# to read the newly-generated Makefiles.
+#
+# This works fine, unless there are dependencies *between* the
+# Makefiles. For example in the GHC build, for each package we have a
+# package-data.mk file which is generated by the ghc-cabal program,
+# and we have a .depend file. The .depend file cannot be generated
+# until package-data.mk has been generated and make has been restarted
+# to read in its contents, because it is the package-data.mk file that
+# tells us which modules are in the package. But make always makes
+# all the Makefiles before restarting - it doesn't take into account a
+# dependency between Makefiles and restart itself earlier.
-install-docs ::
- @case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
- for i in $(SUBDIRS); do \
- echo "------------------------------------------------------------------------"; \
- echo "== $(MAKE) $@ $(MFLAGS);"; \
- echo " in $(shell pwd)/$$i"; \
- echo "------------------------------------------------------------------------"; \
- $(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
- if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
- done
+# Consider the following makefile:
-# -----------------------------------------------------------------------------
-# Making a binary distribution
-#
-# `dist' `binary-dist'
-# Create a distribution tar file for this program. The tar file
-# should be set up so that the file names in the tar file start with
-# a subdirectory name which is the name of the package it is a
-# distribution for. This name can include the version number.
+# --------------------
+# all :
#
-# For example, the distribution tar file of GCC version 1.40 unpacks
-# into a subdirectory named `gcc-1.40'.
+# include inc1.mk
#
-# The easiest way to do this is to create a subdirectory
-# appropriately named, use ln or cp to install the proper files in
-# it, and then tar that subdirectory.
+# inc1.mk : Makefile
+# echo "X = C" >$@
#
-# The dist target should explicitly depend on all non-source files
-# that are in the distribution, to make sure they are up to date in
-# the distribution. See Making Releases.
-#
-# binary-dist is a GHC addition for binary distributions
+# include inc2.mk
#
+# inc2.mk : inc1.mk
+# echo "Y = $(X)" >$@
+# --------------------
-binary-dist::
- -rm -rf $(BIN_DIST_DIR)
- -$(RM) $(BIN_DIST_TAR_BZ2)
-
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-
-binary-dist::
- $(MAKE) prefix=$(BIN_DIST_DIR) install
- $(MAKE) prefix=$(BIN_DIST_DIR) install-docs
-
-binary-dist::
- cd $(BIN_DIST_DIR) && $(SHELL) ../distrib/prep-bin-dist-mingw
-
-binary-dist::
- $(MKDIRHIER) $(BIN_DIST_DIR)/icons
- cp distrib/hsicon.ico $(BIN_DIST_DIR)/icons
-
-# Tar up the distribution and build a manifest
-binary-dist :: tar-binary-dist
-
-.PHONY: tar-binary-dist
-tar-binary-dist:
- ( cd $(BIN_DIST_TOPDIR_ABS); $(TAR) cf - $(BIN_DIST_NAME) | bzip2 > $(FPTOOLS_TOP_ABS)/$(BIN_DIST_TAR_BZ2) )
- ( cd $(BIN_DIST_TOPDIR_ABS); bunzip2 -c $(FPTOOLS_TOP_ABS)/$(BIN_DIST_TAR_BZ2) | $(TAR) tf - | sed "s/^ghc-$(ProjectVersion)/fptools/" | sort >$(FPTOOLS_TOP_ABS)/bin-manifest-$(ProjectVersion) )
-
-else
-
-.PHONY: binary-dist
-
-BIN_DIST_VARFILE=$(BIN_DIST_PREP)/Makefile-vars.in
-
-WHERE_AM_I = $(BIN_DIST_NAME)
-
-binary-dist::
-# For the most part we will be putting filenames in $(BIN_DIST_LIST),
-# and telling tar to tar all of those files up. So to start with we
-# remove $(BIN_DIST_LIST) so that we can start with an empty slate
- $(RM) -f $(BIN_DIST_LIST)
-# Now we add a few files from mk/ to $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/mk/package.mk >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/mk/install.mk >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/mk/recurse.mk >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/mk/cabal.mk >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/mk/cabal-flags.mk >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/mk/fptools.css >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/ANNOUNCE >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/LICENSE >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/install-sh >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/extra-gcc-opts.in >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/config.guess >> $(BIN_DIST_LIST)
- echo $(WHERE_AM_I)/config.sub >> $(BIN_DIST_LIST)
-# Now we recurse into various subdirectories and tell them to add and
-# files that they want into $(BIN_DIST_LIST)
-# XXX Ug, this duplication of "-C foo WHERE_AM_I=.../foo" isn't nice.
- $(MAKE) -C gmp binary-dist WHERE_AM_I=$(WHERE_AM_I)/gmp
- $(MAKE) -C includes binary-dist WHERE_AM_I=$(WHERE_AM_I)/includes
- $(MAKE) -C compiler binary-dist WHERE_AM_I=$(WHERE_AM_I)/compiler $(INSTALL_STAGE)
- $(MAKE) -C ghc binary-dist WHERE_AM_I=$(WHERE_AM_I)/ghc $(INSTALL_STAGE)
- $(MAKE) -C rts binary-dist WHERE_AM_I=$(WHERE_AM_I)/rts
- $(MAKE) -C driver binary-dist WHERE_AM_I=$(WHERE_AM_I)/driver
- $(MAKE) -C utils binary-dist WHERE_AM_I=$(WHERE_AM_I)/utils
- $(MAKE) -C docs binary-dist WHERE_AM_I=$(WHERE_AM_I)/docs
- $(MAKE) -C libffi binary-dist WHERE_AM_I=$(WHERE_AM_I)/libffi
- $(MAKE) -C libraries binary-dist WHERE_AM_I=$(WHERE_AM_I)/libraries
- $(MAKE) -C libraries/Cabal/doc binary-dist WHERE_AM_I=$(WHERE_AM_I)/libraries/Cabal/doc
-# Now thinks get messier. Some files we need to move around, rename or
-# generate. We do this under $(BIN_DIST_PREP).
- $(RM) -rf $(BIN_DIST_PREP_DIR)
- $(MKDIRHIER) $(BIN_DIST_PREP)/mk
- echo 'include $$(TOP)/Makefile-vars' > $(BIN_DIST_PREP)/mk/boilerplate.mk
- echo 'include $$(TOP)/mk/package.mk' > $(BIN_DIST_PREP)/mk/target.mk
- echo 'include $$(TOP)/mk/install.mk' >> $(BIN_DIST_PREP)/mk/target.mk
- echo 'include $$(TOP)/mk/recurse.mk' >> $(BIN_DIST_PREP)/mk/target.mk
- touch $(BIN_DIST_PREP)/mk/bindist.mk
-ifeq "$(darwin_TARGET_OS)" "1"
- cp mk/fix_install_names.sh $(BIN_DIST_PREP)/mk
-endif
-
- cp distrib/Makefile $(BIN_DIST_PREP)
- cp distrib/INSTALL $(BIN_DIST_PREP)
- cp distrib/README $(BIN_DIST_PREP)
- cp distrib/configure-bin.ac $(BIN_DIST_PREP)/configure.ac
-# We can't just list aclocal.m4 in $(BIN_DIST_LIST), as it needs to be
-# next to configure.ac when we run autoreconf
- cp aclocal.m4 $(BIN_DIST_PREP)
- cd $(BIN_DIST_PREP) && autoreconf
-# We need to copy the pwd program that was built with stage1 to where
-# the build system expects to find it, i.e. the location the pwd built
-# with the bootstrapping compiler normally occupies
- $(MKDIRHIER) $(BIN_DIST_PREP)/utils/pwd
- cp utils/pwd/dist-install/build/pwd/pwd $(BIN_DIST_PREP)/utils/pwd
-# And likewise the installPackage program
- $(MKDIRHIER) $(BIN_DIST_PREP)/utils/installPackage/install-inplace/bin
- cp utils/installPackage/dist-install/build/installPackage/installPackage \
- $(BIN_DIST_PREP)/utils/installPackage/install-inplace/bin
-
- echo "package = ghc" >> $(BIN_DIST_VARFILE)
- echo "version = $(ProjectVersion)" >> $(BIN_DIST_VARFILE)
- echo "ProjectVersion = $(ProjectVersion)" >> $(BIN_DIST_VARFILE)
- echo "HaveLibGmp = $(HaveLibGmp)" >> $(BIN_DIST_VARFILE)
- echo "GhcLibsWithUnix = $(GhcLibsWithUnix)" >> $(BIN_DIST_VARFILE)
- echo "GhcWithInterpreter = $(GhcWithInterpreter)" >> $(BIN_DIST_VARFILE)
- echo "GhcHasEditline = $(GhcHasEditline)" >> $(BIN_DIST_VARFILE)
- echo "BootingFromHc = $(BootingFromHc)" >> $(BIN_DIST_VARFILE)
- echo "XMLDocWays = $(XMLDocWays)" >> $(BIN_DIST_VARFILE)
-# We won't actually use xsltproc, but we need to know if it's "" or not
- echo "XSLTPROC = $(XSLTPROC)" >> $(BIN_DIST_VARFILE)
- echo "TARGETPLATFORM = $(TARGETPLATFORM)" >> $(BIN_DIST_VARFILE)
- echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_VARFILE)
- echo "LATEX_DOCS = $(LATEX_DOCS)" >> $(BIN_DIST_VARFILE)
- echo "INTEGER_LIBRARY = $(INTEGER_LIBRARY)" >> $(BIN_DIST_VARFILE)
- cat distrib/Makefile-bin-vars.in >> $(BIN_DIST_VARFILE)
-
-# With that done, we can now build the actual tarball
-
- $(RM) -f $(BIN_DIST_NAME)
- ln -s . $(BIN_DIST_NAME)
-# h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
-# tree then we want to include the real file, not a symlink to it
- $(TAR) hcf $(BIN_DIST_TAR) -T $(BIN_DIST_LIST)
- cd $(BIN_DIST_PREP_DIR) && $(TAR) rf ../$(BIN_DIST_TAR) $(BIN_DIST_NAME)
- bzip2 < $(BIN_DIST_TAR) > $(BIN_DIST_TAR_BZ2)
- $(TAR) tf $(BIN_DIST_TAR) | sort > bin-manifest-$(ProjectVersion)
-endif
-
-PUBLISH_FILES = $(BIN_DIST_TAR_BZ2)
-
-# Upload the distribution and documentation
-ifneq "$(ISCC)" ""
-WINDOWS_INSTALLER_BASE = ghc-$(ProjectVersion)-$(TARGETPLATFORM)
-WINDOWS_INSTALLER = $(WINDOWS_INSTALLER_BASE)$(exeext)
-
-PUBLISH_FILES += $(WINDOWS_INSTALLER)
-
-binary-dist :: generate-windows-installer
-
-.PHONY: generate-windows-installer
-generate-windows-installer ::
- $(SED) "s/@VERSION@/$(ProjectVersion)/" distrib/ghc.iss | $(ISCC) /O. /F$(WINDOWS_INSTALLER_BASE) -
-endif
-
-# Upload the distribution and documentation
-ifneq "$(PublishLocation)" ""
-publish ::
- make publish-binary-dist 'prefix=$(BIN_DIST_INST_DIR)'
-endif
-
-nTimes = set -e; for i in `seq 1 $(1)`; do echo Try "$$i: $(2)"; if $(2); then break; fi; done
-
-.PHONY: publish-binary-dist
-publish-binary-dist ::
- @for f in $(PUBLISH_FILES); \
- do $(call nTimes,10,$(PublishCp) $$f $(PublishLocation)/dist); \
- done
-
-# You need to "make binddisttest" before publishing the docs, as it
-# works by publish setting $(prefix) to inside the binddisttest
-# directory so $(docdir) points to the right place.
-
-# We assume that Windows means Cygwin, as we can't just use docdir
-# unchanged or rsync (really SSH?) thinks that c:/foo means /foo on
-# the machine c.
-
-ifeq "$(Windows)" "YES"
-PUBLISH_DOCDIR = $(shell cygpath --unix $(docdir))
-else
-PUBLISH_DOCDIR = $(docdir)
-endif
-
-publish-binary-dist ::
- $(call nTimes,10,$(PublishCp) -r "$(PUBLISH_DOCDIR)"/* $(PublishLocation)/docs)
-
-binary-dist::
- @echo "Mechanical and super-natty! Inspect the result and *if* happy; freeze, sell and get some sleep!"
-
-# -----------------------------------------------------------------------------
-# Building MacOS installer packages
-#
-# 'framework-pkg'
-# Create an installer package for /Library/Frameworks/GHC.framework
-#
-# 'framework-binary-dist'
-# Create an installer package for GHC.framework encapsulating a
-# binary-dist to make it relocatable
-# FIXME: This is only partially implemented so far
-
-ifeq "$(darwin_TARGET_OS)" "1"
-
-.PHONY: framework-pkg framework-binary-dist
-
-framework-pkg:
- $(MAKE) -C distrib/MacOS framework-pkg
-
-framework-binary-dist:
- $(MAKE) -C distrib/MacOS framework-binary-dist
-
-endif
-
-# -----------------------------------------------------------------------------
-# Building source distributions
-#
-# Do it like this:
-#
-# $ make
-# $ make dist
-#
-# WARNING: `make dist' calls `make distclean' before tarring up the tree.
-#
-
-.PHONY: dist
-
-#
-# Directory in which we're going to build the src dist
-#
-SRC_DIST_NAME=ghc-$(ProjectVersion)
-SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
+# Now try it:
+#
+# $ make -f fail.mk
+# fail.mk:3: inc1.mk: No such file or directory
+# fail.mk:8: inc2.mk: No such file or directory
+# echo "X = C" >inc1.mk
+# echo "Y = " >inc2.mk
+# make: Nothing to be done for `all'.
+# make built both inc1.mk and inc2.mk without restarting itself
+# between the two (even though we added a dependency on inc1.mk from
+# inc2.mk).
#
-# Files to include in source distributions
-#
-SRC_DIST_DIRS += mk docs distrib bindisttest $(filter-out docs distrib libraries/Cabal/doc,$(SUBDIRS))
-SRC_DIST_FILES += \
- configure.ac config.guess config.sub configure \
- aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
- ghc.spec.in ghc.spec extra-gcc-opts.in VERSION boot
+# The solution we adopt in the GHC build system is essentially this:
-# -----------------------------------------------------------------------------
-# Source distributions
-
-# A source dist is built from a complete build tree, because we
-# require some extra files not contained in a darcs checkout: the
-# output from Happy and Alex, for example.
+# --------------------
+# PHASE = 0
#
-# The steps performed by 'make dist' are as follows:
-# - create a complete link-tree of the current build tree in /tmp
-# - run 'make distclean' on that tree
-# - remove a bunch of other files that we know shouldn't be in the dist
-# - tar up first the extralibs package, then the main source package
-
-EXTRA_LIBS=$(patsubst %, $(SRC_DIST_NAME)/%, $(shell grep -E "extralibs|dph" packages | grep -v "^\#" | sed "s/ .*//"))
-
-SRC_DIST_TARBALL = ghc-$(ProjectVersion)-src.tar.bz2
-SRC_DIST_EXTRALIBS_TARBALL = ghc-$(ProjectVersion)-src-extralibs.tar.bz2
-
-VERSION :
- echo $(ProjectVersion) >VERSION
-
-dist :: VERSION
-
-# Use:
-# $(call copy_generated_compiler_file,cmm,CmmLex,x)
-# to copy the generated file that replaces compiler/cmm/CmmLex.x
-# XXX Should this be unconditional? Do we want to support making a src dist
-# from an unbuilt tree?
-copy_generated_compiler_file = \
- if test -f $(FPTOOLS_TOP_ABS)/compiler/dist-stage2/build/$2.hs; \
- then \
- $(CP) $(FPTOOLS_TOP_ABS)/compiler/dist-stage2/build/$2.hs compiler/$1/ ; \
- mv compiler/$1/$2.$3 compiler/$1/$2.$3.source ; \
- fi
-copy_generated_util_file = \
- if test -f $(FPTOOLS_TOP_ABS)/utils/$1/dist-install/build/$1/$1-tmp/$2.hs; \
- then \
- $(CP) $(FPTOOLS_TOP_ABS)/utils/$1/dist-install/build/$1/$1-tmp/$2.hs utils/$1/ ; \
- mv utils/$1/$2.$3 utils/$1/$2.$3.source ; \
- fi
-
-dist ::
- $(RM) -rf $(SRC_DIST_DIR)
- $(RM) $(SRC_DIST_NAME).tar.gz
- mkdir $(SRC_DIST_DIR)
- ( cd $(SRC_DIST_DIR) \
- && for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i && lndir $(FPTOOLS_TOP_ABS)/$$i ); done \
- && for i in $(SRC_DIST_FILES); do $(LN_S) $(FPTOOLS_TOP_ABS)/$$i .; done \
- && $(MAKE) distclean \
- && if test -f $(FPTOOLS_TOP_ABS)/libraries/haskell-src/dist/build/Language/Haskell/Parser.hs; then $(CP) $(FPTOOLS_TOP_ABS)/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 \
- && $(call copy_generated_compiler_file,cmm,CmmLex,x) \
- && $(call copy_generated_compiler_file,cmm,CmmParse,y) \
- && $(call copy_generated_compiler_file,main,ParsePkgConf,y) \
- && $(call copy_generated_compiler_file,parser,HaddockLex,x) \
- && $(call copy_generated_compiler_file,parser,HaddockParse,y) \
- && $(call copy_generated_compiler_file,parser,Lexer,x) \
- && $(call copy_generated_compiler_file,parser,Parser,y.pp) \
- && $(call copy_generated_compiler_file,parser,ParserCore,y) \
- && $(call copy_generated_util_file,hpc,HpcParser,y) \
- && $(RM) -rf compiler/stage[123] mk/build.mk \
- && $(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" \) -print | xargs $(RM) -rf \
- )
- $(TAR) chf - $(EXTRA_LIBS) | bzip2 >$(FPTOOLS_TOP_ABS)/$(SRC_DIST_EXTRALIBS_TARBALL)
- $(RM) -rf $(EXTRA_LIBS)
- $(TAR) chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(FPTOOLS_TOP_ABS)/$(SRC_DIST_TARBALL)
-
-# Upload the distribution(s)
-# Retrying is to work around buggy firewalls that corrupt large file transfers
-# over SSH.
-ifneq "$(PublishLocation)" ""
-dist ::
- @for i in 0 1 2 3 4 5 6 7 8 9; do \
- echo "Try $$i: $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist"; \
- if $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)/dist; then break; fi; \
- done
- @for i in 0 1 2 3 4 5 6 7 8 9; do \
- echo "Try $$i: $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist"; \
- if $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)/dist; then break; fi; \
- done
-endif
-
-# -----------------------------------------------------------------------------
-# HC file bundles
-
-hc-file-bundle :
- $(RM) -r ghc-$(ProjectVersion)
- $(LN_S) . ghc-$(ProjectVersion)
- $(FIND) ghc-$(ProjectVersion)/compiler \
- ghc-$(ProjectVersion)/utils \
- ghc-$(ProjectVersion)/libraries -follow \
- \( -name "*.hc" -o -name "*_hsc.[ch]" -o -name "*_stub.[ch]" \) -print > hc-files-to-go
- for f in `$(FIND) ghc-$(ProjectVersion)/compiler ghc-$(ProjectVersion)/utils ghc-$(ProjectVersion)/libraries -name "*.hsc" -follow -print` ""; do \
- if test "x$$f" != "x" && test -f `echo "$$f" | sed 's/hsc$$/hs/g'`; then \
- echo `echo "$$f" | sed 's/hsc$$/hs/g' ` >> hc-files-to-go ; \
- fi; \
- done;
- for f in `$(FIND) ghc-$(ProjectVersion)/compiler ghc-$(ProjectVersion)/rts -name "*.cmm" -follow -print` ""; do \
- if test "x$$f" != "x"; then \
- echo `echo "$$f" | sed 's/cmm$$/hc/g' ` >> hc-files-to-go ; \
- fi; \
- done;
- echo ghc-$(ProjectVersion)/libraries/base/GHC/PrimopWrappers.hs >> hc-files-to-go
- echo ghc-$(ProjectVersion)/compiler/parser/Parser.hs >> hc-files-to-go
- echo ghc-$(ProjectVersion)/compiler/parser/ParserCore.hs >> hc-files-to-go
- echo ghc-$(ProjectVersion)/compiler/main/ParsePkgConf.hs >> hc-files-to-go
- echo ghc-$(ProjectVersion)/libraries/haskell-src/Language/Haskell/Parser.hs >> hc-files-to-go
- $(TAR) czf ghc-$(ProjectVersion)-$(TARGETPLATFORM)-hc.tar.gz `cat hc-files-to-go`
-
-# -----------------------------------------------------------------------------
-# Cleaning
-
-CLEAN_FILES += hc-files-to-go *-hc.tar.gz
+# ifeq "$(PHASE)" "0"
+# all :
+# $(MAKE) PHASE=1
+# else
+# all :
+# endif
+#
+# -include inc1.mk
+#
+# inc1.mk : Makefile
+# echo "X = C" >$@
+#
+# ifneq "$(PHASE)" "0"
+# include inc2.mk
+#
+# inc2.mk : inc1.mk
+# echo "Y = $(X)" >$@
+# endif
+#
+# clean :
+# rm -f inc1.mk inc2.mk
+# --------------------
-DIST_CLEAN_FILES += config.cache config.status mk/config.h mk/stamp-h \
- docs/users_guide/ug-book.xml extra-gcc-opts
+# That is, every time make is invoked, we force it to update inc1.mk
+# and then restart. In the GHC build system we need to divide the
+# build into 4 phases in fact, with a restart between each phase. See
+# ghc.mk for the details on what happens in each phase and why.
-# don't clean config.mk: it's needed when cleaning stuff later on
-LATE_DIST_CLEAN_FILES += mk/config.mk mk/are-validating.mk
+default : all
+ @:
-# VERSION is shipped in a source dist
-MAINTAINER_CLEAN_FILES += VERSION
+# No need to update makefiles for these targets:
+REALGOALS=$(filter-out clean clean_% distclean maintainer-clean show,$(MAKECMDGOALS))
-extraclean::
- $(RM) -rf autom4te.cache
+# NB. not the same as saying '%: ...', which doesn't do the right thing:
+# it does nothing if we specify a target that already exists.
+.PHONY: $(REALGOALS)
+$(REALGOALS) all:
+ @echo "===--- updating makefiles phase 0"
+ $(MAKE) -r --no-print-directory -f ghc.mk phase=0 just-makefiles
+ @echo "===--- updating makefiles phase 1"
+ $(MAKE) -r --no-print-directory -f ghc.mk phase=1 just-makefiles
+ @echo "===--- updating makefiles phase 2"
+ $(MAKE) -r --no-print-directory -f ghc.mk phase=2 just-makefiles
+ @echo "===--- updating makefiles phase 3"
+ $(MAKE) -r --no-print-directory -f ghc.mk phase=3 just-makefiles
+ @echo "===--- finished updating makefiles"
+ $(MAKE) -r --no-print-directory -f ghc.mk $@
-clean distclean ::
- $(RM) -rf inplace-datadir
+binary-dist:
+ rm -f bindist-list
+ $(MAKE) -r --no-print-directory -f ghc.mk bindist BINDIST=YES
+ $(MAKE) -r --no-print-directory -f ghc.mk binary-dist
-clean distclean ::
- $(MAKE) -C bindisttest $@
- if test -d testsuite; then $(MAKE) -C testsuite $@; fi
+clean distclean maintainer-clean:
+ $(MAKE) -r --no-print-directory -f ghc.mk $@
+ test ! -d testsuite || $(MAKE) -C testsuite $@
-# -----------------------------------------------------------------------------
+$(filter clean_%, $(MAKECMDGOALS)) : clean_% :
+ $(MAKE) -r --no-print-directory -f ghc.mk $@
-# Turn off target.mk's rules for 'all', 'boot' and 'install'.
-NO_BOOT_TARGET=YES
-NO_ALL_TARGET=YES
-NO_INSTALL_TARGET=YES
+show:
+ $(MAKE) -r --no-print-directory -f ghc.mk $@
-include $(TOP)/mk/target.mk
+# If the user says 'make A B', then we don't want to invoke two
+# instances of the rule above in parallel:
+.NOTPARALLEL:
-# -----------------------------------------------------------------------------
+endif
View
4 bindisttest/Makefile
@@ -6,14 +6,14 @@ default_target: all
# Ideally we'd just include something to give us variables
# for paths and arguments to tools etc, and those set in mk/build.mk.
TOP=..
-include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/config.mk
all:
$(RM) -rf $(BIN_DIST_INST_SUBDIR)
$(RM) -rf ghc*
$(RM) HelloWorld HelloWorld.o HelloWorld.hi output
# --force-local makes tar not think that c:/foo refers to a remote file
- $(TAR) --force-local -jxf $(FPTOOLS_TOP_ABS)/$(BIN_DIST_TAR_BZ2)
+ $(TAR) --force-local -jxf $(BIN_DIST_TAR_BZ2)
ifeq "$(Windows)" "YES"
mv $(BIN_DIST_NAME) $(BIN_DIST_INST_DIR)
else
View
20 boot
@@ -4,9 +4,9 @@ set -e
# Check that we have all boot packages.
for dir in `grep "^[^# ][^ ]* *[^ ][^ ]* *[^ ][^ ]*$" packages | sed "s/ .*//"`
do
- if test ! -d $dir
+ if test ! -f $dir/LICENSE
then
- echo "Looks like you're missing $dir." >&2
+ echo "Error: $dir/LICENSE doesn't exist." >&2
echo "Maybe you haven't done './darcs-all get'?" >&2
exit 1
fi
@@ -31,3 +31,19 @@ do
fi
done
+for f in libraries/*; do
+ dir=`basename $f`
+ cabals=`echo $f/*.cabal`
+ if test -f $cabals; then
+ echo "Creating $f/ghc.mk"
+ rm -f $f/ghc.mk
+ pkg=`basename ${cabals%.cabal}`
+ echo "${f}_PACKAGE = ${pkg}" >> $f/ghc.mk
+ echo "\$(eval \$(call build-package,${f},dist-install,1))" >> $f/ghc.mk
+ rm -f $f/GNUmakefile
+ echo "Creating $f/GNUmakefile"
+ echo "dir = ${f}" >> $f/GNUmakefile
+ echo "TOP = ../.." >> $f/GNUmakefile
+ echo "include \$(TOP)/mk/sub-makefile.mk" >> $f/GNUmakefile
+ fi
+done
View
31 compiler/LICENSE
@@ -0,0 +1,31 @@
+The Glasgow Haskell Compiler License
+
+Copyright 2002, The University Court of the University of Glasgow.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+- Neither name of the University nor the names of its contributors may be
+used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
+GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
View
507 compiler/Makefile
@@ -1,503 +1,16 @@
-# -----------------------------------------------------------------------------
-# Main compiler Makefile
-
-# Targets:
-#
-# all builds stage1 compiler
-#
-# boot stage=N generate build dirs and dependencies for stage N.
-# NB. Must be done before 'make stageN'.
-# NB. Cannot 'make boot stage=2' until stage1 has
-# been built (similarly for stage3).
-#
-# stage1 (or stage=1) builds stage1 compiler
-# stage2 (or stage=2) builds stage2 compiler
-# stage3 (or stage=3) builds stage3 compiler
-#
-
+dir = compiler
TOP = ..
+SPEC_TARGETS = 1 2 3
+include $(TOP)/mk/sub-makefile.mk
-ifeq "$(stage)" ""
-stage=1
-endif
-
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal-flags.mk
-
-ifeq "$(GhcThreaded) $(GhcProfiled)" "YES YES"
-$(error Cannot make GHC both threaded and profiled)
-endif
-
-CONFIG_HS = main/Config.hs
-PRIMOP_BITS = primop-data-decl.hs-incl \
- primop-tag.hs-incl \
- primop-list.hs-incl \
- primop-has-side-effects.hs-incl \
- primop-out-of-line.hs-incl \
- primop-commutable.hs-incl \
- primop-needs-wrapper.hs-incl \
- primop-can-fail.hs-incl \
- primop-strictness.hs-incl \
- primop-primop-info.hs-incl
-
-boot:: boot.stage.$(stage)
-
-all:: build.stage.$(stage)
-
-doc:: doc.stage.$(stage)
-
-stage1 ::
- $(MAKE) stage=1
-
-stage2 ::
- $(MAKE) stage=2
-
-stage3 ::
- $(MAKE) stage=3
-
-ifeq "$(CLEAN_ALL_STAGES)" "YES"
-clean distclean maintainer-clean::
- $(RM) -f prelude/primops.txt
- $(RM) -f $(PRIMOP_BITS)
- $(RM) -f $(CONFIG_HS)
- $(RM) -f parser/Parser.y
- $(RM) -rf stage1 stage2plus
- $(RM) -f $(STAGE3_PACKAGE_CONF)
-endif
-
-ifeq "$(CLEAN_ALL_STAGES)" "YES"
-clean distclean maintainer-clean:: clean.stage.1 clean.stage.2 clean.stage.3
-else
-clean distclean maintainer-clean:: clean.stage.$(stage)
-endif
-
-ifeq "$(CLEAN_ALL_STAGES)" "YES"
-distclean maintainer-clean::
- $(RM) -f ghc.cabal
-endif
-
-clean.stage.%:
- $(RM) -f Makefile-stage$*
-# This is a bit naughty. We ought to use:
-# -$(CABAL) clean --distpref dist-stage$*
-# but that won't work if the Cabal file (a generated file) doesn't
-# exist. So we do this instead:
- $(RM) -rf dist-stage$*
-
-CONFIGURE_FLAGS_STAGE1 += --flags=stage1
-CONFIGURE_FLAGS_STAGE2 += --flags=-stage1
-
-ifeq "$(GhcWithNativeCodeGen)" "YES"
-CONFIGURE_FLAGS_STAGE1 += --flags=ncg
-CONFIGURE_FLAGS_STAGE2 += --flags=ncg
-endif
-
-ifeq "$(GhcWithInterpreter)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --flags=ghci
-
-ifeq "$(BuildSharedLibs)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --enable-shared
-# If we are going to use dynamic libraries instead of .o files for ghci,
-# we will need to always retain CAFs in the compiler.
-# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
-# function which sets the keepCAFs flag for the RTS before any Haskell
-# code is run.
-CONFIGURE_FLAGS_STAGE2 += --flags=dynlibs
-endif
-
-ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
-# Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
-# or not?
-# XXX This should logically be a CPP option, but there doesn't seem to
-# be a flag for that
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
-endif
-
-# Should the debugger commands be enabled?
-ifeq "$(GhciWithDebugger)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DDEBUGGER
-endif
-
-# Enable editline if:
-# - we're building stage 2/3, and we have built the editline package
-#
-# But we don't enable editline on Windows, as Windows terminals have
-# editline-like support builtin.
-#
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)" ""
-CONFIGURE_FLAGS_STAGE2 += --flags=editline
-endif
-endif
-endif
-
-ifeq "$(GhcWithNativeCodeGen)" "NO"
-# XXX This should logically be a CPP option, but there doesn't seem to
-# be a flag for that
-COMMON_CONFIGURE_FLAGS += --ghc-option=-DOMIT_NATIVE_CODEGEN
-endif
-
-ifeq "$(TargetOS_CPP)" "openbsd"
-COMMON_CONFIGURE_FLAGS += --ld-options=-E
-endif
-
-ifeq "$(GhcUnregisterised)" "NO"
-ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux"
-# needed for generating proper relocation in large binaries: trac #856
-COMMON_CONFIGURE_FLAGS += --ld-option=-Wl,--relax
-endif
-endif
-
-# We need to turn on profiling either if we have been asked to
-# (GhcLibProfiled = YES) or if we want GHC itself to be compiled with
-# profiling enabled (GhcProfiled = YES).
-ifneq "$(GhcLibProfiled) $(GhcProfiled)" "NO NO"
-CONFIGURE_FLAGS_STAGE2 += --enable-library-profiling
-# And if we're profiling GHC then we want lots of SCCs.
-# We also don't want to waste time building the non-profiling library,
-# either normally or for ghci. Unfortunately this means that we have to
-# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
-# exist.
-ifeq "$(GhcProfiled)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-auto-all
-CONFIGURE_FLAGS_STAGE2 += --disable-library-vanilla
-CONFIGURE_FLAGS_STAGE2 += --disable-library-for-ghci
-CONFIGURE_FLAGS_STAGE2 += --ghc-pkg-option=--force
-endif
-endif
-
-ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-# The #include is vital for the via-C route with older compilers, else the C
-# compiler doesn't realise that the stcall foreign imports are indeed
-# stdcall, and doesn't generate the Foo@8 name for them
-# As it's only important for older compilers we don't need to do anything
-# for stage2+.
-CONFIGURE_FLAGS_STAGE1 += --ghc-option='-\#include' \
- --ghc-option='"<windows.h>"' \
- --ghc-option='-\#include' \
- --ghc-option='"<process.h>"'
-endif
-
-# ghc_strlen percolates through so many modules that it is easier to get its
-# prototype via a global option instead of a myriad of per-file OPTIONS.
-# Again, this is only important for older compilers, so we don't do it in
-# stage 2+.
-CONFIGURE_FLAGS_STAGE1 += --ghc-options='-\#include "cutils.h"'
-
-CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
-CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE3 += --package-db $(STAGE3_PACKAGE_CONF)
-
-# In a source dist we don't need to worry about Parser.y(.pp) as we have
-# the .hs file pre-generated
-ifneq "$(wildcard parser/Parser.y.pp)" ""
-PARSER_Y = parser/Parser.y
-endif
-
-boot.stage.%: $(PRIMOP_BITS) $(CONFIG_HS) $(PARSER_Y)
- test -f $(STAGE3_PACKAGE_CONF) || echo "[]" > $(STAGE3_PACKAGE_CONF)
- $(CABAL) configure --distpref dist-stage$* \
- $(CONFIGURE_FLAGS_STAGE$*) \
- $(INSTALL_DIRS_CONFIGURE_FLAGS) \
- $(COMMON_CONFIGURE_FLAGS) \
- --ghc-option=-DSTAGE=$*
- $(RM) -f Makefile-stage$*
- $(CABAL) makefile --distpref dist-stage$* -f Makefile-stage$*
-
-build.stage.%:
- $(MAKE) -f Makefile-stage$* stage=$*
- $(CABAL) register --distpref dist-stage$* --inplace
- $(MAKE) -C ../ghc stage=$*
-
-doc.stage.%:
- $(CABAL) haddock --distpref dist-stage$* \
- --html-location='../$$pkg' \
- --haddock-option=--optghc=-DSTAGE=$* \
- --haddock-option=+RTS --haddock-option=-s --haddock-option=-c --haddock-option=-RTS \
- --with-haddock=$(FPTOOLS_TOP_ABS)/utils/haddock/install-inplace/bin/haddock
-
-install:
- $(INSTALL_PACKAGE) install '$(GHC_PKG_INSTALL_PROG)' '$(DESTDIR)$(datadir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' --distpref dist-stage2
-
-# -----------------------------------------------------------------------------
-# Create compiler configuration
-#
-# The 'echo' commands simply spit the values of various make variables
-# into Config.hs, whence they can be compiled and used by GHC itself
-
-$(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk
- @$(RM) -f $(CONFIG_HS)
- @echo "Creating $(CONFIG_HS) ... "
- @echo "module Config where" >>$(CONFIG_HS)
- @echo "cProjectName :: String" >> $(CONFIG_HS)
- @echo "cProjectName = \"$(ProjectName)\"" >> $(CONFIG_HS)
- @echo "cProjectVersion :: String" >> $(CONFIG_HS)
- @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
- @echo "cProjectVersionInt :: String" >> $(CONFIG_HS)
- @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
- @echo "cProjectPatchLevel :: String" >> $(CONFIG_HS)
- @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
- @echo "cBooterVersion :: String" >> $(CONFIG_HS)
- @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS)
- @echo "cStage :: String" >> $(CONFIG_HS)
- @echo "cStage = show (STAGE :: Int)" >> $(CONFIG_HS)
- @echo "cHscIfaceFileVersion :: String" >> $(CONFIG_HS)
- @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
- @echo "cSplitObjs :: String" >> $(CONFIG_HS)
- @echo "cSplitObjs = \"$(SupportsSplitObjs)\"" >> $(CONFIG_HS)
- @echo "cGhcWithInterpreter :: String" >> $(CONFIG_HS)
- @echo "cGhcWithInterpreter = \"$(GhcWithInterpreter)\"" >> $(CONFIG_HS)
- @echo "cGhcWithNativeCodeGen :: String" >> $(CONFIG_HS)
- @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
- @echo "cGhcWithSMP :: String" >> $(CONFIG_HS)
- @echo "cGhcWithSMP = \"$(GhcWithSMP)\"" >> $(CONFIG_HS)
- @echo "cGhcRTSWays :: String" >> $(CONFIG_HS)
- @echo "cGhcRTSWays = \"$(GhcRTSWays)\"" >> $(CONFIG_HS)
- @echo "cGhcUnregisterised :: String" >> $(CONFIG_HS)
- @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
- @echo "cGhcEnableTablesNextToCode :: String" >> $(CONFIG_HS)
- @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $(CONFIG_HS)
- @echo "cLeadingUnderscore :: String" >> $(CONFIG_HS)
- @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
- @echo "cRAWCPP_FLAGS :: String" >> $(CONFIG_HS)
- @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
- @echo "cGCC :: String" >> $(CONFIG_HS)
- @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
- @echo "cMKDLL :: String" >> $(CONFIG_HS)
- @echo "cMKDLL = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
- @echo "cLdIsGNULd :: String" >> $(CONFIG_HS)
- @echo "cLdIsGNULd = \"$(LdIsGNULd)\"" >> $(CONFIG_HS)
- @echo "cLD_X :: String" >> $(CONFIG_HS)
- @echo "cLD_X = \"$(LD_X)\"" >> $(CONFIG_HS)
- @echo "cGHC_DRIVER_DIR_REL :: String" >> $(CONFIG_HS)
- @echo "cGHC_DRIVER_DIR_REL = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
- @echo "cGHC_TOUCHY_PGM :: String" >> $(CONFIG_HS)
- @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
- @echo "cGHC_TOUCHY_DIR_REL :: String" >> $(CONFIG_HS)
- @echo "cGHC_TOUCHY_DIR_REL = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
- @echo "cGHC_UNLIT_PGM :: String" >> $(CONFIG_HS)
- @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
- @echo "cGHC_UNLIT_DIR_REL :: String" >> $(CONFIG_HS)
- @echo "cGHC_UNLIT_DIR_REL = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
- @echo "cGHC_MANGLER_PGM :: String" >> $(CONFIG_HS)
- @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
- @echo "cGHC_MANGLER_DIR_REL :: String" >> $(CONFIG_HS)
- @echo "cGHC_MANGLER_DIR_REL = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
- @echo "cGHC_SPLIT_PGM :: String" >> $(CONFIG_HS)
- @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
- @echo "cGHC_SPLIT_DIR_REL :: String" >> $(CONFIG_HS)
- @echo "cGHC_SPLIT_DIR_REL = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
- @echo "cGHC_SYSMAN_PGM :: String" >> $(CONFIG_HS)
- @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
- @echo "cGHC_SYSMAN_DIR_REL :: String" >> $(CONFIG_HS)
- @echo "cGHC_SYSMAN_DIR_REL = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
- @echo "cGHC_CP :: String" >> $(CONFIG_HS)
- @echo "cGHC_CP = \"$(GHC_CP)\"" >> $(CONFIG_HS)
- @echo "cGHC_PERL :: String" >> $(CONFIG_HS)
- @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
- @echo "cEnableWin32DLLs :: String" >> $(CONFIG_HS)
- @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
- @echo "cCONTEXT_DIFF :: String" >> $(CONFIG_HS)
- @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
- @echo "cUSER_WAY_NAMES :: String" >> $(CONFIG_HS)
- @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
- @echo "cUSER_WAY_OPTS :: String" >> $(CONFIG_HS)
- @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
- @echo "cDEFAULT_TMPDIR :: String" >> $(CONFIG_HS)
- @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
- @echo "cRelocatableBuild :: Bool" >> $(CONFIG_HS)
-ifeq "$(RelocatableBuild)" "YES"
- @echo "cRelocatableBuild = True" >> $(CONFIG_HS)
-else
- @echo "cRelocatableBuild = False" >> $(CONFIG_HS)
-endif
- @echo "cLibFFI :: Bool" >> $(CONFIG_HS)
-ifeq "$(UseLibFFIForAdjustors)" "YES"
- @echo "cLibFFI = True" >> $(CONFIG_HS)
-else
- @echo "cLibFFI = False" >> $(CONFIG_HS)
-endif
- @echo done.
-
-# -----------------------------------------------------------------------------
-# Create platform includes
-
-# Here we generate a little header file containing CPP symbols that GHC
-# uses to determine which platform it is building on/for. The platforms
-# can differ between stage1 and stage2 if we're cross-compiling, so we
-# need one of these header files per stage.
-
-PLATFORM_H = ghc_boot_platform.h
-
-stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk
- $(MKDIRHIER) stage1
- @echo "Creating $@..."
- @$(RM) $@
- @echo "#ifndef __PLATFORM_H__" >$@
- @echo "#define __PLATFORM_H__" >>$@
- @echo >> $@
- @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
- @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
- @echo >> $@
- @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
- @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
- @echo >> $@
- @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
- @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
- @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
- @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
- @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
- @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
- @echo >> $@
- @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
- @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
- @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
- @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
- @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
- @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
-ifeq "$(HostOS_CPP)" "irix"
- @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
- @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
- @echo "#endif " >> $@
-endif
- @echo >> $@
- @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
- @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
- @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
- @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
- @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
- @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
- @echo >> $@
- @echo "#endif /* __PLATFORM_H__ */" >> $@
- @echo "Done."
-
-# For stage2 and above, the BUILD platform is the HOST of stage1, and
-# the HOST platform is the TARGET of stage1. The TARGET remains the same
-# (stage1 is the cross-compiler, not stage2).
-stage2plus/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk
- $(MKDIRHIER) stage2plus
- @echo "Creating $@..."
- @$(RM) $@
- @echo "#ifndef __PLATFORM_H__" >$@
- @echo "#define __PLATFORM_H__" >>$@
- @echo >> $@
- @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
- @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
- @echo >> $@
- @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
- @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
- @echo >> $@
- @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
- @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
- @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
- @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
- @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
- @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
- @echo >> $@
- @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
- @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
- @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
- @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
- @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
- @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
-ifeq "$(HostOS_CPP)" "irix"
- @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
- @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
- @echo "#endif " >> $@
-endif
- @echo >> $@
- @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
- @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
- @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
- @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
- @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
- @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
- @echo >> $@
- @echo "#endif /* __PLATFORM_H__ */" >> $@
- @echo "Done."
-
-ifeq "$(stage)" "1"
-STAGE_PLATFORM_H = stage1/$(PLATFORM_H)
-else
-STAGE_PLATFORM_H = stage2plus/$(PLATFORM_H)
-endif
-
-boot :: $(STAGE_PLATFORM_H)
-
-# ----------------------------------------------------------------------------
-# Generate supporting stuff for prelude/PrimOp.lhs
-# from prelude/primops.txt
-
-SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
-SRC_CPP_OPTS += ${GhcCppOpts}
-
-prelude/primops.txt parser/Parser.y: %: %.pp stage1/$(PLATFORM_H)
- $(CPP) $(RAWCPP_FLAGS) -P $(CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
-
-primop-data-decl.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --data-decl < $< > $@
-primop-tag.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --primop-tag < $< > $@
-primop-list.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --primop-list < $< > $@
-primop-has-side-effects.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --has-side-effects < $< > $@
-primop-out-of-line.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --out-of-line < $< > $@
-primop-commutable.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --commutable < $< > $@
-primop-needs-wrapper.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --needs-wrapper < $< > $@
-primop-can-fail.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --can-fail < $< > $@
-primop-strictness.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --strictness < $< > $@
-primop-primop-info.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --primop-primop-info < $< > $@
-
-# Usages aren't used any more; but the generator
-# can still generate them if we want them back
-primop-usage.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --usage < $< > $@
-
-html:
- $(MAKE) doc stage=2
-
-install-docs:
- @:
-
-#-----------------------------------------------------------------------------
-# binary-dist
-#
+.PHONY: 1 2 3
-# Ideally we'd get these from the Cabal file's Install-Includes:
-BINDIST_EXTRAS += HsVersions.h
-ifeq "$(stage)" "1"
-BINDIST_EXTRAS += stage1/ghc_boot_platform.h
-else
-BINDIST_EXTRAS += stage2plus/ghc_boot_platform.h
-endif
+1:
+ +$(TOPMAKE) stage=1 all_ghc_stage1 compiler_stage1_NO_BUILD_DEPS=YES
-include $(TOP)/mk/bindist.mk
-LIB_DIST_DIR = dist-stage2
+2:
+ +$(TOPMAKE) stage=2 all_ghc_stage2 compiler_stage2_NO_BUILD_DEPS=YES
-#-----------------------------------------------------------------------------
-# etags generation
-ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-GHCTAGS = $(TOP)/utils/ghctags/ghctags.exe
-else
-GHCTAGS = $(TOP)/utils/ghctags/ghctags-inplace
-endif
-GHCTAGS_ROOT = main/GHC.hs ghci/InteractiveUI.hs main/PprTyThing.hs
+3:
+ +$(TOPMAKE) stage=3 all_ghc_stage3 compiler_stage3_NO_BUILD_DEPS=YES
-# etags for stage2 is actually broken since it requires building
-# ghctags against an older ghc api
-etags: etags.stage.2
-etags.stage.%:
- $(GHCTAGS) --topdir $(FPTOOLS_TOP_ABS) --etags --use-cabal-config=./dist-stage$* -- -DSTAGE=$* -- $(GHCTAGS_ROOT)
View
19 compiler/ghc.cabal.in
@@ -1,3 +1,6 @@
+-- WARNING: ghc.cabal is automatically generated from ghc.cabal.in by
+-- ./configure. Make sure you are editing ghc.cabal.in, not ghc.cabal.
+
Name: ghc
Version: @ProjectVersion@
License: BSD3
@@ -45,6 +48,15 @@ Flag ncg
Flag stage1
Description: Is this stage 1?
+ Default: False
+
+Flag stage2
+ Description: Is this stage 2?
+ Default: False
+
+Flag stage3
+ Description: Is this stage 3?
+ Default: False
Library
Exposed: False
@@ -103,7 +115,12 @@ Library
Build-Depends: extensible-exceptions
Extensions: PatternSignatures
else
- Include-Dirs: stage2plus
+ if flag(stage2)
+ Include-Dirs: stage2
+ else
+ if flag(stage3)
+ Include-Dirs: stage2
+
Install-Includes: HsVersions.h, ghc_boot_platform.h
c-sources:
View
432 compiler/ghc.mk
@@ -0,0 +1,432 @@
+# -----------------------------------------------------------------------------
+# For expressing extra dependencies on source files
+
+define compiler-hs-dependency # args: $1 = module, $2 = dependency
+
+$$(foreach stage,1 2 3,\
+ $$(foreach way,$$(compiler_stage$$(stage)_WAYS),\
+ compiler/stage$$(stage)/build/$1.$($(way)_osuf))) : $2
+
+endef
+
+# -----------------------------------------------------------------------------
+# Create compiler configuration
+#
+# The 'echo' commands simply spit the values of various make variables
+# into Config.hs, whence they can be compiled and used by GHC itself
+
+compiler_CONFIG_HS = compiler/main/Config.hs
+
+ifneq "$(BINDIST)" "YES"
+compiler/stage1/package-data.mk : $(compiler_CONFIG_HS)
+compiler/stage2/package-data.mk : $(compiler_CONFIG_HS)
+compiler/stage3/package-data.mk : $(compiler_CONFIG_HS)
+endif
+
+$(compiler_CONFIG_HS) : mk/config.mk
+ $(RM) -f $@
+ @echo "Creating $@ ... "
+ @echo "module Config where" >>$@
+ @echo "cProjectName :: String" >> $@
+ @echo "cProjectName = \"$(ProjectName)\"" >> $@
+ @echo "cProjectVersion :: String" >> $@
+ @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $@
+ @echo "cProjectVersionInt :: String" >> $@
+ @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $@
+ @echo "cProjectPatchLevel :: String" >> $@
+ @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $@
+ @echo "cBooterVersion :: String" >> $@
+ @echo "cBooterVersion = \"$(GhcVersion)\"" >> $@
+ @echo "cStage :: String" >> $@
+ @echo "cStage = show (STAGE :: Int)" >> $@
+ @echo "cHscIfaceFileVersion :: String" >> $@
+ @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $@
+ @echo "cSplitObjs :: String" >> $@
+ @echo "cSplitObjs = \"$(SupportsSplitObjs)\"" >> $@
+ @echo "cGhcWithInterpreter :: String" >> $@
+ @echo "cGhcWithInterpreter = \"$(GhcWithInterpreter)\"" >> $@
+ @echo "cGhcWithNativeCodeGen :: String" >> $@
+ @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $@
+ @echo "cGhcWithSMP :: String" >> $@
+ @echo "cGhcWithSMP = \"$(GhcWithSMP)\"" >> $@
+ @echo "cGhcRTSWays :: String" >> $@
+ @echo "cGhcRTSWays = \"$(GhcRTSWays)\"" >> $@
+ @echo "cGhcUnregisterised :: String" >> $@
+ @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $@
+ @echo "cGhcEnableTablesNextToCode :: String" >> $@
+ @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $@
+ @echo "cLeadingUnderscore :: String" >> $@
+ @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $@
+ @echo "cRAWCPP_FLAGS :: String" >> $@
+ @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $@
+ @echo "cGCC :: String" >> $@
+ @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $@
+ @echo "cMKDLL :: String" >> $@
+ @echo "cMKDLL = \"$(BLD_DLL)\"" >> $@
+ @echo "cLdIsGNULd :: String" >> $@
+ @echo "cLdIsGNULd = \"$(LdIsGNULd)\"" >> $@
+ @echo "cLD_X :: String" >> $@
+ @echo "cLD_X = \"$(LD_X)\"" >> $@
+ @echo "cGHC_DRIVER_DIR :: String" >> $@
+ @echo "cGHC_DRIVER_DIR = \"$(GHC_DRIVER_DIR)\"" >> $@
+ @echo "cGHC_TOUCHY_PGM :: String" >> $@
+ @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $@
+ @echo "cGHC_TOUCHY_DIR :: String" >> $@
+ @echo "cGHC_TOUCHY_DIR = \"$(GHC_TOUCHY_DIR)\"" >> $@
+ @echo "cGHC_UNLIT_PGM :: String" >> $@
+ @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $@
+ @echo "cGHC_UNLIT_DIR :: String" >> $@
+ @echo "cGHC_UNLIT_DIR = \"$(GHC_UNLIT_DIR)\"" >> $@
+ @echo "cGHC_MANGLER_PGM :: String" >> $@
+ @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $@
+ @echo "cGHC_MANGLER_DIR :: String" >> $@
+ @echo "cGHC_MANGLER_DIR = \"$(GHC_MANGLER_DIR)\"" >> $@
+ @echo "cGHC_SPLIT_PGM :: String" >> $@
+ @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $@
+ @echo "cGHC_SPLIT_DIR :: String" >> $@
+ @echo "cGHC_SPLIT_DIR = \"$(GHC_SPLIT_DIR)\"" >> $@
+ @echo "cGHC_SYSMAN_PGM :: String" >> $@
+ @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $@
+ @echo "cGHC_SYSMAN_DIR :: String" >> $@
+ @echo "cGHC_SYSMAN_DIR = \"$(GHC_SYSMAN_DIR)\"" >> $@
+ @echo "cGHC_CP :: String" >> $@
+ @echo "cGHC_CP = \"$(GHC_CP)\"" >> $@
+ @echo "cGHC_PERL :: String" >> $@
+ @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $@
+ @echo "cEnableWin32DLLs :: String" >> $@
+ @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $@
+ @echo "cCONTEXT_DIFF :: String" >> $@
+ @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $@
+ @echo "cUSER_WAY_NAMES :: String" >> $@
+ @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $@
+ @echo "cUSER_WAY_OPTS :: String" >> $@
+ @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $@
+ @echo "cDEFAULT_TMPDIR :: String" >> $@
+ @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $@
+ @echo "cRelocatableBuild :: Bool" >> $@
+ifeq "$(RelocatableBuild)" "YES"
+ @echo "cRelocatableBuild = True" >> $@
+else
+ @echo "cRelocatableBuild = False" >> $@
+endif
+ @echo "cLibFFI :: Bool" >> $@
+ifeq "$(UseLibFFIForAdjustors)" "YES"
+ @echo "cLibFFI = True" >> $@
+else
+ @echo "cLibFFI = False" >> $@
+endif
+ @echo done.
+
+$(eval $(call clean-target,compiler,config_hs,$(compiler_CONFIG_HS)))
+
+# -----------------------------------------------------------------------------
+# Create platform includes
+
+# Here we generate a little header file containing CPP symbols that GHC
+# uses to determine which platform it is building on/for. The platforms
+# can differ between stage1 and stage2 if we're cross-compiling, so we
+# need one of these header files per stage.
+
+PLATFORM_H = ghc_boot_platform.h
+
+compiler/stage1/$(PLATFORM_H) : mk/config.mk
+ $(MKDIRHIER) $(dir $@)
+ $(RM) $@
+ @echo "Creating $@..."
+ @echo "#ifndef __PLATFORM_H__" >$@
+ @echo "#define __PLATFORM_H__" >>$@
+ @echo >> $@
+ @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
+ @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
+ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
+ @echo >> $@
+ @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
+ @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
+ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
+ @echo >> $@
+ @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
+ @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
+ @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
+ @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
+ @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
+ @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
+ @echo >> $@
+ @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
+ @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
+ @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
+ @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
+ @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
+ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
+ifeq "$(HostOS_CPP)" "irix"
+ @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
+ @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
+ @echo "#endif " >> $@
+endif
+ @echo >> $@
+ @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
+ @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
+ @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
+ @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
+ @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
+ @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
+ @echo >> $@
+ @echo "#endif /* __PLATFORM_H__ */" >> $@
+ @echo "Done."
+
+# For stage2 and above, the BUILD platform is the HOST of stage1, and
+# the HOST platform is the TARGET of stage1. The TARGET remains the same
+# (stage1 is the cross-compiler, not stage2).
+compiler/stage2/$(PLATFORM_H) : mk/config.mk
+ $(MKDIRHIER) $(dir $@)
+ $(RM) $@
+ @echo "Creating $@..."
+ @echo "#ifndef __PLATFORM_H__" >$@
+ @echo "#define __PLATFORM_H__" >>$@
+ @echo >> $@
+ @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
+ @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
+ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
+ @echo >> $@
+ @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
+ @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
+ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
+ @echo >> $@
+ @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
+ @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
+ @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
+ @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
+ @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
+ @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
+ @echo >> $@
+ @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
+ @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
+ @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
+ @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
+ @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
+ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
+ifeq "$(HostOS_CPP)" "irix"
+ @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
+ @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
+ @echo "#endif " >> $@
+endif
+ @echo >> $@
+ @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
+ @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
+ @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
+ @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
+ @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
+ @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
+ @echo >> $@
+ @echo "#endif /* __PLATFORM_H__ */" >> $@
+ @echo "Done."
+
+compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
+ $(CP) $< $@
+
+# Every Constants.o object file depends on includes/GHCConstants.h:
+$(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS)))
+
+# ----------------------------------------------------------------------------
+# Generate supporting stuff for prelude/PrimOp.lhs
+# from prelude/primops.txt
+
+# XXX: these should go in stage1/stage2/stage3
+PRIMOP_BITS = compiler/primop-data-decl.hs-incl \
+ compiler/primop-tag.hs-incl \
+ compiler/primop-list.hs-incl \
+ compiler/primop-has-side-effects.hs-incl \
+ compiler/primop-out-of-line.hs-incl \
+ compiler/primop-commutable.hs-incl \
+ compiler/primop-needs-wrapper.hs-incl \
+ compiler/primop-can-fail.hs-incl \
+ compiler/primop-strictness.hs-incl \
+ compiler/primop-primop-info.hs-incl
+
+compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
+compiler_CPP_OPTS += ${GhcCppOpts}
+
+$(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
+ $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
+
+$(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS)))
+
+compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --data-decl < $< > $@
+compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --primop-tag < $< > $@
+compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --primop-list < $< > $@
+compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --has-side-effects < $< > $@
+compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --out-of-line < $< > $@
+compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --commutable < $< > $@
+compiler/primop-needs-wrapper.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --needs-wrapper < $< > $@
+compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --can-fail < $< > $@
+compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --strictness < $< > $@
+compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
+ $(GENPRIMOP_INPLACE) --primop-primop-info < $< > $@
+
+# Every PrimOp.o object file depends on $(PRIMOP_BITS):
+$(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS)))
+
+# Usages aren't used any more; but the generator
+# can still generate them if we want them back
+compiler/primop-usage.hs-incl: $(PRIMOPS_TXT)
+ $(GENPRIMOP_INPLACE) --usage < $< > $@
+
+# -----------------------------------------------------------------------------
+# Configuration
+
+compiler_stage1_CONFIGURE_OPTS += --flags=stage1
+compiler_stage2_CONFIGURE_OPTS += --flags=stage2
+compiler_stage3_CONFIGURE_OPTS += --flags=stage3
+
+ifeq "$(GhcWithNativeCodeGen)" "YES"
+compiler_stage1_CONFIGURE_OPTS += --flags=ncg
+compiler_stage2_CONFIGURE_OPTS += --flags=ncg
+endif
+
+ifeq "$(GhcWithInterpreter)" "YES"
+compiler_stage2_CONFIGURE_OPTS += --flags=ghci
+
+ifeq "$(BuildSharedLibs)" "YES"
+compiler_stage2_CONFIGURE_OPTS += --enable-shared
+# If we are going to use dynamic libraries instead of .o files for ghci,
+# we will need to always retain CAFs in the compiler.
+# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
+# function which sets the keepCAFs flag for the RTS before any Haskell
+# code is run.
+compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs
+endif
+
+ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
+# Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
+# or not?
+# XXX This should logically be a CPP option, but there doesn't seem to
+# be a flag for that
+compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
+endif
+
+# Should the debugger commands be enabled?
+ifeq "$(GhciWithDebugger)" "YES"
+compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
+endif
+
+endif
+
+ifeq "$(GhcWithNativeCodeGen)" "NO"
+# XXX This should logically be a CPP option, but there doesn't seem to
+# be a flag for that
+compiler_CONFIGURE_OPTS += --ghc-option=-DOMIT_NATIVE_CODEGEN
+endif
+
+ifeq "$(TargetOS_CPP)" "openbsd"
+compiler_CONFIGURE_OPTS += --ld-options=-E
+endif
+
+ifeq "$(GhcUnregisterised)" "NO"
+ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux"
+# needed for generating proper relocation in large binaries: trac #856
+compiler_CONFIGURE_OPTS += --ld-option=-Wl,--relax
+endif
+endif
+
+# We need to turn on profiling either if we have been asked to
+# (GhcLibProfiled = YES) or if we want GHC itself to be compiled with
+# profiling enabled (GhcProfiled = YES).
+ifneq "$(GhcLibProfiled) $(GhcProfiled)" "NO NO"
+compiler_stage2_CONFIGURE_OPTS += --enable-library-profiling
+# And if we're profiling GHC then we want lots of SCCs.
+# We also don't want to waste time building the non-profiling library,
+# either normally or for ghci. Unfortunately this means that we have to
+# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
+# exist.
+ifeq "$(GhcProfiled)" "YES"
+compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
+compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
+compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
+compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
+endif
+endif
+
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+# The #include is vital for the via-C route with older compilers, else the C
+# compiler doesn't realise that the stcall foreign imports are indeed
+# stdcall, and doesn't generate the Foo@8 name for them
+# As it's only important for older compilers we don't need to do anything
+# for stage2+.
+compiler_stage1_CONFIGURE_OPTS += --ghc-option='-\#include' \
+ --ghc-option='"<windows.h>"' \
+ --ghc-option='-\#include' \
+ --ghc-option='"<process.h>"'
+endif
+
+# ghc_strlen percolates through so many modules that it is easier to get its
+# prototype via a global option instead of a myriad of per-file OPTIONS.
+# Again, this is only important for older compilers, so we don't do it in
+# stage 2+.
+compiler_stage1_CONFIGURE_OPTS += --ghc-options='-\#include "cutils.h"'
+
+compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
+
+compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
+compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
+compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
+compiler_stage2_HADDOCK_OPTS += --haddock-option=--optghc=-DSTAGE=2
+
+compiler_stage1_CONFIGURE_OPTS += --ghc-options='$(GhcStage1HcOpts)'
+compiler_stage2_CONFIGURE_OPTS += --ghc-options='$(GhcStage2HcOpts)'
+compiler_stage3_CONFIGURE_OPTS += --ghc-options='$(GhcStage3HcOpts)'
+
+compiler/stage1/package-data.mk : compiler/ghc.mk
+compiler/stage2/package-data.mk : compiler/ghc.mk
+compiler/stage3/package-data.mk : compiler/ghc.mk
+
+# -----------------------------------------------------------------------------
+# And build the package
+
+compiler_PACKAGE = ghc
+
+# haddocking only happens for stage2
+compiler_stage1_DO_HADDOCK = NO
+compiler_stage3_DO_HADDOCK = NO
+
+# Don't do splitting for the GHC package, it takes too long and
+# there's not much benefit.
+compiler_stage1_SplitObjs = NO
+compiler_stage2_SplitObjs = NO
+compiler_stage3_SplitObjs = NO
+
+# For now, bindists always use stage 2
+ifneq "$(BINDIST)" "YES"
+# stage 1 is enabled unless $(stage) is set to something other than 1
+ifeq "$(filter-out 1,$(stage))" ""
+$(eval $(call build-package,compiler,stage1,0))
+endif
+endif
+
+# stage 2 is enabled unless $(stage) is set to something other than 2
+ifeq "$(filter-out 2,$(stage))" ""
+$(eval $(call build-package,compiler,stage2,1))
+endif
+
+ifneq "$(BINDIST)" "YES"
+# stage 3 has to be requested explicitly with stage=3
+ifeq "$(stage)" "3"
+$(eval $(call build-package,compiler,stage3,2))
+endif
+
+$(compiler_stage1_depfile) : compiler/stage1/$(PLATFORM_H)
+$(compiler_stage2_depfile) : compiler/stage2/$(PLATFORM_H)
+$(compiler_stage3_depfile) : compiler/stage3/$(PLATFORM_H)
+
+$(compiler_stage1_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
+$(compiler_stage2_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
+$(compiler_stage3_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
+endif
+
View
28 compiler/main/DriverMkDepend.hs
@@ -72,7 +72,8 @@ doMkDependHS srcs = do
-- Prcess them one by one, dumping results into makefile
-- and complaining about cycles
hsc_env <- getSession
- mapM (liftIO . processDeps dflags hsc_env excl_mods (mkd_tmp_hdl files)) sorted
+ root <- liftIO getCurrentDirectory
+ mapM (liftIO . processDeps dflags hsc_env excl_mods root (mkd_tmp_hdl files)) sorted
-- If -ddump-mod-cycles, show cycles in the module graph
liftIO $ dumpModCycles dflags mod_summaries
@@ -158,6 +159,7 @@ beginMkDependHS dflags = do
processDeps :: DynFlags
-> HscEnv
-> [ModuleName]
+ -> FilePath
-> Handle -- Write dependencies to here
-> SCC ModSummary
-> IO ()
@@ -176,11 +178,11 @@ processDeps :: DynFlags
--
-- For {-# SOURCE #-} imports the "hi" will be "hi-boot".
-processDeps _ _ _ _ (CyclicSCC nodes)
+processDeps _ _ _ _ _ (CyclicSCC nodes)
= -- There shouldn't be any cycles; report them
ghcError (ProgramError (showSDoc $ GHC.cyclicModuleErr nodes))
-processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node)
+processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC node)
= do { let extra_suffixes = depSuffixes dflags
include_pkg_deps = depIncludePkgDeps dflags
src_file = msHsFilePath node
@@ -194,7 +196,7 @@ processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node)
Nothing -> return () ;
Just hi_file -> do
{ let hi_files = insertSuffixes hi_file extra_suffixes
- write_dep (obj,hi) = writeDependency hdl [obj] hi
+ write_dep (obj,hi) = writeDependency root hdl [obj] hi
-- Add one dependency for each suffix;
-- e.g. A.o : B.hi
@@ -204,7 +206,7 @@ processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node)
-- Emit std dependency of the object(s) on the source file
-- Something like A.o : A.hs
- ; writeDependency hdl obj_files src_file
+ ; writeDependency root hdl obj_files src_file
-- Emit a dependency for each import
@@ -248,12 +250,18 @@ findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps
}
-----------------------------
-writeDependency :: Handle -> [FilePath] -> FilePath -> IO ()
--- (writeDependency h [t1,t2] dep) writes to handle h the dependency
+writeDependency :: FilePath -> Handle -> [FilePath] -> FilePath -> IO ()
+-- (writeDependency r h [t1,t2] dep) writes to handle h the dependency
-- t1 t2 : dep
-writeDependency hdl targets dep
- = hPutStrLn hdl (unwords (map forOutput targets) ++ " : " ++ forOutput dep)
- where forOutput = escapeSpaces . reslash Forwards . normalise
+writeDependency root hdl targets dep
+ = do let -- We need to avoid making deps on
+ -- c:/foo/...
+ -- on cygwin as make gets confused by the :
+ -- Making relative deps avoids some instances of this.
+ dep' = makeRelative root dep
+ forOutput = escapeSpaces . reslash Forwards . normalise
+ output = unwords (map forOutput targets) ++ " : " ++ forOutput dep'
+ hPutStrLn hdl output
-----------------------------
insertSuffixes
View
200 compiler/main/SysTools.lhs
@@ -77,27 +77,20 @@ How GHC finds its files
[Note topdir]
GHC needs various support files (library packages, RTS etc), plus
-various auxiliary programs (cp, gcc, etc). It starts by finding topdir:
-
- for "installed" topdir is the root of GHC's support files ($libdir)
- for "in-place" topdir is the root of the build tree
+various auxiliary programs (cp, gcc, etc). It starts by finding topdir,
+the root of GHC's support files
On Unix:
- ghc always has a shell wrapper that passes a -B<dir> option
- - in an installation, <dir> is $libdir
- - in a build tree, <dir> is $TOP/inplace-datadir
- - so we detect the build-tree case and add ".." to get us back to $TOP
On Windows:
- ghc never has a shell wrapper.
- we can find the location of the ghc binary, which is
- $topdir/bin/ghc.exe in an installation, or
- $topdir/ghc/stage1-inplace/ghc.exe in a build tree.
- - we detect which one of these we have, and calculate $topdir.
-
+ $topdir/bin/<something>.exe
+ where <something> may be "ghc", "ghc-stage2", or similar
+ - we strip off the "bin/<something>.exe" to leave $topdir.
-from topdir we can find package.conf, which contains the locations of
-almost everything else, whether we're in a build tree or installed.
+from topdir we can find package.conf, ghc-asm, etc.
SysTools.initSysProgs figures out exactly where all the auxiliary programs
@@ -113,8 +106,8 @@ Config.hs contains two sorts of things
etc They do *not* include paths
- cUNLIT_DIR_REL The *path* to the directory containing unlit, split etc
- cSPLIT_DIR_REL *relative* to the root of the build tree,
+ cUNLIT_DIR The *path* to the directory containing unlit, split etc
+ cSPLIT_DIR *relative* to the root of the build tree,
for use when running *in-place* in a build tree (only)
@@ -159,46 +152,28 @@ initSysTools :: Maybe String -- Maybe TopDir path (without the '-B' prefix)
initSysTools mbMinusB dflags0
- = do { (am_installed, top_dir) <- findTopDir mbMinusB
+ = do { top_dir <- findTopDir mbMinusB
-- see [Note topdir]
-- NB: top_dir is assumed to be in standard Unix
-- format, '/' separated
- ; let installed, installed_bin :: FilePath -> FilePath
- installed_bin pgm = top_dir </> pgm
- installed file = top_dir </> file
- inplace dir pgm = top_dir </> dir </> pgm
-
- ; let pkgconfig_path
- | am_installed = installed "package.conf"
- | otherwise = inplace "inplace-datadir" "package.conf"
-
- ghc_usage_msg_path
- | am_installed = installed "ghc-usage.txt"
- | otherwise = inplace cGHC_DRIVER_DIR_REL "ghc-usage.txt"
+ ; let installed :: FilePath -> FilePath
+ installed file = top_dir </> file
+ installed_mingw_bin file = top_dir </> ".." </> "mingw" </> "bin" </> file
- ghci_usage_msg_path
- | am_installed = installed "ghci-usage.txt"
- | otherwise = inplace cGHC_DRIVER_DIR_REL "ghci-usage.txt"
+ ; let pkgconfig_path = installed "package.conf"
+ ghc_usage_msg_path = installed "ghc-usage.txt"
+ ghci_usage_msg_path = installed "ghci-usage.txt"
-- For all systems, unlit, split, mangle are GHC utilities
-- architecture-specific stuff is done when building Config.hs
- unlit_path
- | am_installed = installed_bin cGHC_UNLIT_PGM
- | otherwise = inplace cGHC_UNLIT_DIR_REL cGHC_UNLIT_PGM
+ unlit_path = installed cGHC_UNLIT_PGM