Documentation: Avoid use of xmlto --stringparam
[git/git.git] / Documentation / Makefile
CommitLineData
4a5d6939
MW
1MAN1_TXT= \
2 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
3 $(wildcard git-*.txt)) \
9e1f0a85 4 gitk.txt git.txt
30eba7bf
CC
5MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
6 gitrepository-layout.txt
9e1f0a85 7MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
30eba7bf 8 gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
f948dd89 9 gitdiffcore.txt gitworkflows.txt
b790abb8 10
5cefc33b
JH
11MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
12MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
13MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
14
15DOC_HTML=$(MAN_HTML)
8db9307c 16
30eba7bf 17ARTICLES = howto-index
db9536c8 18ARTICLES += everyday
4a5d6939 19ARTICLES += git-tools
8db9307c 20# with their own formatting rules.
471a5ce5 21SP_ARTICLES = howto/revert-branch-rebase howto/using-merge-subtree user-manual
530e741c
JH
22API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
23SP_ARTICLES += $(API_DOCS)
24SP_ARTICLES += technical/api-index
8db9307c
JH
25
26DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
789d5774 27
b2bf34d6 28DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
2d76548b 29DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
b2bf34d6
DG
30DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
31
d2b8593f 32prefix?=$(HOME)
e14421b9 33bindir?=$(prefix)/bin
5d6491c7 34htmldir?=$(prefix)/share/doc/git-doc
a325a1a7 35pdfdir?=$(prefix)/share/doc/git-doc
45fd8bd3 36mandir?=$(prefix)/share/man
7b8cf0cf 37man1dir=$(mandir)/man1
4392da4d 38man5dir=$(mandir)/man5
7b8cf0cf 39man7dir=$(mandir)/man7
a682ef9f 40# DESTDIR=
87a81c83 41
1187d756 42ASCIIDOC=asciidoc
26cfcfbf 43ASCIIDOC_EXTRA =
c30e9485 44MANPAGE_XSL = manpage-normal.xsl
5121a6d9 45XMLTO_EXTRA =
d2b8593f 46INSTALL?=install
4cb08df5 47RM ?= rm -f
6538d1ef 48DOC_REF = origin/man
6fe570de 49HTML_REF = origin/html
87a81c83 50
4739809c
DK
51infodir?=$(prefix)/share/info
52MAKEINFO=makeinfo
53INSTALL_INFO=install-info
54DOCBOOK2X_TEXI=docbook2x-texi
a325a1a7 55DBLATEX=dblatex
c680dd83
JH
56ifndef PERL_PATH
57 PERL_PATH = /usr/bin/perl
58endif
4739809c 59
95676853 60-include ../config.mak.autogen
4fa96e15 61-include ../config.mak
95676853 62
8fa2b45f
CJ
63#
64# For asciidoc ...
65# -7.1.2, no extra settings are needed.
66# 8.0-, set ASCIIDOC8.
67#
68
69#
70# For docbook-xsl ...
71# -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
2346431e
CJ
72# 1.69.0, no extra settings are needed?
73# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
74# 1.71.1, no extra settings are needed?
8fa2b45f
CJ
75# 1.72.0, set DOCBOOK_XSL_172.
76# 1.73.0-, set ASCIIDOC_NO_ROFF
77#
78
79#
80# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
81# of 'the ".ft C" problem' in your generated manpages, and you
82# instead ended up with weird characters around callouts, try
83# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
84#
85
7f55cf45 86ifdef ASCIIDOC8
71c020c5 87ASCIIDOC_EXTRA += -a asciidoc7compatible -a no-inline-literal
7f55cf45
JF
88endif
89ifdef DOCBOOK_XSL_172
8fa2b45f 90ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
7a2078b4 91MANPAGE_XSL = manpage-1.72.xsl
8fa2b45f
CJ
92else
93 ifdef ASCIIDOC_NO_ROFF
94 # docbook-xsl after 1.72 needs the regular XSL, but will not
95 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
96 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
97 endif
7f55cf45 98endif
5121a6d9
CJ
99ifdef MAN_BOLD_LITERAL
100XMLTO_EXTRA += -m manpage-bold-literal.xsl
101endif
2346431e
CJ
102ifdef DOCBOOK_SUPPRESS_SP
103XMLTO_EXTRA += -m manpage-suppress-sp.xsl
104endif
7f55cf45 105
8dd35c71 106# Newer DocBook stylesheet emits warning cruft in the output when
50d9bbba
TZ
107# this is not set, and if set it shows an absolute link. Older
108# stylesheets simply ignore this parameter.
59a0a0bd 109#
50d9bbba
TZ
110# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
111# or similar.
112ifndef MAN_BASE_URL
113MAN_BASE_URL = file://$(htmldir)/
59a0a0bd 114endif
50d9bbba 115XMLTO_EXTRA += -m manpage-base-url.xsl
a479a564 116
204d363f
TR
117# If your target system uses GNU groff, it may try to render
118# apostrophes as a "pretty" apostrophe using unicode. This breaks
119# cut&paste, so you should set GNU_ROFF to force them to be ASCII
120# apostrophes. Unfortunately does not work with non-GNU roff.
121ifdef GNU_ROFF
122XMLTO_EXTRA += -m manpage-quote-apos.xsl
123endif
124
ee7ec2f9
BW
125SHELL_PATH ?= $(SHELL)
126# Shell quote;
127SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
128
b2bf34d6
DG
129#
130# Please note that there is a minor bug in asciidoc.
131# The version after 6.0.3 _will_ include the patch found here:
132# http://marc.theaimsgroup.com/?l=git&m=111558757202243&w=2
133#
134# Until that version is released you may have to apply the patch
135# yourself - yes, all 6 characters of it!
136#
137
bb230097
CJ
138QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
139QUIET_SUBDIR1 =
140
141ifneq ($(findstring $(MAKEFLAGS),w),w)
142PRINT_DIR = --no-print-directory
143else # "make -w"
144NO_SUBDIR = :
145endif
146
147ifneq ($(findstring $(MAKEFLAGS),s),s)
148ifndef V
149 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
150 QUIET_XMLTO = @echo ' ' XMLTO $@;
151 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
152 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
153 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
154 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
155 QUIET_GEN = @echo ' ' GEN $@;
156 QUIET_STDERR = 2> /dev/null
157 QUIET_SUBDIR0 = +@subdir=
158 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
159 $(MAKE) $(PRINT_DIR) -C $$subdir
160 export V
161endif
162endif
163
b2bf34d6 164all: html man
b790abb8
DG
165
166html: $(DOC_HTML)
167
4392da4d 168$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
b2bf34d6 169
4392da4d 170man: man1 man5 man7
b2bf34d6 171man1: $(DOC_MAN1)
4392da4d 172man5: $(DOC_MAN5)
b2bf34d6 173man7: $(DOC_MAN7)
b790abb8 174
5cefc33b 175info: git.info gitman.info
4739809c 176
a325a1a7
MV
177pdf: user-manual.pdf
178
b1a46b70
MH
179install: install-man
180
181install-man: man
41650765
RS
182 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
183 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
184 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
185 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
186 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
187 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
87a81c83 188
4739809c 189install-info: info
41650765 190 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
5cefc33b 191 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
4739809c
DK
192 if test -r $(DESTDIR)$(infodir)/dir; then \
193 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
5cefc33b 194 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
4739809c
DK
195 else \
196 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
197 fi
37465016 198
a325a1a7
MV
199install-pdf: pdf
200 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
201 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
202
5d6491c7 203install-html: html
ee7ec2f9 204 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
5d6491c7 205
7b8a74f3 206../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
bb230097 207 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
7b8a74f3
FL
208
209-include ../GIT-VERSION-FILE
210
93d69d86
JL
211#
212# Determine "include::" file references in asciidoc files.
213#
fb612d54 214doc.dep : $(wildcard *.txt) build-docdep.perl
bb230097
CJ
215 $(QUIET_GEN)$(RM) $@+ $@ && \
216 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
a5ae8e64 217 mv $@+ $@
93d69d86 218
a5ae8e64 219-include doc.dep
37465016 220
72fe6a59
JH
221cmds_txt = cmds-ancillaryinterrogators.txt \
222 cmds-ancillarymanipulators.txt \
223 cmds-mainporcelain.txt \
224 cmds-plumbinginterrogators.txt \
225 cmds-plumbingmanipulators.txt \
89bf2077
JH
226 cmds-synchingrepositories.txt \
227 cmds-synchelpers.txt \
228 cmds-purehelpers.txt \
229 cmds-foreignscminterface.txt
72fe6a59 230
d7907392
JH
231$(cmds_txt): cmd-list.made
232
79d30668 233cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
bb230097
CJ
234 $(QUIET_GEN)$(RM) $@ && \
235 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
d7907392 236 date >$@
b790abb8
DG
237
238clean:
4c785e50 239 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
c6a5ad21 240 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
530e741c
JH
241 $(RM) howto-index.txt howto/*.html doc.dep
242 $(RM) technical/api-*.html technical/api-index.txt
4cb08df5 243 $(RM) $(cmds_txt) *.made
50d9bbba 244 $(RM) manpage-base-url.xsl
b790abb8 245
530e741c 246$(MAN_HTML): %.html : %.txt
bb230097 247 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
7b8a74f3 248 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
bb230097 249 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
7b8a74f3 250 mv $@+ $@
b790abb8 251
50d9bbba
TZ
252manpage-base-url.xsl: manpage-base-url.xsl.in
253 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
254
255%.1 %.5 %.7 : %.xml manpage-base-url.xsl
bb230097 256 $(QUIET_XMLTO)$(RM) $@ && \
5121a6d9 257 xmlto -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
b790abb8
DG
258
259%.xml : %.txt
bb230097 260 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
7b8a74f3 261 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
bb230097 262 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
7b8a74f3 263 mv $@+ $@
3f971fc4 264
d19fbc3c 265user-manual.xml: user-manual.txt user-manual.conf
26e47f25 266 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book $<
d19fbc3c 267
530e741c
JH
268technical/api-index.txt: technical/api-index-skel.txt \
269 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
ee7ec2f9 270 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
530e741c
JH
271
272$(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
bb230097 273 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
530e741c
JH
274 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
275
1cffddd6 276XSLT = docbook.xsl
0a3985dc 277XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
1c95c565 278
d19fbc3c 279user-manual.html: user-manual.xml
bb230097 280 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
d19fbc3c 281
50b3555c 282git.info: user-manual.texi
bb230097 283 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
5cefc33b 284
50b3555c 285user-manual.texi: user-manual.xml
bb230097 286 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
c6a5ad21
CJ
287 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
288 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
289 rm $@++ && \
5cefc33b
JH
290 mv $@+ $@
291
a325a1a7 292user-manual.pdf: user-manual.xml
bb230097
CJ
293 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
294 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
a325a1a7
MV
295 mv $@+ $@
296
5cefc33b 297gitman.texi: $(MAN_XML) cat-texi.perl
bb230097 298 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
8b30ad01 299 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
c6a5ad21
CJ
300 --to-stdout $(xml) &&) true) > $@++ && \
301 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
302 rm $@++ && \
5cefc33b
JH
303 mv $@+ $@
304
305gitman.info: gitman.texi
bb230097 306 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
5cefc33b
JH
307
308$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
bb230097
CJ
309 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
310 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
5cefc33b 311 mv $@+ $@
4739809c 312
e6fc2346 313howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
bb230097 314 $(QUIET_GEN)$(RM) $@+ $@ && \
ee7ec2f9 315 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
e6fc2346
JH
316 mv $@+ $@
317
8db9307c 318$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
26e47f25 319 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
e6fc2346
JH
320
321WEBDOC_DEST = /pub/software/scm/git/docs
322
8d0991d7 323$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
bb230097 324 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
26e47f25 325 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
8d0991d7
JH
326 mv $@+ $@
327
e6fc2346 328install-webdoc : html
ee7ec2f9 329 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
6538d1ef 330
b1a46b70
MH
331quick-install: quick-install-man
332
333quick-install-man:
ee7ec2f9 334 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
7b8a74f3 335
6fe570de 336quick-install-html:
ee7ec2f9 337 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
6fe570de 338
7b8a74f3 339.PHONY: .FORCE-GIT-VERSION-FILE