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