1 # Guard against environment variables
10 MAN1_TXT += $(filter-out \
11 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
12 $(wildcard git-*.txt))
15 MAN1_TXT += gitremote-helpers.txt
16 MAN1_TXT += gitweb.txt
18 MAN5_TXT += gitattributes.txt
19 MAN5_TXT += githooks.txt
20 MAN5_TXT += gitignore.txt
21 MAN5_TXT += gitmodules.txt
22 MAN5_TXT += gitrepository-layout.txt
23 MAN5_TXT += gitweb.conf.txt
25 MAN7_TXT += gitcli.txt
26 MAN7_TXT += gitcore-tutorial.txt
27 MAN7_TXT += gitcredentials.txt
28 MAN7_TXT += gitcvs-migration.txt
29 MAN7_TXT += gitdiffcore.txt
30 MAN7_TXT += giteveryday.txt
31 MAN7_TXT += gitglossary.txt
32 MAN7_TXT += gitnamespaces.txt
33 MAN7_TXT += gitrevisions.txt
34 MAN7_TXT += gitsubmodules.txt
35 MAN7_TXT += gittutorial-2.txt
36 MAN7_TXT += gittutorial.txt
37 MAN7_TXT += gitworkflows.txt
39 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
40 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
41 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
44 OBSOLETE_HTML += everyday.html
45 OBSOLETE_HTML += git-remote-helpers.html
46 DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
48 ARTICLES += howto-index
50 ARTICLES += git-bisect-lk2009
51 # with their own formatting rules.
52 SP_ARTICLES += user-manual
53 SP_ARTICLES += howto/new-command
54 SP_ARTICLES += howto/revert-branch-rebase
55 SP_ARTICLES += howto/using-merge-subtree
56 SP_ARTICLES += howto/using-signed-tag-in-pull-request
57 SP_ARTICLES += howto/use-git-daemon
58 SP_ARTICLES += howto/update-hook-example
59 SP_ARTICLES += howto/setup-git-server-over-http
60 SP_ARTICLES += howto/separating-topic-branches
61 SP_ARTICLES += howto/revert-a-faulty-merge
62 SP_ARTICLES += howto/recover-corrupted-blob-object
63 SP_ARTICLES += howto/recover-corrupted-object-harder
64 SP_ARTICLES += howto/rebuild-from-update-hook
65 SP_ARTICLES += howto/rebase-from-internal-branch
66 SP_ARTICLES += howto/keep-canonical-history-correct
67 SP_ARTICLES += howto/maintain-git
68 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
69 SP_ARTICLES += $(API_DOCS)
71 TECH_DOCS += SubmittingPatches
72 TECH_DOCS += technical/hash-function-transition
73 TECH_DOCS += technical/http-protocol
74 TECH_DOCS += technical/index-format
75 TECH_DOCS += technical/long-running-process-protocol
76 TECH_DOCS += technical/multi-pack-index
77 TECH_DOCS += technical/pack-format
78 TECH_DOCS += technical/pack-heuristics
79 TECH_DOCS += technical/pack-protocol
80 TECH_DOCS += technical/partial-clone
81 TECH_DOCS += technical/protocol-capabilities
82 TECH_DOCS += technical/protocol-common
83 TECH_DOCS += technical/protocol-v2
84 TECH_DOCS += technical/racy-git
85 TECH_DOCS += technical/send-pack-pipeline
86 TECH_DOCS += technical/shallow
87 TECH_DOCS += technical/signature-format
88 TECH_DOCS += technical/trivial-merge
89 SP_ARTICLES += $(TECH_DOCS)
90 SP_ARTICLES += technical/api-index
92 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
94 DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
95 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
96 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
99 bindir ?= $(prefix)/bin
100 htmldir ?= $(prefix)/share/doc/git-doc
101 infodir ?= $(prefix)/share/info
102 pdfdir ?= $(prefix)/share/doc/git-doc
103 mandir ?= $(prefix)/share/man
104 man1dir = $(mandir)/man1
105 man5dir = $(mandir)/man5
106 man7dir = $(mandir)/man7
111 ASCIIDOC_HTML = xhtml11
112 ASCIIDOC_DOCBOOK = docbook
113 ASCIIDOC_CONF = -f asciidoc.conf
114 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
115 -agit_version=$(GIT_VERSION)
116 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
117 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
118 MANPAGE_XSL = manpage-normal.xsl
123 MAN_REPO = ../../git-manpages
124 HTML_REPO = ../../git-htmldocs
127 INSTALL_INFO = install-info
128 DOCBOOK2X_TEXI = docbook2x-texi
130 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
131 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
133 PERL_PATH = /usr/bin/perl
136 -include ../config.mak.autogen
137 -include ../config.mak
140 # For docbook-xsl ...
141 # -1.68.1, no extra settings are needed?
142 # 1.69.0, set ASCIIDOC_ROFF?
143 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
144 # 1.71.1, set ASCIIDOC_ROFF?
145 # 1.72.0, set DOCBOOK_XSL_172.
146 # 1.73.0-, no extra settings are needed
149 ifdef DOCBOOK_XSL_172
150 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
151 MANPAGE_XSL = manpage-1.72.xsl
154 # docbook-xsl after 1.72 needs the regular XSL, but will not
155 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
156 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
159 ifndef NO_MAN_BOLD_LITERAL
160 XMLTO_EXTRA += -m manpage-bold-literal.xsl
162 ifdef DOCBOOK_SUPPRESS_SP
163 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
166 # Newer DocBook stylesheet emits warning cruft in the output when
167 # this is not set, and if set it shows an absolute link. Older
168 # stylesheets simply ignore this parameter.
170 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
173 MAN_BASE_URL = file://$(htmldir)/
175 XMLTO_EXTRA += -m manpage-base-url.xsl
177 # If your target system uses GNU groff, it may try to render
178 # apostrophes as a "pretty" apostrophe using unicode. This breaks
179 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
180 # apostrophes. Unfortunately does not work with non-GNU roff.
182 XMLTO_EXTRA += -m manpage-quote-apos.xsl
185 ifdef USE_ASCIIDOCTOR
186 ASCIIDOC = asciidoctor
188 ASCIIDOC_HTML = xhtml5
189 ASCIIDOC_DOCBOOK = docbook45
190 ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
191 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
192 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
196 SHELL_PATH ?= $(SHELL)
198 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
201 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
202 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
206 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
207 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
210 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
213 ifneq ($(findstring $(MAKEFLAGS),w),w)
214 PRINT_DIR = --no-print-directory
219 ifneq ($(findstring $(MAKEFLAGS),s),s)
221 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
222 QUIET_XMLTO = @echo ' ' XMLTO $@;
223 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
224 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
225 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
226 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
227 QUIET_GEN = @echo ' ' GEN $@;
228 QUIET_LINT = @echo ' ' LINT $@;
229 QUIET_STDERR = 2> /dev/null
230 QUIET_SUBDIR0 = +@subdir=
231 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
232 $(MAKE) $(PRINT_DIR) -C $$subdir
246 info: git.info gitman.info
253 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
254 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
255 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
256 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
257 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
258 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
261 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
262 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
263 if test -r $(DESTDIR)$(infodir)/dir; then \
264 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
265 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
267 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
271 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
272 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
275 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
277 ../GIT-VERSION-FILE: FORCE
278 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
280 -include ../GIT-VERSION-FILE
283 # Determine "include::" file references in asciidoc files.
286 mergetools-list.made $(mergetools_txt) \
287 cmd-list.made $(cmds_txt)
289 doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
290 $(QUIET_GEN)$(RM) $@+ $@ && \
291 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
296 cmds_txt = cmds-ancillaryinterrogators.txt \
297 cmds-ancillarymanipulators.txt \
298 cmds-mainporcelain.txt \
299 cmds-plumbinginterrogators.txt \
300 cmds-plumbingmanipulators.txt \
301 cmds-synchingrepositories.txt \
302 cmds-synchelpers.txt \
303 cmds-purehelpers.txt \
304 cmds-foreignscminterface.txt
306 $(cmds_txt): cmd-list.made
308 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
309 $(QUIET_GEN)$(RM) $@ && \
310 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
313 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
315 $(mergetools_txt): mergetools-list.made
317 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
318 $(QUIET_GEN)$(RM) $@ && \
319 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
320 . ../git-mergetool--lib.sh && \
321 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
322 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
323 . ../git-mergetool--lib.sh && \
324 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
328 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
329 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
331 $(RM) howto-index.txt howto/*.html doc.dep
332 $(RM) technical/*.html technical/api-index.txt
333 $(RM) SubmittingPatches.txt
334 $(RM) $(cmds_txt) $(mergetools_txt) *.made
335 $(RM) manpage-base-url.xsl
337 $(MAN_HTML): %.html : %.txt asciidoc.conf
338 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
339 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
342 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
343 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
344 $(TXT_TO_HTML) -o $@+ $< && \
347 manpage-base-url.xsl: manpage-base-url.xsl.in
348 $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
350 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
351 $(QUIET_XMLTO)$(RM) $@ && \
352 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
354 %.xml : %.txt asciidoc.conf
355 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
356 $(TXT_TO_XML) -d manpage -o $@+ $< && \
359 user-manual.xml: user-manual.txt user-manual.conf
360 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
361 $(TXT_TO_XML) -d book -o $@+ $< && \
364 technical/api-index.txt: technical/api-index-skel.txt \
365 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
366 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
368 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
369 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
370 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
372 SubmittingPatches.txt: SubmittingPatches
373 $(QUIET_GEN) cp $< $@
376 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
378 user-manual.html: user-manual.xml $(XSLT)
379 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
380 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
383 git.info: user-manual.texi
384 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
386 user-manual.texi: user-manual.xml
387 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
388 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
389 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
393 user-manual.pdf: user-manual.xml
394 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
395 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
398 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
399 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
400 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
401 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
402 rm $(xml)+ &&) true) > $@++ && \
403 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
407 gitman.info: gitman.texi
408 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
410 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
411 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
412 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
415 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
416 $(QUIET_GEN)$(RM) $@+ $@ && \
417 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
420 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
421 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
423 WEBDOC_DEST = /pub/software/scm/git/docs
425 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
426 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
427 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
428 sed -e '1,/^$$/d' $< | \
429 $(TXT_TO_HTML) - >$@+ && \
432 install-webdoc : html
433 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
435 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
436 # next to the 'git' repository itself for the following to work.
438 quick-install: quick-install-man
441 @if test ! -d $(MAN_REPO); \
442 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
444 quick-install-man: require-manrepo
445 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
448 @if test ! -d $(HTML_REPO); \
449 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
451 quick-install-html: require-htmlrepo
452 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
455 @for i in $(MAN1_TXT); do echo $$i; done
458 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl