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