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
40 MAN_TXT = $(filter $(MAN_FILTER),$(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT))
42 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
43 MAN_FILTER = $(MAN_TXT)
46 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
47 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
50 OBSOLETE_HTML += everyday.html
51 OBSOLETE_HTML += git-remote-helpers.html
53 ARTICLES += howto-index
55 ARTICLES += git-bisect-lk2009
56 # with their own formatting rules.
57 SP_ARTICLES += user-manual
58 SP_ARTICLES += howto/new-command
59 SP_ARTICLES += howto/revert-branch-rebase
60 SP_ARTICLES += howto/using-merge-subtree
61 SP_ARTICLES += howto/using-signed-tag-in-pull-request
62 SP_ARTICLES += howto/use-git-daemon
63 SP_ARTICLES += howto/update-hook-example
64 SP_ARTICLES += howto/setup-git-server-over-http
65 SP_ARTICLES += howto/separating-topic-branches
66 SP_ARTICLES += howto/revert-a-faulty-merge
67 SP_ARTICLES += howto/recover-corrupted-blob-object
68 SP_ARTICLES += howto/recover-corrupted-object-harder
69 SP_ARTICLES += howto/rebuild-from-update-hook
70 SP_ARTICLES += howto/rebase-from-internal-branch
71 SP_ARTICLES += howto/keep-canonical-history-correct
72 SP_ARTICLES += howto/maintain-git
73 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
74 SP_ARTICLES += $(API_DOCS)
76 TECH_DOCS += SubmittingPatches
77 TECH_DOCS += technical/hash-function-transition
78 TECH_DOCS += technical/http-protocol
79 TECH_DOCS += technical/index-format
80 TECH_DOCS += technical/long-running-process-protocol
81 TECH_DOCS += technical/multi-pack-index
82 TECH_DOCS += technical/pack-format
83 TECH_DOCS += technical/pack-heuristics
84 TECH_DOCS += technical/pack-protocol
85 TECH_DOCS += technical/partial-clone
86 TECH_DOCS += technical/protocol-capabilities
87 TECH_DOCS += technical/protocol-common
88 TECH_DOCS += technical/protocol-v2
89 TECH_DOCS += technical/racy-git
90 TECH_DOCS += technical/send-pack-pipeline
91 TECH_DOCS += technical/shallow
92 TECH_DOCS += technical/signature-format
93 TECH_DOCS += technical/trivial-merge
94 SP_ARTICLES += $(TECH_DOCS)
95 SP_ARTICLES += technical/api-index
97 ARTICLES_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
98 HTML_FILTER ?= $(ARTICLES_HTML) $(OBSOLETE_HTML)
99 DOC_HTML = $(MAN_HTML) $(filter $(HTML_FILTER),$(ARTICLES_HTML) $(OBSOLETE_HTML))
101 DOC_MAN1 = $(patsubst %.txt,%.1,$(filter $(MAN_FILTER),$(MAN1_TXT)))
102 DOC_MAN5 = $(patsubst %.txt,%.5,$(filter $(MAN_FILTER),$(MAN5_TXT)))
103 DOC_MAN7 = $(patsubst %.txt,%.7,$(filter $(MAN_FILTER),$(MAN7_TXT)))
106 bindir ?= $(prefix)/bin
107 htmldir ?= $(prefix)/share/doc/git-doc
108 infodir ?= $(prefix)/share/info
109 pdfdir ?= $(prefix)/share/doc/git-doc
110 mandir ?= $(prefix)/share/man
111 man1dir = $(mandir)/man1
112 man5dir = $(mandir)/man5
113 man7dir = $(mandir)/man7
118 ASCIIDOC_HTML = xhtml11
119 ASCIIDOC_DOCBOOK = docbook
120 ASCIIDOC_CONF = -f asciidoc.conf
121 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
122 -agit_version=$(GIT_VERSION)
123 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
124 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
125 MANPAGE_XSL = manpage-normal.xsl
130 MAN_REPO = ../../git-manpages
131 HTML_REPO = ../../git-htmldocs
134 INSTALL_INFO = install-info
135 DOCBOOK2X_TEXI = docbook2x-texi
137 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
138 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
140 PERL_PATH = /usr/bin/perl
143 -include ../config.mak.autogen
144 -include ../config.mak
147 # For docbook-xsl ...
148 # -1.68.1, no extra settings are needed?
149 # 1.69.0, set ASCIIDOC_ROFF?
150 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
151 # 1.71.1, set ASCIIDOC_ROFF?
152 # 1.72.0, set DOCBOOK_XSL_172.
153 # 1.73.0-, no extra settings are needed
156 ifdef DOCBOOK_XSL_172
157 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
158 MANPAGE_XSL = manpage-1.72.xsl
161 # docbook-xsl after 1.72 needs the regular XSL, but will not
162 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
163 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
166 ifndef NO_MAN_BOLD_LITERAL
167 XMLTO_EXTRA += -m manpage-bold-literal.xsl
169 ifdef DOCBOOK_SUPPRESS_SP
170 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
173 # Newer DocBook stylesheet emits warning cruft in the output when
174 # this is not set, and if set it shows an absolute link. Older
175 # stylesheets simply ignore this parameter.
177 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
180 MAN_BASE_URL = file://$(htmldir)/
182 XMLTO_EXTRA += -m manpage-base-url.xsl
184 # If your target system uses GNU groff, it may try to render
185 # apostrophes as a "pretty" apostrophe using unicode. This breaks
186 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
187 # apostrophes. Unfortunately does not work with non-GNU roff.
189 XMLTO_EXTRA += -m manpage-quote-apos.xsl
192 ifdef USE_ASCIIDOCTOR
193 ASCIIDOC = asciidoctor
195 ASCIIDOC_HTML = xhtml5
196 ASCIIDOC_DOCBOOK = docbook45
197 ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
198 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
199 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
203 SHELL_PATH ?= $(SHELL)
205 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
208 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
209 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
213 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
214 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
217 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
220 ifneq ($(findstring $(MAKEFLAGS),w),w)
221 PRINT_DIR = --no-print-directory
226 ifneq ($(findstring $(MAKEFLAGS),s),s)
228 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
229 QUIET_XMLTO = @echo ' ' XMLTO $@;
230 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
231 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
232 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
233 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
234 QUIET_GEN = @echo ' ' GEN $@;
235 QUIET_LINT = @echo ' ' LINT $@;
236 QUIET_STDERR = 2> /dev/null
237 QUIET_SUBDIR0 = +@subdir=
238 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
239 $(MAKE) $(PRINT_DIR) -C $$subdir
253 info: git.info gitman.info
260 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
261 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
262 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
263 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
264 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
265 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
268 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
269 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
270 if test -r $(DESTDIR)$(infodir)/dir; then \
271 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
272 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
274 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
278 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
279 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
282 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
284 ../GIT-VERSION-FILE: FORCE
285 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
287 -include ../GIT-VERSION-FILE
290 # Determine "include::" file references in asciidoc files.
293 mergetools-list.made $(mergetools_txt) \
294 cmd-list.made $(cmds_txt)
296 doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
297 $(QUIET_GEN)$(RM) $@+ $@ && \
298 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
303 cmds_txt = cmds-ancillaryinterrogators.txt \
304 cmds-ancillarymanipulators.txt \
305 cmds-mainporcelain.txt \
306 cmds-plumbinginterrogators.txt \
307 cmds-plumbingmanipulators.txt \
308 cmds-synchingrepositories.txt \
309 cmds-synchelpers.txt \
310 cmds-purehelpers.txt \
311 cmds-foreignscminterface.txt
313 $(cmds_txt): cmd-list.made
315 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
316 $(QUIET_GEN)$(RM) $@ && \
317 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
320 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
322 $(mergetools_txt): mergetools-list.made
324 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
325 $(QUIET_GEN)$(RM) $@ && \
326 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
327 . ../git-mergetool--lib.sh && \
328 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
329 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
330 . ../git-mergetool--lib.sh && \
331 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
335 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
336 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
338 $(RM) howto-index.txt howto/*.html doc.dep
339 $(RM) technical/*.html technical/api-index.txt
340 $(RM) SubmittingPatches.txt
341 $(RM) $(cmds_txt) $(mergetools_txt) *.made
342 $(RM) manpage-base-url.xsl
344 $(MAN_HTML): %.html : %.txt asciidoc.conf
345 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
346 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
349 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
350 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
351 $(TXT_TO_HTML) -o $@+ $< && \
354 manpage-base-url.xsl: manpage-base-url.xsl.in
355 $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
357 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
358 $(QUIET_XMLTO)$(RM) $@ && \
359 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
361 %.xml : %.txt asciidoc.conf
362 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
363 $(TXT_TO_XML) -d manpage -o $@+ $< && \
366 user-manual.xml: user-manual.txt user-manual.conf
367 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
368 $(TXT_TO_XML) -d book -o $@+ $< && \
371 technical/api-index.txt: technical/api-index-skel.txt \
372 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
373 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
375 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
376 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
377 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
379 SubmittingPatches.txt: SubmittingPatches
380 $(QUIET_GEN) cp $< $@
383 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
385 user-manual.html: user-manual.xml $(XSLT)
386 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
387 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
390 git.info: user-manual.texi
391 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
393 user-manual.texi: user-manual.xml
394 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
395 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
396 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
400 user-manual.pdf: user-manual.xml
401 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
402 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
405 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
406 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
407 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
408 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
409 rm $(xml)+ &&) true) > $@++ && \
410 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
414 gitman.info: gitman.texi
415 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
417 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
418 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
419 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
422 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
423 $(QUIET_GEN)$(RM) $@+ $@ && \
424 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
427 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
428 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
430 WEBDOC_DEST = /pub/software/scm/git/docs
432 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
433 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
434 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
435 sed -e '1,/^$$/d' $< | \
436 $(TXT_TO_HTML) - >$@+ && \
439 install-webdoc : html
440 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
442 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
443 # next to the 'git' repository itself for the following to work.
445 quick-install: quick-install-man
448 @if test ! -d $(MAN_REPO); \
449 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
451 quick-install-man: require-manrepo
452 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
455 @if test ! -d $(HTML_REPO); \
456 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
458 quick-install-html: require-htmlrepo
459 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
462 @for i in $(MAN1_TXT); do echo $$i; done
465 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
467 ifeq ($(wildcard po/Makefile),po/Makefile)
468 doc-l10n install-l10n::