+.PHONY: fiddle-binary-dist
+fiddle-binary-dist:
+ cd $(BIN_DIST_DIR) && ../distrib/prep-bin-dist-mingw
+# Tar up the distribution and build a manifest
+binary-dist :: tar-binary-dist
+
+.PHONY: tar-binary-dist
+tar-binary-dist:
+ ( cd $(BIN_DIST_TOPDIR); tar cf - $(BIN_DIST_NAME) | bzip2 >$(BIN_DIST_TARBALL) )
+ ( cd $(BIN_DIST_TOPDIR); bunzip2 -c $(BIN_DIST_TARBALL) | tar tf - | sed "s/^ghc-$(ProjectVersion)/fptools/" | sort >bin-manifest-$(ProjectVersion) )
+
+PUBLISH_FILES = $(BIN_DIST_TARBALL)
+
+# Upload the distribution and documentation
+ifneq "$(ISCC)" ""
+WINDOWS_INSTALLER_BASE = ghc-$(ProjectVersion)-$(TARGETPLATFORM)
+WINDOWS_INSTALLER = $(WINDOWS_INSTALLER)$(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)" ""
+binary-dist :: publish-binary-dist
+endif
+
+.PHONY: publish-binary-dist
+publish-binary-dist ::
+ @for f in $(PUBLISH_FILES); do \
+ @for i in 0 1 2 3 4 5 6 7 8 9; do \
+ echo "Try $$i: $(PublishCp) $$f $(PublishLocation)/dist"; \
+ if $(PublishCp) $$f $(PublishLocation)/dist; then break; fi; \
+ done \
+ done
+
+ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+# On Windows, we cannot use absoluate pathnames to rsync, because they look
+# like remote pathnames ("c:/foo/bar"). Also, the docs reside in doc/
+# rather than share/, due to prep-bin-dist-mingw.
+publish-binary-dist ::
+ $(PublishCp) -r $(FPTOOLS_TOP)/$(BIN_DIST_NAME)/doc/html/* $(PublishLocation)/docs
+else
+publish-binary-dist ::
+ $(PublishCp) -r $(BIN_DIST_DIR)/share/html/* $(PublishLocation)/docs