-# See "MSys Note 3" in compiler/Makefile
-$(INPLACE_SCRIPT_PROG).bat :
- echo '@call $(subst /,\,$(FPTOOLS_TOP_ABS_PLATFORM)/utils/ghc-pkg/$(HS_PROG)) --global-conf $(PKGCONF) %*' >> $@
- chmod 755 $@
+ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+LINK = ghc-pkg
+LINK_TARGET = $(LINK)-$(ProjectVersion)
+INSTALLED_SCRIPT=$(DESTDIR)$(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)