diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index c40e6708761..72f8075c734 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -131,9 +131,13 @@ html-stamp: stylesheet.xsl postgres.sgml $(ALLSGML)
cp $(srcdir)/stylesheet.css html/
touch $@
-htmlhelp: stylesheet-hh.xsl postgres.sgml $(ALLSGML)
+htmlhelp: htmlhelp-stamp
+
+htmlhelp-stamp: stylesheet-hh.xsl postgres.sgml $(ALLSGML)
$(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
$(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(wordlist 1,2,$^)
+ cp $(srcdir)/stylesheet.css htmlhelp/
+ touch $@
# single-page HTML
postgres.html: stylesheet-html-nochunk.xsl postgres.sgml $(ALLSGML)
@@ -284,7 +288,7 @@ clean:
# generated SGML files
rm -f $(GENERATED_SGML)
# HTML Help
- rm -f htmlhelp.hhp toc.hhc index.hhk
+ rm -rf htmlhelp/ htmlhelp-stamp
# EPUB
rm -f postgres.epub
# Texinfo
diff --git a/doc/src/sgml/stylesheet-hh.xsl b/doc/src/sgml/stylesheet-hh.xsl
index ae9c0c47c72..fb2da0b72f6 100644
--- a/doc/src/sgml/stylesheet-hh.xsl
+++ b/doc/src/sgml/stylesheet-hh.xsl
@@ -10,8 +10,10 @@
+
+