Merge branch 'maint-1.8.2' into maint
[git/git.git] / Documentation / Makefile
CommitLineData
a617578d
JK
1# Guard against environment variables
2MAN1_TXT =
3MAN5_TXT =
4MAN7_TXT =
5
6MAN1_TXT += $(filter-out \
7 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
8 $(wildcard git-*.txt))
9MAN1_TXT += git.txt
10MAN1_TXT += gitk.txt
b9a5f681 11MAN1_TXT += gitremote-helpers.txt
a617578d
JK
12MAN1_TXT += gitweb.txt
13
14MAN5_TXT += gitattributes.txt
15MAN5_TXT += githooks.txt
16MAN5_TXT += gitignore.txt
17MAN5_TXT += gitmodules.txt
18MAN5_TXT += gitrepository-layout.txt
19MAN5_TXT += gitweb.conf.txt
20
21MAN7_TXT += gitcli.txt
22MAN7_TXT += gitcore-tutorial.txt
a6fc9fd3 23MAN7_TXT += gitcredentials.txt
a617578d
JK
24MAN7_TXT += gitcvs-migration.txt
25MAN7_TXT += gitdiffcore.txt
26MAN7_TXT += gitglossary.txt
27MAN7_TXT += gitnamespaces.txt
28MAN7_TXT += gitrevisions.txt
29MAN7_TXT += gittutorial-2.txt
30MAN7_TXT += gittutorial.txt
31MAN7_TXT += gitworkflows.txt
b790abb8 32
5cefc33b
JH
33MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
34MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
35MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
36
bd4a3d61
JK
37OBSOLETE_HTML = git-remote-helpers.html
38DOC_HTML=$(MAN_HTML) $(OBSOLETE_HTML)
8db9307c 39
30eba7bf 40ARTICLES = howto-index
db9536c8 41ARTICLES += everyday
4a5d6939 42ARTICLES += git-tools
69a9cd31 43ARTICLES += git-bisect-lk2009
8db9307c 44# with their own formatting rules.
11b17afc 45SP_ARTICLES = user-manual
81670e9b 46SP_ARTICLES += howto/new-command
11b17afc
JH
47SP_ARTICLES += howto/revert-branch-rebase
48SP_ARTICLES += howto/using-merge-subtree
49SP_ARTICLES += howto/using-signed-tag-in-pull-request
5e00439f
TA
50SP_ARTICLES += howto/use-git-daemon
51SP_ARTICLES += howto/update-hook-example
52SP_ARTICLES += howto/setup-git-server-over-http
53SP_ARTICLES += howto/separating-topic-branches
54SP_ARTICLES += howto/revert-a-faulty-merge
55SP_ARTICLES += howto/recover-corrupted-blob-object
56SP_ARTICLES += howto/rebuild-from-update-hook
5e00439f
TA
57SP_ARTICLES += howto/rebase-from-internal-branch
58SP_ARTICLES += howto/maintain-git
530e741c
JH
59API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
60SP_ARTICLES += $(API_DOCS)
5e00439f
TA
61
62TECH_DOCS = technical/index-format
63TECH_DOCS += technical/pack-format
64TECH_DOCS += technical/pack-heuristics
65TECH_DOCS += technical/pack-protocol
66TECH_DOCS += technical/protocol-capabilities
67TECH_DOCS += technical/protocol-common
68TECH_DOCS += technical/racy-git
69TECH_DOCS += technical/send-pack-pipeline
70TECH_DOCS += technical/shallow
71TECH_DOCS += technical/trivial-merge
72SP_ARTICLES += $(TECH_DOCS)
530e741c 73SP_ARTICLES += technical/api-index
8db9307c
JH
74
75DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
789d5774 76
b2bf34d6 77DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
2d76548b 78DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
b2bf34d6
DG
79DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
80
d2b8593f 81prefix?=$(HOME)
e14421b9 82bindir?=$(prefix)/bin
5d6491c7 83htmldir?=$(prefix)/share/doc/git-doc
a325a1a7 84pdfdir?=$(prefix)/share/doc/git-doc
45fd8bd3 85mandir?=$(prefix)/share/man
7b8cf0cf 86man1dir=$(mandir)/man1
4392da4d 87man5dir=$(mandir)/man5
7b8cf0cf 88man7dir=$(mandir)/man7
a682ef9f 89# DESTDIR=
87a81c83 90
dd4f3075 91ASCIIDOC = asciidoc
26cfcfbf 92ASCIIDOC_EXTRA =
c30e9485 93MANPAGE_XSL = manpage-normal.xsl
dd4f3075 94XMLTO = xmlto
5121a6d9 95XMLTO_EXTRA =
d2b8593f 96INSTALL?=install
4cb08df5 97RM ?= rm -f
fcbebfdd
JH
98MAN_REPO = ../../git-manpages
99HTML_REPO = ../../git-htmldocs
87a81c83 100
4739809c
DK
101infodir?=$(prefix)/share/info
102MAKEINFO=makeinfo
103INSTALL_INFO=install-info
104DOCBOOK2X_TEXI=docbook2x-texi
a325a1a7 105DBLATEX=dblatex
c680dd83
JH
106ifndef PERL_PATH
107 PERL_PATH = /usr/bin/perl
108endif
4739809c 109
95676853 110-include ../config.mak.autogen
4fa96e15 111-include ../config.mak
95676853 112
8fa2b45f
CJ
113#
114# For docbook-xsl ...
79c461d5
JK
115# -1.68.1, no extra settings are needed?
116# 1.69.0, set ASCIIDOC_ROFF?
2346431e 117# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
79c461d5 118# 1.71.1, set ASCIIDOC_ROFF?
8fa2b45f 119# 1.72.0, set DOCBOOK_XSL_172.
79c461d5 120# 1.73.0-, no extra settings are needed
8fa2b45f
CJ
121#
122
7f55cf45 123ifdef DOCBOOK_XSL_172
8fa2b45f 124ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
7a2078b4 125MANPAGE_XSL = manpage-1.72.xsl
8fa2b45f 126else
79c461d5 127 ifndef ASCIIDOC_ROFF
8fa2b45f
CJ
128 # docbook-xsl after 1.72 needs the regular XSL, but will not
129 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
130 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
131 endif
7f55cf45 132endif
5121a6d9
CJ
133ifdef MAN_BOLD_LITERAL
134XMLTO_EXTRA += -m manpage-bold-literal.xsl
135endif
2346431e
CJ
136ifdef DOCBOOK_SUPPRESS_SP
137XMLTO_EXTRA += -m manpage-suppress-sp.xsl
138endif
7f55cf45 139
8dd35c71 140# Newer DocBook stylesheet emits warning cruft in the output when
50d9bbba
TZ
141# this is not set, and if set it shows an absolute link. Older
142# stylesheets simply ignore this parameter.
59a0a0bd 143#
50d9bbba
TZ
144# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
145# or similar.
146ifndef MAN_BASE_URL
147MAN_BASE_URL = file://$(htmldir)/
59a0a0bd 148endif
50d9bbba 149XMLTO_EXTRA += -m manpage-base-url.xsl
a479a564 150
204d363f
TR
151# If your target system uses GNU groff, it may try to render
152# apostrophes as a "pretty" apostrophe using unicode. This breaks
153# cut&paste, so you should set GNU_ROFF to force them to be ASCII
154# apostrophes. Unfortunately does not work with non-GNU roff.
155ifdef GNU_ROFF
156XMLTO_EXTRA += -m manpage-quote-apos.xsl
157endif
158
ee7ec2f9
BW
159SHELL_PATH ?= $(SHELL)
160# Shell quote;
161SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
162
5b58619a
JN
163ifdef DEFAULT_PAGER
164DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
165ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
166endif
167
168ifdef DEFAULT_EDITOR
169DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
170ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
171endif
172
bb230097
CJ
173QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
174QUIET_SUBDIR1 =
175
176ifneq ($(findstring $(MAKEFLAGS),w),w)
177PRINT_DIR = --no-print-directory
178else # "make -w"
179NO_SUBDIR = :
180endif
181
182ifneq ($(findstring $(MAKEFLAGS),s),s)
183ifndef V
184 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
185 QUIET_XMLTO = @echo ' ' XMLTO $@;
186 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
187 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
188 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
189 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
190 QUIET_GEN = @echo ' ' GEN $@;
191 QUIET_STDERR = 2> /dev/null
192 QUIET_SUBDIR0 = +@subdir=
193 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
194 $(MAKE) $(PRINT_DIR) -C $$subdir
195 export V
196endif
197endif
198
b2bf34d6 199all: html man
b790abb8
DG
200
201html: $(DOC_HTML)
202
4392da4d 203man: man1 man5 man7
b2bf34d6 204man1: $(DOC_MAN1)
4392da4d 205man5: $(DOC_MAN5)
b2bf34d6 206man7: $(DOC_MAN7)
b790abb8 207
5cefc33b 208info: git.info gitman.info
4739809c 209
a325a1a7
MV
210pdf: user-manual.pdf
211
b1a46b70
MH
212install: install-man
213
214install-man: man
41650765
RS
215 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
216 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
217 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
218 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
219 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
220 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
87a81c83 221
4739809c 222install-info: info
41650765 223 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
5cefc33b 224 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
4739809c
DK
225 if test -r $(DESTDIR)$(infodir)/dir; then \
226 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
5cefc33b 227 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
4739809c
DK
228 else \
229 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
230 fi
37465016 231
a325a1a7
MV
232install-pdf: pdf
233 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
234 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
235
5d6491c7 236install-html: html
ee7ec2f9 237 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
5d6491c7 238
13fca9f3 239../GIT-VERSION-FILE: FORCE
bb230097 240 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
7b8a74f3
FL
241
242-include ../GIT-VERSION-FILE
243
93d69d86
JL
244#
245# Determine "include::" file references in asciidoc files.
246#
f35ec546
DA
247docdep_prereqs = \
248 mergetools-list.made $(mergetools_txt) \
249 cmd-list.made $(cmds_txt)
250
251doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
bb230097
CJ
252 $(QUIET_GEN)$(RM) $@+ $@ && \
253 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
a5ae8e64 254 mv $@+ $@
93d69d86 255
a5ae8e64 256-include doc.dep
37465016 257
72fe6a59
JH
258cmds_txt = cmds-ancillaryinterrogators.txt \
259 cmds-ancillarymanipulators.txt \
260 cmds-mainporcelain.txt \
261 cmds-plumbinginterrogators.txt \
262 cmds-plumbingmanipulators.txt \
89bf2077
JH
263 cmds-synchingrepositories.txt \
264 cmds-synchelpers.txt \
265 cmds-purehelpers.txt \
266 cmds-foreignscminterface.txt
72fe6a59 267
d7907392
JH
268$(cmds_txt): cmd-list.made
269
79d30668 270cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
bb230097
CJ
271 $(QUIET_GEN)$(RM) $@ && \
272 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
d7907392 273 date >$@
b790abb8 274
f35ec546
DA
275mergetools_txt = mergetools-diff.txt mergetools-merge.txt
276
277$(mergetools_txt): mergetools-list.made
278
279mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
280 $(QUIET_GEN)$(RM) $@ && \
281 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
282 . ../git-mergetool--lib.sh && \
283 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
284 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
285 . ../git-mergetool--lib.sh && \
286 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
287 date >$@
288
b790abb8 289clean:
4c785e50 290 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
c6a5ad21 291 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
ae8044a2 292 $(RM) *.pdf
530e741c 293 $(RM) howto-index.txt howto/*.html doc.dep
5e00439f 294 $(RM) technical/*.html technical/api-index.txt
f35ec546 295 $(RM) $(cmds_txt) $(mergetools_txt) *.made
50d9bbba 296 $(RM) manpage-base-url.xsl
b790abb8 297
fdb04244 298$(MAN_HTML): %.html : %.txt asciidoc.conf
bb230097 299 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
7b8a74f3 300 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
bb230097 301 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
7b8a74f3 302 mv $@+ $@
b790abb8 303
bd4a3d61
JK
304$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
305 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
306 $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
307 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
308 mv $@+ $@
309
50d9bbba
TZ
310manpage-base-url.xsl: manpage-base-url.xsl.in
311 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
312
313%.1 %.5 %.7 : %.xml manpage-base-url.xsl
bb230097 314 $(QUIET_XMLTO)$(RM) $@ && \
dd4f3075 315 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
b790abb8 316
fdb04244 317%.xml : %.txt asciidoc.conf
bb230097 318 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
7b8a74f3 319 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
bb230097 320 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
7b8a74f3 321 mv $@+ $@
3f971fc4 322
d19fbc3c 323user-manual.xml: user-manual.txt user-manual.conf
f9dae0d3
JN
324 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
325 $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
326 mv $@+ $@
d19fbc3c 327
530e741c
JH
328technical/api-index.txt: technical/api-index-skel.txt \
329 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
ee7ec2f9 330 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
530e741c 331
fe77b416 332technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
fdb04244 333$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
bb230097 334 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
530e741c
JH
335 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
336
1cffddd6 337XSLT = docbook.xsl
0a3985dc 338XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
1c95c565 339
f2aff316 340user-manual.html: user-manual.xml $(XSLT)
f9dae0d3
JN
341 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
342 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
343 mv $@+ $@
d19fbc3c 344
50b3555c 345git.info: user-manual.texi
bb230097 346 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
5cefc33b 347
50b3555c 348user-manual.texi: user-manual.xml
bb230097 349 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
c6a5ad21
CJ
350 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
351 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
352 rm $@++ && \
5cefc33b
JH
353 mv $@+ $@
354
a325a1a7 355user-manual.pdf: user-manual.xml
bb230097
CJ
356 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
357 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
a325a1a7
MV
358 mv $@+ $@
359
5cefc33b 360gitman.texi: $(MAN_XML) cat-texi.perl
bb230097 361 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
8b30ad01 362 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
c6a5ad21
CJ
363 --to-stdout $(xml) &&) true) > $@++ && \
364 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
365 rm $@++ && \
5cefc33b
JH
366 mv $@+ $@
367
368gitman.info: gitman.texi
bb230097 369 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
5cefc33b
JH
370
371$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
bb230097
CJ
372 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
373 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
5cefc33b 374 mv $@+ $@
4739809c 375
e6fc2346 376howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
bb230097 377 $(QUIET_GEN)$(RM) $@+ $@ && \
854dfda8 378 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
e6fc2346
JH
379 mv $@+ $@
380
8db9307c 381$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
26e47f25 382 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
e6fc2346
JH
383
384WEBDOC_DEST = /pub/software/scm/git/docs
385
fe77b416 386howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
8d0991d7 387$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
bb230097 388 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
26e47f25 389 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
8d0991d7
JH
390 mv $@+ $@
391
e6fc2346 392install-webdoc : html
ee7ec2f9 393 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
6538d1ef 394
2de9b711
TA
395# You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
396# next to the 'git' repository itself for the following to work.
fcbebfdd 397
b1a46b70
MH
398quick-install: quick-install-man
399
fcbebfdd
JH
400require-manrepo::
401 @if test ! -d $(MAN_REPO); \
402 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
403
404quick-install-man: require-manrepo
405 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
406
407require-htmlrepo::
408 @if test ! -d $(HTML_REPO); \
409 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
7b8a74f3 410
fcbebfdd
JH
411quick-install-html: require-htmlrepo
412 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
6fe570de 413
5fafce0b
JK
414print-man1:
415 @for i in $(MAN1_TXT); do echo $$i; done
416
13fca9f3 417.PHONY: FORCE