+# we could be more accurate here and add a dependency on
+# ghc/driver/package.conf, but that doesn't work too well because of
+# make's limited accuracy with modification times: when doing 'make
+# boot' in multiple packages, make won't detect that the package
+# configuration needs updating if it was updated already in the last
+# second.
+#
+# The stamp file goes in $(GHC_DRIVER_DIR), so that if someone happens
+# to 'make clean' in ghc without cleaning in libraries too, the packages
+# will be correctly re-installed.
+#
+ifeq "$(STANDALONE_PACKAGE)" "NO"
+
+STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
+CLEAN_FILES += $(STAMP_PKG_CONF)
+
+ifneq "$(BootingFromHc)" "YES"
+boot all :: $(STAMP_PKG_CONF)
+endif
+
+$(STAMP_PKG_CONF) : package.conf.inplace package.conf.installed
+ $(GHC_PKG_INPLACE) --update-package <package.conf.inplace
+ $(GHC_PKG_INPLACE) -f $(GHC_DRIVER_DIR)/package.conf --update-package <package.conf.installed
+ @touch $(STAMP_PKG_CONF)
+
+CLEAN_FILES += package.conf.installed package.conf.inplace
+
+else # $(STANDALONE_PACKAGE) == "YES"
+
+PACKAGE_CPP_OPTS += -DPACKAGE=\"${PACKAGE}\"
+PACKAGE_CPP_OPTS += -DPACKAGE_DEPS='$(patsubst %,"%"$(comma),$(PACKAGE_DEPS))'
+PACKAGE_CPP_OPTS += -DLIBRARY=\"HS$(PACKAGE)\"
+PACKAGE_CPP_OPTS += -DLIBDIR=\"$(libdir)\"
+
+# Let the package configuration file refer to $(libdir) as
+# ${pkglibdir}. Note we can't use ${libdir} because ghc-pkg already
+# redefines it to point to GHC's libdir (bug or feature?).
+#
+install :: package.conf.in
+ $(CPP) $(RAWCPP_FLAGS) $(PKGCONF_CPP_EXTRA_OPTS) -DINSTALLING -x c $(PACKAGE_CPP_OPTS) $< \
+ | sed -e 's/^#.*$$//g' -e 's/""//g' -e 's/, ]/ ]/g' \
+ | $(GHC_PKG) --force --update-package
+
+endif # $(STANDALONE_PACKAGE)