+# 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 compiler/gcc-lib
+ mkdir compiler/gcc-lib
+ cp $(LD) compiler/gcc-lib
+ touch $@
+
+clean ::
+ $(RM) -r compiler/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
+
+# Same as default rule, but we pass $(INSTALL_STAGE) to $(MAKE) too
+install :: check-packages
+ @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)
+
+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
+
+# -----------------------------------------------------------------------------
+# 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.