1 #----------------------------------------------------------------------------
3 # PostgreSQL documentation makefile
5 # doc/src/sgml/Makefile
7 #----------------------------------------------------------------------------
9 # This makefile is for building and installing the documentation.
10 # In Git-based trees these files
11 # don't exist, unless explicitly built, so we skip the installation in
15 # Make "html" the default target, since that is what most people tend
18 # Note that all is *not* the default target in this directory
21 # We don't need the tree-wide headers or install support here.
22 NO_GENERATED_HEADERS
=yes
26 top_builddir
= ..
/..
/..
27 include $(top_builddir
)/src
/Makefile.global
32 DBTOEPUB
= $(missing
) dbtoepub
41 XMLINCLUDE
= --path .
--path
$(srcdir)
44 XMLLINT
:= $(XMLLINT
) --nonet
46 XMLLINT
= $(missing
) xmllint
50 XSLTPROC
:= $(XSLTPROC
) --nonet
52 XSLTPROC
= $(missing
) xsltproc
55 override XSLTPROCFLAGS
+= --stringparam pg.version
'$(VERSION)'
58 GENERATED_SGML
= version.sgml \
59 features-supported.sgml features-unsupported.sgml errcodes-table.sgml \
60 keywords-table.sgml targets-meson.sgml wait_event_types.sgml
62 ALL_SGML
:= $(wildcard $(srcdir)/*.sgml
$(srcdir)/ref
/*.sgml
) $(GENERATED_SGML
)
64 ALL_IMAGES
:= $(wildcard $(srcdir)/images
/*.svg
)
67 # Run validation only once, common to all subsequent targets. While
68 # we're at it, also resolve all entities (that is, copy all included
69 # files into one big file). This helps tools that don't understand
70 # vpath builds (such as dbtoepub).
71 postgres-full.xml
: postgres.sgml
$(ALL_SGML
)
72 $(XMLLINT
) $(XMLINCLUDE
) --output
$@
--noent
--valid
$<
81 man-stamp
: stylesheet-man.xsl postgres-full.xml
82 $(XSLTPROC
) $(XMLINCLUDE
) $(XSLTPROCFLAGS
) $(XSLTPROC_MAN_FLAGS
) $^
90 # Technically, this should depend on Makefile.global, but then
91 # version.sgml would need to be rebuilt after every configure run. So
92 # this is cheating a bit, but it will achieve the goal of updating the
93 # version number when it changes.
94 version.sgml
: $(top_srcdir
)/configure
96 echo
"<!ENTITY version \"$(VERSION)\">"; \
97 echo
"<!ENTITY majorversion \"$(MAJORVERSION)\">"; \
100 features-supported.sgml
: $(top_srcdir
)/src
/backend
/catalog
/sql_feature_packages.txt
$(top_srcdir
)/src
/backend
/catalog
/sql_features.txt
101 $(PERL
) $(srcdir)/mk_feature_tables.pl YES
$^
> $@
103 features-unsupported.sgml
: $(top_srcdir
)/src
/backend
/catalog
/sql_feature_packages.txt
$(top_srcdir
)/src
/backend
/catalog
/sql_features.txt
104 $(PERL
) $(srcdir)/mk_feature_tables.pl NO
$^
> $@
106 errcodes-table.sgml
: $(top_srcdir
)/src
/backend
/utils
/errcodes.txt generate-errcodes-table.pl
107 $(PERL
) $(srcdir)/generate-errcodes-table.pl
$< > $@
109 keywords-table.sgml
: $(top_srcdir
)/src
/include/parser
/kwlist.h
$(wildcard $(srcdir)/keywords
/sql
*.txt
) generate-keywords-table.pl
110 $(PERL
) $(srcdir)/generate-keywords-table.pl
$(srcdir) > $@
112 wait_event_types.sgml
: $(top_srcdir
)/src
/backend
/utils
/activity
/wait_event_names.txt
$(top_srcdir
)/src
/backend
/utils
/activity
/generate-wait_event_types.pl
113 $(PERL
) $(top_srcdir
)/src
/backend
/utils
/activity
/generate-wait_event_types.pl
--docs
$<
115 targets-meson.sgml
: targets-meson.txt
$(srcdir)/generate-targets-meson.pl
116 $(PERL
) $(srcdir)/generate-targets-meson.pl
$^
> $@
123 ifeq ($(STYLE
),website
)
124 XSLTPROC_HTML_FLAGS
+= --param website.stylesheet
1
129 html-stamp
: stylesheet.xsl postgres-full.xml
$(ALL_IMAGES
)
130 $(XSLTPROC
) $(XMLINCLUDE
) $(XSLTPROCFLAGS
) $(XSLTPROC_HTML_FLAGS
) $(wordlist
1,2,$^
)
134 postgres.html
: stylesheet-html-nochunk.xsl postgres-full.xml
$(ALL_IMAGES
)
135 $(XSLTPROC
) $(XMLINCLUDE
) $(XSLTPROCFLAGS
) $(XSLTPROC_HTML_FLAGS
) -o
$@
$(wordlist
1,2,$^
)
138 postgres.txt
: postgres.html
139 $(PANDOC
) -t plain
-o
$@
$<
147 $(error Invalid target
; use postgres-A4.pdf or postgres-US.pdf
as targets
)
149 XSLTPROC_FO_FLAGS
+= --stringparam img.src.path
'$(srcdir)/'
151 # XSL Formatting Objects (FO), https://en.wikipedia.org/wiki/XSL_Formatting_Objects
152 %-A4.fo
: stylesheet-fo.xsl
%-full.xml
153 $(XSLTPROC
) $(XMLINCLUDE
) $(XSLTPROCFLAGS
) $(XSLTPROC_FO_FLAGS
) --stringparam paper.type A4
-o
$@
$^
155 %-US.fo
: stylesheet-fo.xsl
%-full.xml
156 $(XSLTPROC
) $(XMLINCLUDE
) $(XSLTPROCFLAGS
) $(XSLTPROC_FO_FLAGS
) --stringparam paper.type USletter
-o
$@
$^
158 # There is no easy way to pipe output and capture its return code,
159 # so add a final line to report the return code.
160 %.pdf
: %.fo
$(ALL_IMAGES
)
161 { LANG
=C
$(FOP
) -fo
$< -pdf
$@
2>&1; echo
"FOP_RETURN $$?"; } | \
162 $(AWK
) 'BEGIN { warn = 0 } $$1 != "FOP_RETURN" { print } /not available in font/ { warn = 1 } \
163 END { if (warn != 0) print("\nFound characters that cannot be output in the PDF document; see README.non-ASCII"); \
164 if ($$2 != 0) { exit $$2} }' 1>&2
172 postgres.epub
: postgres-full.xml
$(ALL_IMAGES
)
173 ifeq ($(vpath_build
),yes
)
175 cp
$(ALL_IMAGES
) images
/
181 ## Experimental Texinfo targets
184 DB2X_TEXIXML
= db2x_texixml
185 DB2X_XSLTPROC
= db2x_xsltproc
188 %.texixml
: %-full.xml
189 $(DB2X_XSLTPROC
) -s texi
-g output-file
=$(basename $@
) $< -o
$@
192 $(DB2X_TEXIXML
) --encoding
=utf-8
$< --to-stdout
> $@
195 $(MAKEINFO
) --enable-encoding
--no-split
--no-validate
$< -o
$@
202 # Quick syntax check without style processing
203 check: postgres.sgml
$(ALL_SGML
) check-tabs check-nbsp
204 $(XMLLINT
) $(XMLINCLUDE
) --noout
--valid
$<
211 install: install-html install-man
214 $(MKDIR_P
) '$(DESTDIR)$(htmldir)'/html
$(addprefix '$(DESTDIR)$(mandir)'/man
, 1 3 $(sqlmansectnum
))
216 # If the install used a man directory shared with other applications, this will remove all files.
218 rm -f
'$(DESTDIR)$(htmldir)/html/'* $(addprefix '$(DESTDIR)$(mandir)'/man
, 1/* 3/* $(sqlmansectnum
)/*)
223 install-html
: html
installdirs
224 cp
-R html
'$(DESTDIR)$(htmldir)'
229 install-man
: man
installdirs
232 sqlmansectnum
= $(shell expr X
'$(sqlmansect)' : X
'\([0-9]\)')
234 # Before we install the man pages, we massage the section numbers to
235 # follow the local conventions.
237 ifeq ($(sqlmansectnum
),7)
239 cp
-R man1 man3 man7
'$(DESTDIR)$(mandir)'
241 else # sqlmansectnum != 7
242 fix_sqlmansectnum
= sed
-e
'/^\.TH/s/"7"/"$(sqlmansect)"/' \
243 -e
's/\\fR(7)/\\fR($(sqlmansectnum))/g' \
244 -e
'1s/^\.so man7/.so man$(sqlmansectnum)/g;1s/^\(\.so.*\)\.7$$/\1.$(sqlmansect)/g'
248 fixed-man-stamp
: man-stamp
249 @
$(MKDIR_P
) $(addprefix fixedman
/,man1 man3 man
$(sqlmansectnum
))
250 for file in man1
/*.1; do
$(fix_sqlmansectnum
) $$file >fixedman
/man1
/`basename $$file` || exit
; done
251 for file in man3
/*.3; do
$(fix_sqlmansectnum
) $$file >fixedman
/man3
/`basename $$file` || exit
; done
252 for file in man7
/*.7; do
$(fix_sqlmansectnum
) $$file >fixedman
/man
$(sqlmansectnum
)/`basename $$file | sed s/\.7$$/.$(sqlmansect)/` || exit
; done
255 cp
-R
$(foreach dir,man1 man3 man
$(sqlmansectnum
),fixedman
/$(dir)) '$(DESTDIR)$(mandir)'
260 rm -rf fixedman
/ fixed-man-stamp
262 endif # sqlmansectnum != 7
264 # tabs are harmless, but it is best to avoid them in SGML files
266 @
( ! grep
' ' $(wildcard $(srcdir)/*.sgml
$(srcdir)/ref
/*.sgml
$(srcdir)/*.xsl
) ) || \
267 (echo
"Tabs appear in SGML/XML files" 1>&2; exit
1)
269 # Non-breaking spaces are harmless, but it is best to avoid them in SGML files.
270 # Use perl command because non-GNU grep or sed could not have hex escape sequence.
272 @
( $(PERL
) -ne
'/\xC2\xA0/ and print("$$ARGV:$$_"),$$n++; END {exit($$n>0)}' \
273 $(wildcard $(srcdir)/*.sgml
$(srcdir)/ref
/*.sgml
$(srcdir)/*.xsl
$(srcdir)/images
/*.xsl
) ) || \
274 (echo
"Non-breaking spaces appear in SGML/XML files" 1>&2; exit
1)
280 # This allows removing some files from the distribution tarballs while
281 # keeping the dependencies satisfied.
282 .SECONDARY
: $(GENERATED_SGML
)
283 .SECONDARY
: postgres-full.xml
284 .SECONDARY
: postgres-A4.fo postgres-US.fo
288 rm -f postgres.html postgres.txt
291 # generated SGML files
292 rm -f
$(GENERATED_SGML
)
293 rm -f postgres-full.xml
297 rm -f
*.texixml
*.texi
*.
info db2texi.refs
301 rm -fr html
/ html-stamp
303 rm -rf man1
/ man3
/ man7
/ man-stamp