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