built-in add -p: implement the 'g' ("goto") command
[git/debian.git] / Documentation / Makefile
blob06d85ad9588c93675f146bd398c415a85fe71d62
1 # Guard against environment variables
2 MAN1_TXT =
3 MAN5_TXT =
4 MAN7_TXT =
5 TECH_DOCS =
6 ARTICLES =
7 SP_ARTICLES =
8 OBSOLETE_HTML =
10 -include GIT-EXCLUDED-PROGRAMS
12 MAN1_TXT += $(filter-out \
13 $(patsubst %,%.txt,$(EXCLUDED_PROGRAMS)) \
14 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
15 $(wildcard git-*.txt))
16 MAN1_TXT += git.txt
17 MAN1_TXT += gitk.txt
18 MAN1_TXT += gitweb.txt
20 MAN5_TXT += gitattributes.txt
21 MAN5_TXT += githooks.txt
22 MAN5_TXT += gitignore.txt
23 MAN5_TXT += gitmodules.txt
24 MAN5_TXT += gitrepository-layout.txt
25 MAN5_TXT += gitweb.conf.txt
27 MAN7_TXT += gitcli.txt
28 MAN7_TXT += gitcore-tutorial.txt
29 MAN7_TXT += gitcredentials.txt
30 MAN7_TXT += gitcvs-migration.txt
31 MAN7_TXT += gitdiffcore.txt
32 MAN7_TXT += giteveryday.txt
33 MAN7_TXT += gitglossary.txt
34 MAN7_TXT += gitnamespaces.txt
35 MAN7_TXT += gitremote-helpers.txt
36 MAN7_TXT += gitrevisions.txt
37 MAN7_TXT += gitsubmodules.txt
38 MAN7_TXT += gittutorial-2.txt
39 MAN7_TXT += gittutorial.txt
40 MAN7_TXT += gitworkflows.txt
42 ifdef MAN_FILTER
43 MAN_TXT = $(filter $(MAN_FILTER),$(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT))
44 else
45 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
46 MAN_FILTER = $(MAN_TXT)
47 endif
49 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
50 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
51 GIT_MAN_REF = master
53 OBSOLETE_HTML += everyday.html
54 OBSOLETE_HTML += git-remote-helpers.html
56 ARTICLES += howto-index
57 ARTICLES += git-tools
58 ARTICLES += git-bisect-lk2009
59 # with their own formatting rules.
60 SP_ARTICLES += user-manual
61 SP_ARTICLES += howto/new-command
62 SP_ARTICLES += howto/revert-branch-rebase
63 SP_ARTICLES += howto/using-merge-subtree
64 SP_ARTICLES += howto/using-signed-tag-in-pull-request
65 SP_ARTICLES += howto/use-git-daemon
66 SP_ARTICLES += howto/update-hook-example
67 SP_ARTICLES += howto/setup-git-server-over-http
68 SP_ARTICLES += howto/separating-topic-branches
69 SP_ARTICLES += howto/revert-a-faulty-merge
70 SP_ARTICLES += howto/recover-corrupted-blob-object
71 SP_ARTICLES += howto/recover-corrupted-object-harder
72 SP_ARTICLES += howto/rebuild-from-update-hook
73 SP_ARTICLES += howto/rebase-from-internal-branch
74 SP_ARTICLES += howto/keep-canonical-history-correct
75 SP_ARTICLES += howto/maintain-git
76 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
77 SP_ARTICLES += $(API_DOCS)
79 TECH_DOCS += MyFirstContribution
80 TECH_DOCS += SubmittingPatches
81 TECH_DOCS += technical/hash-function-transition
82 TECH_DOCS += technical/http-protocol
83 TECH_DOCS += technical/index-format
84 TECH_DOCS += technical/long-running-process-protocol
85 TECH_DOCS += technical/multi-pack-index
86 TECH_DOCS += technical/pack-format
87 TECH_DOCS += technical/pack-heuristics
88 TECH_DOCS += technical/pack-protocol
89 TECH_DOCS += technical/partial-clone
90 TECH_DOCS += technical/protocol-capabilities
91 TECH_DOCS += technical/protocol-common
92 TECH_DOCS += technical/protocol-v2
93 TECH_DOCS += technical/racy-git
94 TECH_DOCS += technical/send-pack-pipeline
95 TECH_DOCS += technical/shallow
96 TECH_DOCS += technical/signature-format
97 TECH_DOCS += technical/trivial-merge
98 SP_ARTICLES += $(TECH_DOCS)
99 SP_ARTICLES += technical/api-index
101 ARTICLES_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
102 HTML_FILTER ?= $(ARTICLES_HTML) $(OBSOLETE_HTML)
103 DOC_HTML = $(MAN_HTML) $(filter $(HTML_FILTER),$(ARTICLES_HTML) $(OBSOLETE_HTML))
105 DOC_MAN1 = $(patsubst %.txt,%.1,$(filter $(MAN_FILTER),$(MAN1_TXT)))
106 DOC_MAN5 = $(patsubst %.txt,%.5,$(filter $(MAN_FILTER),$(MAN5_TXT)))
107 DOC_MAN7 = $(patsubst %.txt,%.7,$(filter $(MAN_FILTER),$(MAN7_TXT)))
109 prefix ?= $(HOME)
110 bindir ?= $(prefix)/bin
111 htmldir ?= $(prefix)/share/doc/git-doc
112 infodir ?= $(prefix)/share/info
113 pdfdir ?= $(prefix)/share/doc/git-doc
114 mandir ?= $(prefix)/share/man
115 man1dir = $(mandir)/man1
116 man5dir = $(mandir)/man5
117 man7dir = $(mandir)/man7
118 # DESTDIR =
120 ASCIIDOC = asciidoc
121 ASCIIDOC_EXTRA =
122 ASCIIDOC_HTML = xhtml11
123 ASCIIDOC_DOCBOOK = docbook
124 ASCIIDOC_CONF = -f asciidoc.conf
125 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
126 -amanversion=$(GIT_VERSION) \
127 -amanmanual='Git Manual' -amansource='Git'
128 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
129 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
130 MANPAGE_XSL = manpage-normal.xsl
131 XMLTO = xmlto
132 XMLTO_EXTRA =
133 INSTALL ?= install
134 RM ?= rm -f
135 MAN_REPO = ../../git-manpages
136 HTML_REPO = ../../git-htmldocs
138 MAKEINFO = makeinfo
139 INSTALL_INFO = install-info
140 DOCBOOK2X_TEXI = docbook2x-texi
141 DBLATEX = dblatex
142 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
143 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
144 ifndef PERL_PATH
145 PERL_PATH = /usr/bin/perl
146 endif
148 -include ../config.mak.autogen
149 -include ../config.mak
152 # For docbook-xsl ...
153 # -1.68.1, no extra settings are needed?
154 # 1.69.0, set ASCIIDOC_ROFF?
155 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
156 # 1.71.1, set ASCIIDOC_ROFF?
157 # 1.72.0, set DOCBOOK_XSL_172.
158 # 1.73.0-, no extra settings are needed
161 ifdef DOCBOOK_XSL_172
162 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
163 MANPAGE_XSL = manpage-1.72.xsl
164 else
165 ifndef ASCIIDOC_ROFF
166 # docbook-xsl after 1.72 needs the regular XSL, but will not
167 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
168 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
169 endif
170 endif
171 ifndef NO_MAN_BOLD_LITERAL
172 XMLTO_EXTRA += -m manpage-bold-literal.xsl
173 endif
174 ifdef DOCBOOK_SUPPRESS_SP
175 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
176 endif
178 # Newer DocBook stylesheet emits warning cruft in the output when
179 # this is not set, and if set it shows an absolute link. Older
180 # stylesheets simply ignore this parameter.
182 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
183 # or similar.
184 ifndef MAN_BASE_URL
185 MAN_BASE_URL = file://$(htmldir)/
186 endif
187 XMLTO_EXTRA += -m manpage-base-url.xsl
189 # If your target system uses GNU groff, it may try to render
190 # apostrophes as a "pretty" apostrophe using unicode. This breaks
191 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
192 # apostrophes. Unfortunately does not work with non-GNU roff.
193 ifdef GNU_ROFF
194 XMLTO_EXTRA += -m manpage-quote-apos.xsl
195 endif
197 ifdef USE_ASCIIDOCTOR
198 ASCIIDOC = asciidoctor
199 ASCIIDOC_CONF =
200 ASCIIDOC_HTML = xhtml5
201 ASCIIDOC_DOCBOOK = docbook5
202 ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
203 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
204 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
205 DBLATEX_COMMON =
206 XMLTO_EXTRA += --skip-validation
207 XMLTO_EXTRA += -x manpage.xsl
208 endif
210 SHELL_PATH ?= $(SHELL)
211 # Shell quote;
212 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
214 ifdef DEFAULT_PAGER
215 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
216 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
217 endif
219 ifdef DEFAULT_EDITOR
220 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
221 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
222 endif
224 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
225 QUIET_SUBDIR1 =
227 ifneq ($(findstring $(MAKEFLAGS),w),w)
228 PRINT_DIR = --no-print-directory
229 else # "make -w"
230 NO_SUBDIR = :
231 endif
233 ifneq ($(findstring $(MAKEFLAGS),s),s)
234 ifndef V
235 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
236 QUIET_XMLTO = @echo ' ' XMLTO $@;
237 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
238 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
239 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
240 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
241 QUIET_GEN = @echo ' ' GEN $@;
242 QUIET_LINT = @echo ' ' LINT $@;
243 QUIET_STDERR = 2> /dev/null
244 QUIET_SUBDIR0 = +@subdir=
245 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
246 $(MAKE) $(PRINT_DIR) -C $$subdir
247 export V
248 endif
249 endif
251 all: html man
253 html: $(DOC_HTML)
255 man: man1 man5 man7
256 man1: $(DOC_MAN1)
257 man5: $(DOC_MAN5)
258 man7: $(DOC_MAN7)
260 info: git.info gitman.info
262 pdf: user-manual.pdf
264 install: install-man
266 install-man: man
267 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
268 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
269 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
270 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
271 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
272 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
274 install-info: info
275 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
276 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
277 if test -r $(DESTDIR)$(infodir)/dir; then \
278 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
279 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
280 else \
281 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
284 install-pdf: pdf
285 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
286 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
288 install-html: html
289 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
291 ../GIT-VERSION-FILE: FORCE
292 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
294 -include ../GIT-VERSION-FILE
297 # Determine "include::" file references in asciidoc files.
299 docdep_prereqs = \
300 mergetools-list.made $(mergetools_txt) \
301 cmd-list.made $(cmds_txt)
303 doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
304 $(QUIET_GEN)$(RM) $@+ $@ && \
305 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
306 mv $@+ $@
308 -include doc.dep
310 cmds_txt = cmds-ancillaryinterrogators.txt \
311 cmds-ancillarymanipulators.txt \
312 cmds-mainporcelain.txt \
313 cmds-plumbinginterrogators.txt \
314 cmds-plumbingmanipulators.txt \
315 cmds-synchingrepositories.txt \
316 cmds-synchelpers.txt \
317 cmds-purehelpers.txt \
318 cmds-foreignscminterface.txt
320 $(cmds_txt): cmd-list.made
322 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
323 $(QUIET_GEN)$(RM) $@ && \
324 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
325 date >$@
327 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
329 $(mergetools_txt): mergetools-list.made
331 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
332 $(QUIET_GEN)$(RM) $@ && \
333 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
334 . ../git-mergetool--lib.sh && \
335 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
336 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
337 . ../git-mergetool--lib.sh && \
338 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
339 date >$@
341 TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
343 GIT-ASCIIDOCFLAGS: FORCE
344 @FLAGS='$(TRACK_ASCIIDOCFLAGS)'; \
345 if test x"$$FLAGS" != x"`cat GIT-ASCIIDOCFLAGS 2>/dev/null`" ; then \
346 echo >&2 " * new asciidoc flags"; \
347 echo "$$FLAGS" >GIT-ASCIIDOCFLAGS; \
350 clean:
351 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
352 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
353 $(RM) *.pdf
354 $(RM) howto-index.txt howto/*.html doc.dep
355 $(RM) technical/*.html technical/api-index.txt
356 $(RM) SubmittingPatches.txt
357 $(RM) $(cmds_txt) $(mergetools_txt) *.made
358 $(RM) manpage-base-url.xsl
359 $(RM) GIT-ASCIIDOCFLAGS
361 $(MAN_HTML): %.html : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
362 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
363 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
364 mv $@+ $@
366 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
367 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
368 $(TXT_TO_HTML) -o $@+ $< && \
369 mv $@+ $@
371 manpage-base-url.xsl: manpage-base-url.xsl.in
372 $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
374 %.1 %.5 %.7 : %.xml manpage-base-url.xsl $(wildcard manpage*.xsl)
375 $(QUIET_XMLTO)$(RM) $@ && \
376 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
378 %.xml : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
379 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
380 $(TXT_TO_XML) -d manpage -o $@+ $< && \
381 mv $@+ $@
383 user-manual.xml: user-manual.txt user-manual.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
384 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
385 $(TXT_TO_XML) -d book -o $@+ $< && \
386 mv $@+ $@
388 technical/api-index.txt: technical/api-index-skel.txt \
389 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
390 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
392 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
393 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
394 asciidoc.conf GIT-ASCIIDOCFLAGS
395 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
397 SubmittingPatches.txt: SubmittingPatches
398 $(QUIET_GEN) cp $< $@
400 XSLT = docbook.xsl
401 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
403 user-manual.html: user-manual.xml $(XSLT)
404 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
405 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
406 mv $@+ $@
408 git.info: user-manual.texi
409 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
411 user-manual.texi: user-manual.xml
412 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
413 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
414 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
415 rm $@++ && \
416 mv $@+ $@
418 user-manual.pdf: user-manual.xml
419 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
420 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
421 mv $@+ $@
423 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
424 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
425 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
426 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
427 rm $(xml)+ &&) true) > $@++ && \
428 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
429 rm $@++ && \
430 mv $@+ $@
432 gitman.info: gitman.texi
433 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
435 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
436 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
437 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
438 mv $@+ $@
440 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
441 $(QUIET_GEN)$(RM) $@+ $@ && \
442 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
443 mv $@+ $@
445 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
446 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
448 WEBDOC_DEST = /pub/software/scm/git/docs
450 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
451 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt GIT-ASCIIDOCFLAGS
452 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
453 sed -e '1,/^$$/d' $< | \
454 $(TXT_TO_HTML) - >$@+ && \
455 mv $@+ $@
457 install-webdoc : html
458 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
460 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
461 # next to the 'git' repository itself for the following to work.
463 quick-install: quick-install-man
465 require-manrepo::
466 @if test ! -d $(MAN_REPO); \
467 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
469 quick-install-man: require-manrepo
470 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
472 require-htmlrepo::
473 @if test ! -d $(HTML_REPO); \
474 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
476 quick-install-html: require-htmlrepo
477 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
479 print-man1:
480 @for i in $(MAN1_TXT); do echo $$i; done
482 lint-docs::
483 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
485 ifeq ($(wildcard po/Makefile),po/Makefile)
486 doc-l10n install-l10n::
487 $(MAKE) -C po $@
488 endif
490 .PHONY: FORCE