-# -----------------------------------------------------------------------------
-# don't recurse on 'make install'
-#
-ifeq "$(INSTALLING)" "1"
-all :: $(HS_PROG)
- $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
-clean distclean maintainer-clean ::
- $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
+$(INPLACE_PROG): $(INPLACE_HS)
+ $(GHC) --make $< -o $@
+
+all :: $(INPLACE_PROG)
+
+CLEAN_FILES += $(INPLACE_HS) $(INPLACE_PROG)
+
+ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+LINK = ghc-pkg
+LINK_TARGET = $(LINK)-$(ProjectVersion)
+INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
+install::
+ $(RM) -f $(INSTALLED_SCRIPT)
+ echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
+ echo "GHCPKGBIN=$(libexecdir)/$(HS_PROG)" >> $(INSTALLED_SCRIPT)
+ echo "PKGCONF=$(libdir)/package.conf" >> $(INSTALLED_SCRIPT)
+ echo 'exec $$GHCPKGBIN --global-conf $$PKGCONF $${1+"$$@"}' >> $(INSTALLED_SCRIPT)
+ $(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)