]> granicus.if.org Git - postgresql/blob - doc/src/sgml/Makefile
Experimental new support for building man pages via docbook2x, an XSL-based
[postgresql] / doc / src / sgml / Makefile
1 #----------------------------------------------------------------------------
2 #
3 # PostgreSQL documentation makefile
4 #
5 # $PostgreSQL: pgsql/doc/src/sgml/Makefile,v 1.110 2008/11/04 14:58:22 petere Exp $
6 #
7 #----------------------------------------------------------------------------
8
9 subdir = doc/src/sgml
10 top_builddir = ../../..
11 include $(top_builddir)/src/Makefile.global
12
13 .NOTPARALLEL:
14 .PRECIOUS: %-A4.tex-ps %-US.tex-ps %-A4.tex-pdf %-US.tex-pdf
15
16 ifndef COLLATEINDEX
17 COLLATEINDEX = $(DOCBOOKSTYLE)/bin/collateindex.pl
18 endif
19
20 ifndef JADE
21 JADE = jade
22 endif
23 SGMLINCLUDE = -D $(srcdir)
24
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
31
32 ifndef NSGMLS
33 NSGMLS = nsgmls
34 endif
35
36 ifndef SGMLSPL
37 SGMLSPL = sgmlspl
38 endif
39
40 # docbook2man generates man pages from docbook refentry source code.
41 D2MSCRIPT= $(D2MDIR)/docbook2man-spec.pl
42
43
44 GENERATED_SGML = bookindex.sgml version.sgml \
45         features-supported.sgml features-unsupported.sgml
46
47 ALLSGML := $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml) $(GENERATED_SGML)
48
49 ifdef DOCBOOKSTYLE
50 CATALOG = -c $(DOCBOOKSTYLE)/catalog
51 endif
52
53 # Enable some extra warnings
54 # -wfully-tagged needed to throw a warning on missing tags 
55 # for older tool chains, 2007-08-31
56 # Note: try "make SPFLAGS=-wxml" to catch a lot of other dubious constructs,
57 # in particular < and & that haven't been made into entities.  It's far too
58 # noisy to turn on by default, unfortunately.
59 override SPFLAGS += -wall -wno-unused-param -wno-empty -wfully-tagged
60
61 ##
62 ## Man pages
63 ##
64
65 .PHONY: html man draft clean
66
67 DEFAULTSECTION = $(sqlmansect_dummy)
68
69 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'
70
71 man: postgres.sgml $(ALLSGML)
72         $(NSGMLS) $(NSGMLS_FLAGS) $(SGMLINCLUDE) $< | $(SGMLSPL) $(D2MSCRIPT) --lowercase --section $(DEFAULTSECTION) --date "`date '+%Y-%m-%d'`"
73 # One more time, to resolve cross-references
74         $(NSGMLS) $(NSGMLS_FLAGS) $(SGMLINCLUDE) $< | $(SGMLSPL) $(D2MSCRIPT) --lowercase --section $(DEFAULTSECTION) --date "`date '+%Y-%m-%d'`"
75         $(fix_man_xrefs) *.1 *.$(DEFAULTSECTION)
76         $(mkinstalldirs) man1 man$(DEFAULTSECTION)
77         mv *.1 man1/
78         mv *.$(DEFAULTSECTION) man$(DEFAULTSECTION)/
79
80
81 ##
82 ## HTML
83 ##
84
85 all: html
86
87 # The draft target creates HTML output in draft mode
88 draft : JADEFLAGS += -V draft-mode
89 draft: html-output
90
91 html: html-output
92 # Re-run this target until HTML.index does not change
93         @cmp -s HTML.index.start HTML.index || $(MAKE) $@
94
95 # This is run for all output formats because we need bookindex.sgml
96 html-output: postgres.sgml $(ALLSGML) stylesheet.dsl
97         @rm -f *.html
98         $(JADE) $(JADEFLAGS) $(SPFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -i output-html -t sgml $<
99 ifeq ($(vpath_build), yes)
100         @cp $(srcdir)/stylesheet.css .
101 endif
102
103 COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g
104
105 # bookindex.sgml is required so there is a proper index for all output formats
106 bookindex.sgml: HTML.index
107 # create a dummy bookindex.html
108         test -s HTML.index || $(COLLATEINDEX) -o $@ -N
109 # If HTML.index is valid, create a valid bookindex.sgml.
110         test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
111 # save copy of HTML.index for later comparison
112         @cp HTML.index HTML.index.start
113
114 # HTML.index is used to create bookindex.sgml
115 HTML.index:
116 # create an empty HTML.index if it does not exist
117         @$(if $(wildcard HTML.index), , touch HTML.index)
118
119 version.sgml: $(top_builddir)/src/Makefile.global
120         { \
121           echo "<!entity version \"$(VERSION)\">"; \
122           echo "<!entity majorversion \"`expr $(VERSION) : '\([0-9][0-9]*\.[0-9][0-9]*\)'`\">"; \
123         } >$@
124
125 features-supported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.txt $(top_srcdir)/src/backend/catalog/sql_features.txt
126         $(PERL) $(srcdir)/mk_feature_tables.pl YES $^ > $@
127
128 features-unsupported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.txt $(top_srcdir)/src/backend/catalog/sql_features.txt
129         $(PERL) $(srcdir)/mk_feature_tables.pl NO $^ > $@
130
131
132 ##
133 ## Print
134 ##
135
136
137 # RTF to allow minor editing for hardcopy
138 %.rtf: %.sgml $(ALLSGML) html
139         $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t rtf -V rtf-backend -i output-print postgres.sgml
140
141 # TeX
142 # Regular TeX and pdfTeX have slightly differing requirements, so we
143 # need to distinguish the path we're taking.
144
145 JADE.tex.call = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d $(srcdir)/stylesheet.dsl -t tex -V tex-backend -i output-print
146
147 %-A4.tex-ps: %.sgml $(ALLSGML) html
148         $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
149
150 %-US.tex-ps: %.sgml $(ALLSGML) html
151         $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
152
153 %-A4.tex-pdf: %.sgml $(ALLSGML) html
154         $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
155
156 %-US.tex-pdf: %.sgml $(ALLSGML) html
157         $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
158
159 %.dvi: %.tex-ps
160         @rm -f $*.aux $*.log
161 # multiple runs are necessary to create proper intra-document links
162         jadetex $<
163         jadetex $<
164         jadetex $<
165
166 # PostScript from TeX
167 postgres.ps:
168         $(error Invalid target;  use postgres-A4.ps or postgres-US.ps as targets)
169         
170 %.ps: %.dvi
171         dvips -o $@ $<
172
173 postgres.pdf:
174         $(error Invalid target;  use postgres-A4.pdf or postgres-US.pdf as targets)
175         
176 %.pdf: %.tex-pdf
177         @rm -f $*.aux $*.log $*.out
178 # multiple runs are necessary to create proper intra-document links
179         pdfjadetex $<
180         pdfjadetex $<
181         pdfjadetex $<
182
183
184 # This generates an XML version of the flow-object tree.  It's useful
185 # for debugging DSSSL code, and possibly to interface to some other
186 # tools that can make use of this.
187 %.fot: %.sgml $(ALLSGML) html
188         $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -t fot -i output-print -o $@ $<
189
190
191 ##
192 ## Semi-automatic generation of some text files.
193 ##
194
195 JADE.text = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -i output-text -t sgml
196 LYNX = lynx
197
198 INSTALL HISTORY regress_README: % : %.html
199         $(PERL) -p -e 's/<H(1|2)$$/<H\1 align=center/g' $< | $(LYNX) -force_html -dump -nolist -stdin >$@
200
201 INSTALL.html: standalone-install.sgml installation.sgml version.sgml
202         $(JADE.text) -V nochunks standalone-install.sgml installation.sgml >$@
203
204 # remove links to main documentation
205 HISTORY.html: release.sgml
206         ( echo '<!doctype appendix PUBLIC "-//OASIS//DTD DocBook V4.2//EN">'; \
207           cat $< ) | \
208         $(PERL) -p -0 -e 's/<link\s+linkend[^>]*>//g' | \
209         $(PERL) -p -e 's/<\/link>//g' >tempfile_HISTORY.sgml
210         $(JADE.text) -V nochunks tempfile_HISTORY.sgml >$@
211         rm tempfile_HISTORY.sgml
212
213 regress_README.html: regress.sgml
214         ( echo '<!doctype chapter PUBLIC "-//OASIS//DTD DocBook V4.2//EN" ['; \
215           echo '<!entity % standalone-ignore "IGNORE">'; \
216           echo '<!entity % standalone-include "INCLUDE"> ]>'; \
217           cat $< ) >tempfile_regress_README.sgml
218         $(JADE.text) -V nochunks tempfile_regress_README.sgml >$@
219         rm tempfile_regress_README.sgml
220
221
222 ##
223 ## XSLT processing
224 ##
225
226 OSX = osx # (may be called sx or sgml2xml on some systems)
227 XSLTPROC = xsltproc
228
229 postgres.xml: postgres.sgml $(GENERATED_SGML)
230         $(OSX) -D. -x lower $< | \
231           $(PERL) -p -e 's/\[(amp|copy|egrave|gt|lt|mdash|nbsp|ouml|pi|quot|uuml) *\]/\&\1;/g;' \
232                      -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;' \
233           >$@
234 # ' hello Emacs
235
236 override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
237
238 xslthtml: stylesheet.xsl postgres.xml
239         $(XSLTPROC) $(XSLTPROCFLAGS) $^
240
241 htmlhelp: stylesheet-hh.xsl postgres.xml
242         $(XSLTPROC) $(XSLTPROCFLAGS) $^
243
244 %-A4.fo: stylesheet-fo.xsl %.xml
245         $(XSLTPROC) $(XSLTPROCFLAGS) --stringparam paper.type A4 -o $@ $^
246
247 %-US.fo: stylesheet-fo.xsl %.xml
248         $(XSLTPROC) $(XSLTPROCFLAGS) --stringparam paper.type USletter -o $@ $^
249
250
251 ##
252 ## Experimental Texinfo targets
253 ##
254
255 DB2X_TEXIXML = db2x_texixml
256 DB2X_XSLTPROC = db2x_xsltproc
257 MAKEINFO = makeinfo
258
259 %.texixml: %.xml
260         $(DB2X_XSLTPROC) -s texi -g output-file=$(basename $@) $< -o $@
261
262 %.texi: %.texixml
263         $(DB2X_TEXIXML) --encoding=iso-8859-1//TRANSLIT $< --to-stdout >$@
264
265 %.info: %.texi
266         $(MAKEINFO) --enable-encoding --no-split --no-validate $< -o $@
267
268 # Cancel built-in suffix rules, interfering with PS building
269 .SUFFIXES:
270
271
272 ##
273 ## Experimental man page building through docbook2x
274 ##
275
276 # called docbook2man on non-Debian
277 DOCBOOK2MAN = docbook2x-man
278
279 manx: postgres.xml stylesheet-man.xsl
280         $(DOCBOOK2MAN) -s $(srcdir)/stylesheet-man.xsl --string-param default-manpage-section=$(DEFAULTSECTION)  $<
281         $(mkinstalldirs) man1 man$(DEFAULTSECTION)
282         mv *.1 man1/
283         mv *.$(DEFAULTSECTION) man$(DEFAULTSECTION)/
284
285
286 ##
287 ## Check
288 ##
289
290 # Quick syntax check without style processing
291 check: postgres.sgml $(ALLSGML)
292         $(NSGMLS) $(SPFLAGS) $(SGMLINCLUDE) -s $<
293
294
295 ##
296 ## Clean
297 ##
298
299 clean distclean maintainer-clean:
300 # HTML
301         rm -f HTML.manifest *.html
302 # man
303         rm -rf *.1 *.$(DEFAULTSECTION) man1 man$(DEFAULTSECTION) manpage.refs manpage.links manpage.log
304 # print
305         rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.fot
306 # index
307         rm -f HTML.index HTML.index.start $(GENERATED_SGML)
308 # text
309         rm -f INSTALL HISTORY regress_README
310 # XSLT
311         rm -f postgres.xml htmlhelp.hhp toc.hhc index.hhk *.fo
312 # Texinfo
313         rm -f *.texixml *.texi *.info db2texi.refs
314 ifeq ($(vpath_build), yes)
315         rm -f stylesheet.css
316 endif