Skip to content

Commit 4ef8dc7

Browse files
committed
Rearrangement of the HTML docs build rules
Set up proper makefile dependencies in the documentation build rules, especially around the HTML/index build. The problem we've had with all previous solutions is that we have used the same file name, such as HTML.index or bookindex.sgml, to mean different things at different stages of the build, and make can't distinguish that. The solution here is that the first jade run produces HTML.index, but does not require bookindex.sgml at all, and produces no other html output (the latter an idea from Alvaro). The second jade run includes bookindex.sgml, but does not recreate HTML.index. That way, when you change an sgml file, jade is run twice and at the end all dependencies are satisfied. Omitting the html output in the first stage also makes the full build a lot faster. When you run one of the print format targets, only the first jade run is run, then the print target-specific commands. If an HTML build has completed previously, the first jade run is skipped because the dependencies have already been satisfied. The draft and check targets for quick builds and syntax verification are still there.
1 parent 4baaaf7 commit 4ef8dc7

File tree

4 files changed

+44
-35
lines changed

4 files changed

+44
-35
lines changed

doc/src/sgml/Makefile

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# PostgreSQL documentation makefile
44
#
5-
# $PostgreSQL: pgsql/doc/src/sgml/Makefile,v 1.117 2009/06/25 21:15:38 petere Exp $
5+
# $PostgreSQL: pgsql/doc/src/sgml/Makefile,v 1.118 2009/07/14 22:16:38 petere Exp $
66
#
77
#----------------------------------------------------------------------------
88

@@ -51,6 +51,9 @@ GENERATED_SGML = bookindex.sgml version.sgml \
5151

5252
ALLSGML := $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml) $(GENERATED_SGML)
5353

54+
# Sometimes we don't want this one.
55+
ALMOSTALLSGML := $(filter-out %bookindex.sgml,$(ALLSGML))
56+
5457
ifdef DOCBOOKSTYLE
5558
CATALOG = -c $(DOCBOOKSTYLE)/catalog
5659
endif
@@ -94,37 +97,27 @@ man: postgres.sgml $(ALLSGML)
9497

9598
all: html
9699

97-
# The draft target creates HTML output in draft mode
98-
draft : JADEFLAGS += -V draft-mode
99-
draft: html-output
100+
JADE.html.call = $(JADE) $(JADEFLAGS) $(SPFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t sgml -i output-html
101+
102+
# The draft target creates HTML output in draft mode, without index (for faster build).
103+
draft: postgres.sgml $(ALMOSTALLSGML) stylesheet.dsl
104+
$(JADE.html.call) -V draft-mode $<
100105

101-
html: html-output
102-
# Re-run this target until HTML.index does not change
103-
@cmp -s HTML.index.start HTML.index || $(MAKE) $@
106+
html: html-stamp
104107

105-
# This is run for all output formats because we need bookindex.sgml
106-
html-output: postgres.sgml $(ALLSGML) stylesheet.dsl
108+
html-stamp: postgres.sgml $(ALLSGML) stylesheet.dsl
107109
@rm -f *.html
108-
$(JADE) $(JADEFLAGS) $(SPFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -i output-html -t sgml $<
110+
$(JADE.html.call) -i include-index $<
109111
ifeq ($(vpath_build), yes)
110112
@cp $(srcdir)/stylesheet.css .
111113
endif
114+
touch $@
112115

113-
COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g
116+
HTML.index: postgres.sgml $(ALMOSTALLSGML) stylesheet.dsl
117+
$(JADE.html.call) -V html-index $<
114118

115-
# bookindex.sgml is required so there is a proper index for all output formats
116119
bookindex.sgml: HTML.index
117-
# create a dummy bookindex.html
118-
test -s HTML.index || $(COLLATEINDEX) -o $@ -N
119-
# If HTML.index is valid, create a valid bookindex.sgml.
120-
test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
121-
# save copy of HTML.index for later comparison
122-
@cp HTML.index HTML.index.start
123-
124-
# HTML.index is used to create bookindex.sgml
125-
HTML.index:
126-
# create an empty HTML.index if it does not exist
127-
@$(if $(wildcard HTML.index), , touch HTML.index)
120+
LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g -i 'bookindex' -o $@ $<
128121

129122
version.sgml: $(top_builddir)/src/Makefile.global
130123
{ \
@@ -146,13 +139,13 @@ features-unsupported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_package
146139

147140
# RTF to allow minor editing for hardcopy
148141
%.rtf: %.sgml $(ALLSGML) html
149-
$(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t rtf -V rtf-backend -i output-print postgres.sgml
142+
$(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t rtf -V rtf-backend -i output-print -i include-index postgres.sgml
150143

151144
# TeX
152145
# Regular TeX and pdfTeX have slightly differing requirements, so we
153146
# need to distinguish the path we're taking.
154147

155-
JADE.tex.call = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d $(srcdir)/stylesheet.dsl -t tex -V tex-backend -i output-print
148+
JADE.tex.call = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d $(srcdir)/stylesheet.dsl -t tex -V tex-backend -i output-print -i include-index
156149

157150
%-A4.tex-ps: %.sgml $(ALLSGML) html
158151
$(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
@@ -195,7 +188,7 @@ postgres.pdf:
195188
# for debugging DSSSL code, and possibly to interface to some other
196189
# tools that can make use of this.
197190
%.fot: %.sgml $(ALLSGML) html
198-
$(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t fot -i output-print -o $@ $<
191+
$(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t fot -i output-print -i include-index -o $@ $<
199192

200193

201194
##
@@ -292,7 +285,7 @@ manx: postgres.xml stylesheet-man.xsl
292285
##
293286

294287
# Quick syntax check without style processing
295-
check: postgres.sgml $(ALLSGML)
288+
check: postgres.sgml $(ALMOSTALLSGML)
296289
$(NSGMLS) $(SPFLAGS) $(SGMLINCLUDE) -s $<
297290

298291

@@ -302,7 +295,7 @@ check: postgres.sgml $(ALLSGML)
302295

303296
clean distclean maintainer-clean:
304297
# HTML
305-
rm -f HTML.manifest *.html
298+
rm -f *.html html-stamp
306299
# man
307300
rm -rf *.1 *.7 *.$(DEFAULTSECTION) man1 man7 manpage.refs manpage.links manpage.log
308301
# print

doc/src/sgml/filelist.sgml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/filelist.sgml,v 1.61 2009/05/02 20:17:19 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/filelist.sgml,v 1.62 2009/07/14 22:16:38 petere Exp $ -->
22

33
<!entity history SYSTEM "history.sgml">
44
<!entity info SYSTEM "info.sgml">
@@ -165,3 +165,9 @@
165165
-->
166166
<!entity % standalone-ignore "INCLUDE">
167167
<!entity % standalone-include "IGNORE">
168+
169+
<!--
170+
By default, no index is included. Use -i include-index on the command line
171+
to include it.
172+
-->
173+
<!entity % include-index "IGNORE">

doc/src/sgml/postgres.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/postgres.sgml,v 1.88 2009/06/17 21:58:49 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/postgres.sgml,v 1.89 2009/07/14 22:16:38 petere Exp $ -->
22

33
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [
44

@@ -262,6 +262,6 @@
262262
</part>
263263

264264
&biblio;
265-
&bookindex;
265+
<![%include-index;[&bookindex;]]>
266266

267267
</book>

doc/src/sgml/stylesheet.dsl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/stylesheet.dsl,v 1.33 2007/12/28 11:14:19 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/stylesheet.dsl,v 1.34 2009/07/14 22:16:38 petere Exp $ -->
22
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
33

44
<!-- must turn on one of these with -i on the jade command line -->
@@ -180,6 +180,19 @@
180180
(define %body-attr% '())
181181
(define ($generate-book-lot-list$) '())
182182

183+
184+
;; Only build HTML.index or the actual HTML output, not both. Saves a
185+
;; *lot* of time. (overrides docbook.dsl)
186+
(root
187+
(if (not html-index)
188+
(make sequence
189+
(process-children)
190+
(with-mode manifest
191+
(process-children)))
192+
(with-mode htmlindex
193+
(process-children))))
194+
195+
183196
;; Do not combine first section into chapter chunk.
184197
(define (chunk-skip-first-element-list) '())
185198

@@ -202,9 +215,6 @@
202215
(list (list "META" '("HTTP-EQUIV" "Content-Type") '("CONTENT" "text/html; charset=ISO-8859-1"))
203216
(list "META" '("NAME" "creation") (list "CONTENT" (time->string (time) #t)))))
204217

205-
;; Create an index
206-
(define html-index #t)
207-
208218

209219
;; Block elements are allowed in PARA in DocBook, but not in P in
210220
;; HTML. With %fix-para-wrappers% turned on, the stylesheets attempt

0 commit comments

Comments
 (0)