-$(GHC_PKG_INPLACE) : utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext) $(MKDIRHIER)
- $(MKDIRHIER) $(dir $(INPLACE_PACKAGE_CONF))
- echo "[]" > $(INPLACE_PACKAGE_CONF)
+ifeq "$(BootingFromHc)" "YES"
+
+inplace/bin/ghc-pkg : utils/ghc-pkg/dist-install/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext)
+ifeq "$(Windows)" "YES"
+ cp $< $@
+else
+ "$(RM)" $(RM_OPTS) $@
+ echo "#!/bin/sh" >>$@
+ echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
+ echo '$(TOP)/$< --global-conf $$PKGCONF $${1+"$$@"}' >> $@
+ chmod +x $@
+endif
+
+else
+
+$(GHC_PKG_INPLACE) : utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext) | $$(dir $$@)/. $(INPLACE_PACKAGE_CONF)/.
+ "$(RM)" $(RM_OPTS) $(INPLACE_PACKAGE_CONF)/*