Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / doc / src / sgml / Makefile
blob4e029732d7f71a7c3657c57ca80deb2d3413b49e
1 #----------------------------------------------------------------------------
3 # PostgreSQL documentation makefile
5 # $PostgreSQL$
7 #----------------------------------------------------------------------------
9 subdir = doc/src/sgml
10 top_builddir = ../../..
11 include $(top_builddir)/src/Makefile.global
13 .NOTPARALLEL:
14 .PRECIOUS: %-A4.tex-ps %-US.tex-ps %-A4.tex-pdf %-US.tex-pdf
16 ifndef COLLATEINDEX
17 COLLATEINDEX = $(DOCBOOKSTYLE)/bin/collateindex.pl
18 endif
20 ifndef JADE
21 JADE = jade
22 endif
23 SGMLINCLUDE = -D $(srcdir)
25 # If this is a vpath build, some generated SGML will be in the build
26 # tree, so we need to make sure we look there as well as in the
27 # source tree
28 ifeq ($(vpath_build), yes)
29 SGMLINCLUDE += -D .
30 endif
32 ifndef NSGMLS
33 NSGMLS = nsgmls
34 endif
36 ifndef SGMLSPL
37 SGMLSPL = sgmlspl
38 endif
40 ifndef DOCBOOK2MAN
41 DOCBOOK2MAN = docbook2man_is_missing
42 endif
44 # docbook2man generates man pages from docbook refentry source code.
45 D2MSCRIPT= $(D2MDIR)/docbook2man-spec.pl
46 D2MLINKS = $(D2MDIR)/docbook2man-spec_makelinks
49 GENERATED_SGML = bookindex.sgml version.sgml \
50 features-supported.sgml features-unsupported.sgml
52 ALLSGML := $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml) $(GENERATED_SGML)
54 ifdef DOCBOOKSTYLE
55 CATALOG = -c $(DOCBOOKSTYLE)/catalog
56 endif
58 # Enable some extra warnings
59 # -wfully-tagged needed to throw a warning on missing tags
60 # for older tool chains, 2007-08-31
61 # Note: try "make SPFLAGS=-wxml" to catch a lot of other dubious constructs,
62 # in particular < and & that haven't been made into entities. It's far too
63 # noisy to turn on by default, unfortunately.
64 override SPFLAGS += -wall -wno-unused-param -wno-empty -wfully-tagged
67 ## Man pages
70 .PHONY: html man draft clean
72 DEFAULTSECTION = l
74 fix_man_xrefs = $(PERL) -npi -e 's{\[XRef to GUC-([A-Z0-9-]*)\]}{($$l = $$1) =~ tr/A-Z-/a-z_/, $$l}ge || s{\[XRef to [A-Z0-9-]*\]}{in the documentation}g'
75 lowercase = tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
77 man: postgres.sgml $(ALLSGML)
78 $(NSGMLS) $(NSGMLS_FLAGS) $(SGMLINCLUDE) $< | $(SGMLSPL) $(D2MSCRIPT) --lowercase --section $(DEFAULTSECTION) --date "`date '+%Y-%m-%d'`"
79 # One more time, to resolve cross-references
80 $(NSGMLS) $(NSGMLS_FLAGS) $(SGMLINCLUDE) $< | $(SGMLSPL) $(D2MSCRIPT) --lowercase --section $(DEFAULTSECTION) --date "`date '+%Y-%m-%d'`"
81 $(fix_man_xrefs) *.1 *.7
82 $(mkinstalldirs) man1 man7
83 $(D2MLINKS) < manpage.links
84 mv *.1 man1/
85 mv *.7 man7/
86 rm *.$(DEFAULTSECTION)
87 # manpage.links doesn't handle lowercase, needs fixups
88 cd man7 && for file in `awk '{ print $$2 }' ../manpage.links`; do $(lowercase) <$$file >`echo $$file | $(lowercase)` && rm $$file || exit; done
92 ## HTML
95 all: html
97 # The draft target creates HTML output in draft mode
98 draft : JADEFLAGS += -V draft-mode
99 draft: html-output
101 html: html-output
102 # Re-run this target until HTML.index does not change
103 @cmp -s HTML.index.start HTML.index || $(MAKE) $@
105 # This is run for all output formats because we need bookindex.sgml
106 html-output: postgres.sgml $(ALLSGML) stylesheet.dsl
107 @rm -f *.html
108 $(JADE) $(JADEFLAGS) $(SPFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -i output-html -t sgml $<
109 ifeq ($(vpath_build), yes)
110 @cp $(srcdir)/stylesheet.css .
111 endif
113 COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g
115 # bookindex.sgml is required so there is a proper index for all output formats
116 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
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)
129 version.sgml: $(top_builddir)/src/Makefile.global
131 echo "<!entity version \"$(VERSION)\">"; \
132 echo "<!entity majorversion \"$(MAJORVERSION)\">"; \
133 } >$@
135 features-supported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.txt $(top_srcdir)/src/backend/catalog/sql_features.txt
136 $(PERL) $(srcdir)/mk_feature_tables.pl YES $^ > $@
138 features-unsupported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.txt $(top_srcdir)/src/backend/catalog/sql_features.txt
139 $(PERL) $(srcdir)/mk_feature_tables.pl NO $^ > $@
143 ## Print
147 # RTF to allow minor editing for hardcopy
148 %.rtf: %.sgml $(ALLSGML) html
149 $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t rtf -V rtf-backend -i output-print postgres.sgml
151 # TeX
152 # Regular TeX and pdfTeX have slightly differing requirements, so we
153 # need to distinguish the path we're taking.
155 JADE.tex.call = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d $(srcdir)/stylesheet.dsl -t tex -V tex-backend -i output-print
157 %-A4.tex-ps: %.sgml $(ALLSGML) html
158 $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
160 %-US.tex-ps: %.sgml $(ALLSGML) html
161 $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
163 %-A4.tex-pdf: %.sgml $(ALLSGML) html
164 $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
166 %-US.tex-pdf: %.sgml $(ALLSGML) html
167 $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
169 %.dvi: %.tex-ps
170 @rm -f $*.aux $*.log
171 # multiple runs are necessary to create proper intra-document links
172 jadetex $<
173 jadetex $<
174 jadetex $<
176 # PostScript from TeX
177 postgres.ps:
178 $(error Invalid target; use postgres-A4.ps or postgres-US.ps as targets)
180 %.ps: %.dvi
181 dvips -o $@ $<
183 postgres.pdf:
184 $(error Invalid target; use postgres-A4.pdf or postgres-US.pdf as targets)
186 %.pdf: %.tex-pdf
187 @rm -f $*.aux $*.log $*.out
188 # multiple runs are necessary to create proper intra-document links
189 pdfjadetex $<
190 pdfjadetex $<
191 pdfjadetex $<
194 # This generates an XML version of the flow-object tree. It's useful
195 # for debugging DSSSL code, and possibly to interface to some other
196 # tools that can make use of this.
197 %.fot: %.sgml $(ALLSGML) html
198 $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t fot -i output-print -o $@ $<
202 ## Semi-automatic generation of some text files.
205 JADE.text = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -i output-text -t sgml
206 LYNX = lynx
208 INSTALL HISTORY regress_README: % : %.html
209 $(PERL) -p -e 's/<H(1|2)$$/<H\1 align=center/g' $< | $(LYNX) -force_html -dump -nolist -stdin >$@
211 INSTALL.html: standalone-install.sgml installation.sgml version.sgml
212 $(JADE.text) -V nochunks standalone-install.sgml installation.sgml >$@
214 HISTORY.html: generate_history.pl $(wildcard $(srcdir)/release*.sgml)
215 $(PERL) $< "$(srcdir)" release.sgml >tempfile_HISTORY.sgml
216 $(JADE.text) -V nochunks tempfile_HISTORY.sgml >$@
217 rm tempfile_HISTORY.sgml
219 regress_README.html: regress.sgml
220 ( echo '<!doctype chapter PUBLIC "-//OASIS//DTD DocBook V4.2//EN" ['; \
221 echo '<!entity % standalone-ignore "IGNORE">'; \
222 echo '<!entity % standalone-include "INCLUDE"> ]>'; \
223 cat $< ) >tempfile_regress_README.sgml
224 $(JADE.text) -V nochunks tempfile_regress_README.sgml >$@
225 rm tempfile_regress_README.sgml
229 ## XSLT processing
232 OSX = osx # (may be called sx or sgml2xml on some systems)
233 XSLTPROC = xsltproc
235 postgres.xml: postgres.sgml $(GENERATED_SGML)
236 $(OSX) -D. -x lower $< | \
237 $(PERL) -p -e 's/\[(amp|copy|egrave|gt|lt|mdash|nbsp|ouml|pi|quot|uuml) *\]/\&\1;/g;' \
238 -e '$$_ .= qq{<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">\n} if $$. == 1;' \
240 # ' hello Emacs
242 override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
244 xslthtml: stylesheet.xsl postgres.xml
245 $(XSLTPROC) $(XSLTPROCFLAGS) $^
247 htmlhelp: stylesheet-hh.xsl postgres.xml
248 $(XSLTPROC) $(XSLTPROCFLAGS) $^
250 %-A4.fo: stylesheet-fo.xsl %.xml
251 $(XSLTPROC) $(XSLTPROCFLAGS) --stringparam paper.type A4 -o $@ $^
253 %-US.fo: stylesheet-fo.xsl %.xml
254 $(XSLTPROC) $(XSLTPROCFLAGS) --stringparam paper.type USletter -o $@ $^
258 ## Experimental Texinfo targets
261 DB2X_TEXIXML = db2x_texixml
262 DB2X_XSLTPROC = db2x_xsltproc
263 MAKEINFO = makeinfo
265 %.texixml: %.xml
266 $(DB2X_XSLTPROC) -s texi -g output-file=$(basename $@) $< -o $@
268 %.texi: %.texixml
269 $(DB2X_TEXIXML) --encoding=iso-8859-1//TRANSLIT $< --to-stdout >$@
271 %.info: %.texi
272 $(MAKEINFO) --enable-encoding --no-split --no-validate $< -o $@
274 # Cancel built-in suffix rules, interfering with PS building
275 .SUFFIXES:
279 ## Experimental man page building through docbook2x
282 manx: postgres.xml stylesheet-man.xsl
283 $(DOCBOOK2MAN) --solinks -s $(srcdir)/stylesheet-man.xsl --string-param default-manpage-section=$(DEFAULTSECTION) $<
284 $(mkinstalldirs) man1 man7
285 mv *.1 man1/
286 mv *.7 man7/
287 rm *.$(DEFAULTSECTION)
291 ## Check
294 # Quick syntax check without style processing
295 check: postgres.sgml $(ALLSGML)
296 $(NSGMLS) $(SPFLAGS) $(SGMLINCLUDE) -s $<
300 ## Clean
303 clean distclean maintainer-clean:
304 # HTML
305 rm -f HTML.manifest *.html
306 # man
307 rm -rf *.1 *.7 *.$(DEFAULTSECTION) man1 man7 manpage.refs manpage.links manpage.log
308 # print
309 rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.fot
310 # index
311 rm -f HTML.index HTML.index.start $(GENERATED_SGML)
312 # text
313 rm -f INSTALL HISTORY regress_README
314 # XSLT
315 rm -f postgres.xml htmlhelp.hhp toc.hhc index.hhk *.fo
316 # Texinfo
317 rm -f *.texixml *.texi *.info db2texi.refs
318 ifeq ($(vpath_build), yes)
319 rm -f stylesheet.css
320 endif