]> granicus.if.org Git - postgresql/blob - doc/src/sgml/Makefile
Use Pandoc also for plain-text documentation output
[postgresql] / doc / src / sgml / Makefile
1 #----------------------------------------------------------------------------
2 #
3 # PostgreSQL documentation makefile
4 #
5 # doc/src/sgml/Makefile
6 #
7 #----------------------------------------------------------------------------
8
9 # This makefile is for building and installing the documentation.
10 # When a release tarball is created, the documentation files are
11 # prepared using the distprep target.  In Git-based trees these files
12 # don't exist, unless explicitly built, so we skip the installation in
13 # that case.
14
15
16 # Make "html" the default target, since that is what most people tend
17 # to want to use.
18 html:
19
20 # We don't need the tree-wide headers or install support here.
21 NO_GENERATED_HEADERS=yes
22 NO_TEMP_INSTALL=yes
23
24 subdir = doc/src/sgml
25 top_builddir = ../../..
26 include $(top_builddir)/src/Makefile.global
27
28
29 all: html man
30
31 distprep: html distprep-man
32
33
34 ifndef DBTOEPUB
35 DBTOEPUB = $(missing) dbtoepub
36 endif
37
38 ifndef FOP
39 FOP = $(missing) fop
40 endif
41
42 XMLINCLUDE = --path .
43
44 ifndef XMLLINT
45 XMLLINT = $(missing) xmllint
46 endif
47
48 ifndef XSLTPROC
49 XSLTPROC = $(missing) xsltproc
50 endif
51
52 override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
53
54
55 GENERATED_SGML = version.sgml \
56         features-supported.sgml features-unsupported.sgml errcodes-table.sgml
57
58 ALLSGML := $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml) $(GENERATED_SGML)
59
60
61 ##
62 ## Man pages
63 ##
64
65 man distprep-man: man-stamp
66
67 man-stamp: stylesheet-man.xsl postgres.sgml $(ALLSGML)
68         $(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
69         $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_MAN_FLAGS) $(wordlist 1,2,$^)
70         touch $@
71
72
73 ##
74 ## common files
75 ##
76
77 # Technically, this should depend on Makefile.global, but then
78 # version.sgml would need to be rebuilt after every configure run,
79 # even in distribution tarballs.  So this is cheating a bit, but it
80 # will achieve the goal of updating the version number when it
81 # changes.
82 version.sgml: $(top_srcdir)/configure
83         { \
84           echo "<!ENTITY version \"$(VERSION)\">"; \
85           echo "<!ENTITY majorversion \"$(MAJORVERSION)\">"; \
86         } > $@
87
88 features-supported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.txt $(top_srcdir)/src/backend/catalog/sql_features.txt
89         $(PERL) $(srcdir)/mk_feature_tables.pl YES $^ > $@
90
91 features-unsupported.sgml: $(top_srcdir)/src/backend/catalog/sql_feature_packages.txt $(top_srcdir)/src/backend/catalog/sql_features.txt
92         $(PERL) $(srcdir)/mk_feature_tables.pl NO $^ > $@
93
94 errcodes-table.sgml: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes-table.pl
95         $(PERL) $(srcdir)/generate-errcodes-table.pl $< > $@
96
97
98 ##
99 ## Generation of some text files.
100 ##
101
102 ICONV = iconv
103 PANDOC = pandoc
104
105 INSTALL: % : %.html
106         $(PANDOC) -t plain -o $@.tmp $<
107         $(ICONV) -f utf8 -t us-ascii//TRANSLIT $@.tmp > $@
108         rm $@.tmp
109
110 INSTALL.html: %.html : stylesheet-text.xsl %.xml
111         $(XMLLINT) --noout --valid $*.xml
112         $(XSLTPROC) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_FLAGS) $^ >$@
113
114 INSTALL.xml: standalone-profile.xsl standalone-install.xml postgres.sgml $(ALLSGML)
115         $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) --xinclude $(wordlist 1,2,$^) >$@
116
117
118 ##
119 ## HTML
120 ##
121
122 ifeq ($(STYLE),website)
123 XSLTPROC_HTML_FLAGS += --param website.stylesheet 1
124 endif
125
126 html: html-stamp
127
128 html-stamp: stylesheet.xsl postgres.sgml $(ALLSGML)
129         $(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
130         $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_FLAGS) $(wordlist 1,2,$^)
131         cp $(srcdir)/stylesheet.css html/
132         touch $@
133
134 htmlhelp: stylesheet-hh.xsl postgres.sgml $(ALLSGML)
135         $(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
136         $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(wordlist 1,2,$^)
137
138 # single-page HTML
139 postgres.html: stylesheet-html-nochunk.xsl postgres.sgml $(ALLSGML)
140         $(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
141         $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_FLAGS) -o $@ $(wordlist 1,2,$^)
142
143 # single-page text
144 postgres.txt: postgres.html
145         $(PANDOC) -t plain -o $@ $<
146
147
148 ##
149 ## Print
150 ##
151
152 postgres.pdf:
153         $(error Invalid target;  use postgres-A4.pdf or postgres-US.pdf as targets)
154
155 %-A4.fo: stylesheet-fo.xsl %.sgml $(ALLSGML)
156         $(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
157         $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) --stringparam paper.type A4 -o $@ $(wordlist 1,2,$^)
158
159 %-US.fo: stylesheet-fo.xsl %.sgml $(ALLSGML)
160         $(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
161         $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) --stringparam paper.type USletter -o $@ $(wordlist 1,2,$^)
162
163 %.pdf: %.fo
164         $(FOP) -fo $< -pdf $@
165
166
167 ##
168 ## EPUB
169 ##
170
171 epub: postgres.epub
172 postgres.epub: postgres.sgml $(ALLSGML)
173         $(XMLLINT) --noout --valid $<
174         $(DBTOEPUB) -o $@ $<
175
176
177 ##
178 ## Experimental Texinfo targets
179 ##
180
181 DB2X_TEXIXML = db2x_texixml
182 DB2X_XSLTPROC = db2x_xsltproc
183 MAKEINFO = makeinfo
184
185 %.texixml: %.sgml $(ALLSGML)
186         $(XMLLINT) --noout --valid $<
187         $(DB2X_XSLTPROC) -s texi -g output-file=$(basename $@) $< -o $@
188
189 %.texi: %.texixml
190         $(DB2X_TEXIXML) --encoding=iso-8859-1//TRANSLIT $< --to-stdout > $@
191
192 %.info: %.texi
193         $(MAKEINFO) --enable-encoding --no-split --no-validate $< -o $@
194
195
196 ##
197 ## Check
198 ##
199
200 # Quick syntax check without style processing
201 check: postgres.sgml $(ALLSGML) check-tabs
202         $(XMLLINT) $(XMLINCLUDE) --noout --valid $<
203
204
205 ##
206 ## Install
207 ##
208
209 install: install-html install-man
210
211 installdirs:
212         $(MKDIR_P) '$(DESTDIR)$(htmldir)'/html $(addprefix '$(DESTDIR)$(mandir)'/man, 1 3 $(sqlmansectnum))
213
214 # If the install used a man directory shared with other applications, this will remove all files.
215 uninstall:
216         rm -f '$(DESTDIR)$(htmldir)/html/'* $(addprefix  '$(DESTDIR)$(mandir)'/man, 1/* 3/* $(sqlmansectnum)/*)
217
218
219 ## Install html
220
221 install-html: html installdirs
222         cp -R $(call vpathsearch,html) '$(DESTDIR)$(htmldir)'
223
224
225 ## Install man
226
227 install-man: man installdirs
228
229 sqlmansect ?= 7
230 sqlmansectnum = $(shell expr X'$(sqlmansect)' : X'\([0-9]\)')
231
232 # Before we install the man pages, we massage the section numbers to
233 # follow the local conventions.
234 #
235 ifeq ($(sqlmansectnum),7)
236 install-man:
237         cp -R $(foreach dir,man1 man3 man7,$(call vpathsearch,$(dir))) '$(DESTDIR)$(mandir)'
238
239 else # sqlmansectnum != 7
240 fix_sqlmansectnum = sed -e '/^\.TH/s/"7"/"$(sqlmansect)"/' \
241                         -e 's/\\fR(7)/\\fR($(sqlmansectnum))/g' \
242                         -e '1s/^\.so man7/.so man$(sqlmansectnum)/g;1s/^\(\.so.*\)\.7$$/\1.$(sqlmansect)/g'
243
244 man: fixed-man-stamp
245
246 fixed-man-stamp: man-stamp
247         @$(MKDIR_P) $(addprefix fixedman/,man1 man3 man$(sqlmansectnum))
248         for file in $(call vpathsearch,man1)/*.1; do $(fix_sqlmansectnum) $$file >fixedman/man1/`basename $$file` || exit; done
249         for file in $(call vpathsearch,man3)/*.3; do $(fix_sqlmansectnum) $$file >fixedman/man3/`basename $$file` || exit; done
250         for file in $(call vpathsearch,man7)/*.7; do $(fix_sqlmansectnum) $$file >fixedman/man$(sqlmansectnum)/`basename $$file | sed s/\.7$$/.$(sqlmansect)/` || exit; done
251
252 install-man:
253         cp -R $(foreach dir,man1 man3 man$(sqlmansectnum),fixedman/$(dir)) '$(DESTDIR)$(mandir)'
254
255 clean: clean-man
256 .PHONY: clean-man
257 clean-man:
258         rm -rf fixedman/ fixed-man-stamp
259
260 endif # sqlmansectnum != 7
261
262 # tabs are harmless, but it is best to avoid them in SGML files
263 check-tabs:
264         @( ! grep '     ' $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml $(srcdir)/*.xsl) ) || (echo "Tabs appear in SGML/XML files" 1>&2;  exit 1)
265
266 ##
267 ## Clean
268 ##
269
270 # This allows removing some files from the distribution tarballs while
271 # keeping the dependencies satisfied.
272 .SECONDARY: $(GENERATED_SGML)
273 .SECONDARY: INSTALL.html INSTALL.xml
274 .SECONDARY: postgres-A4.fo postgres-US.fo
275
276 clean:
277 # text --- these are shipped, but not in this directory
278         rm -f INSTALL
279         rm -f INSTALL.html INSTALL.xml
280 # single-page output
281         rm -f postgres.html postgres.txt
282 # print
283         rm -f *.fo *.pdf
284 # generated SGML files
285         rm -f $(GENERATED_SGML)
286 # HTML Help
287         rm -f htmlhelp.hhp toc.hhc index.hhk
288 # EPUB
289         rm -f postgres.epub
290 # Texinfo
291         rm -f *.texixml *.texi *.info db2texi.refs
292
293 distclean: clean
294
295 maintainer-clean: distclean
296 # HTML
297         rm -fr html/ html-stamp
298 # man
299         rm -rf man1/ man3/ man7/ man-stamp