1 #----------------------------------------------------------------------------
3 # PostgreSQL documentation makefile
5 # doc/src/sgml/Makefile
7 #----------------------------------------------------------------------------
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
16 # Make "html" the default target, since that is what most people tend
20 # We don't need the tree-wide headers or install support here.
21 NO_GENERATED_HEADERS=yes
25 top_builddir = ../../..
26 include $(top_builddir)/src/Makefile.global
31 distprep: html distprep-man
35 DBTOEPUB = $(missing) dbtoepub
45 XMLLINT = $(missing) xmllint
49 XSLTPROC = $(missing) xsltproc
52 override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
55 GENERATED_SGML = version.sgml \
56 features-supported.sgml features-unsupported.sgml errcodes-table.sgml
58 ALLSGML := $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml) $(GENERATED_SGML)
65 man distprep-man: man-stamp
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,$^)
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
82 version.sgml: $(top_srcdir)/configure
84 echo "<!ENTITY version \"$(VERSION)\">"; \
85 echo "<!ENTITY majorversion \"$(MAJORVERSION)\">"; \
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 $^ > $@
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 $^ > $@
94 errcodes-table.sgml: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes-table.pl
95 $(PERL) $(srcdir)/generate-errcodes-table.pl $< > $@
99 ## Generation of some text files.
106 $(PANDOC) -t plain -o $@.tmp $<
107 $(ICONV) -f utf8 -t us-ascii//TRANSLIT $@.tmp > $@
110 INSTALL.html: %.html : stylesheet-text.xsl %.xml
111 $(XMLLINT) --noout --valid $*.xml
112 $(XSLTPROC) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_FLAGS) $^ >$@
114 INSTALL.xml: standalone-profile.xsl standalone-install.xml postgres.sgml $(ALLSGML)
115 $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) --xinclude $(wordlist 1,2,$^) >$@
122 ifeq ($(STYLE),website)
123 XSLTPROC_HTML_FLAGS += --param website.stylesheet 1
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/
134 htmlhelp: stylesheet-hh.xsl postgres.sgml $(ALLSGML)
135 $(XMLLINT) $(XMLINCLUDE) --noout --valid $(word 2,$^)
136 $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(wordlist 1,2,$^)
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,$^)
144 postgres.txt: postgres.html
145 $(PANDOC) -t plain -o $@ $<
153 $(error Invalid target; use postgres-A4.pdf or postgres-US.pdf as targets)
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,$^)
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,$^)
164 $(FOP) -fo $< -pdf $@
172 postgres.epub: postgres.sgml $(ALLSGML)
173 $(XMLLINT) --noout --valid $<
178 ## Experimental Texinfo targets
181 DB2X_TEXIXML = db2x_texixml
182 DB2X_XSLTPROC = db2x_xsltproc
185 %.texixml: %.sgml $(ALLSGML)
186 $(XMLLINT) --noout --valid $<
187 $(DB2X_XSLTPROC) -s texi -g output-file=$(basename $@) $< -o $@
190 $(DB2X_TEXIXML) --encoding=iso-8859-1//TRANSLIT $< --to-stdout > $@
193 $(MAKEINFO) --enable-encoding --no-split --no-validate $< -o $@
200 # Quick syntax check without style processing
201 check: postgres.sgml $(ALLSGML) check-tabs
202 $(XMLLINT) $(XMLINCLUDE) --noout --valid $<
209 install: install-html install-man
212 $(MKDIR_P) '$(DESTDIR)$(htmldir)'/html $(addprefix '$(DESTDIR)$(mandir)'/man, 1 3 $(sqlmansectnum))
214 # If the install used a man directory shared with other applications, this will remove all files.
216 rm -f '$(DESTDIR)$(htmldir)/html/'* $(addprefix '$(DESTDIR)$(mandir)'/man, 1/* 3/* $(sqlmansectnum)/*)
221 install-html: html installdirs
222 cp -R $(call vpathsearch,html) '$(DESTDIR)$(htmldir)'
227 install-man: man installdirs
230 sqlmansectnum = $(shell expr X'$(sqlmansect)' : X'\([0-9]\)')
232 # Before we install the man pages, we massage the section numbers to
233 # follow the local conventions.
235 ifeq ($(sqlmansectnum),7)
237 cp -R $(foreach dir,man1 man3 man7,$(call vpathsearch,$(dir))) '$(DESTDIR)$(mandir)'
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'
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
253 cp -R $(foreach dir,man1 man3 man$(sqlmansectnum),fixedman/$(dir)) '$(DESTDIR)$(mandir)'
258 rm -rf fixedman/ fixed-man-stamp
260 endif # sqlmansectnum != 7
262 # tabs are harmless, but it is best to avoid them in SGML files
264 @( ! grep ' ' $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml $(srcdir)/*.xsl) ) || (echo "Tabs appear in SGML/XML files" 1>&2; exit 1)
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
277 # text --- these are shipped, but not in this directory
279 rm -f INSTALL.html INSTALL.xml
281 rm -f postgres.html postgres.txt
284 # generated SGML files
285 rm -f $(GENERATED_SGML)
287 rm -f htmlhelp.hhp toc.hhc index.hhk
291 rm -f *.texixml *.texi *.info db2texi.refs
295 maintainer-clean: distclean
297 rm -fr html/ html-stamp
299 rm -rf man1/ man3/ man7/ man-stamp