1 # Guard against environment variables
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))
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 += gitfaq.txt
34 MAN7_TXT += gitglossary.txt
35 MAN7_TXT += gitnamespaces.txt
36 MAN7_TXT += gitremote-helpers.txt
37 MAN7_TXT += gitrevisions.txt
38 MAN7_TXT += gitsubmodules.txt
39 MAN7_TXT += gittutorial-2.txt
40 MAN7_TXT += gittutorial.txt
41 MAN7_TXT += gitworkflows.txt
44 MAN_TXT = $(filter $(MAN_FILTER),$(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT))
46 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
47 MAN_FILTER = $(MAN_TXT)
50 MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
51 MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
54 OBSOLETE_HTML += everyday.html
55 OBSOLETE_HTML += git-remote-helpers.html
57 ARTICLES += howto-index
59 ARTICLES += git-bisect-lk2009
60 # with their own formatting rules.
61 SP_ARTICLES += user-manual
62 SP_ARTICLES += howto/new-command
63 SP_ARTICLES += howto/revert-branch-rebase
64 SP_ARTICLES += howto/using-merge-subtree
65 SP_ARTICLES += howto/using-signed-tag-in-pull-request
66 SP_ARTICLES += howto/use-git-daemon
67 SP_ARTICLES += howto/update-hook-example
68 SP_ARTICLES += howto/setup-git-server-over-http
69 SP_ARTICLES += howto/separating-topic-branches
70 SP_ARTICLES += howto/revert-a-faulty-merge
71 SP_ARTICLES += howto/recover-corrupted-blob-object
72 SP_ARTICLES += howto/recover-corrupted-object-harder
73 SP_ARTICLES += howto/rebuild-from-update-hook
74 SP_ARTICLES += howto/rebase-from-internal-branch
75 SP_ARTICLES += howto/keep-canonical-history-correct
76 SP_ARTICLES += howto/maintain-git
77 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
78 SP_ARTICLES += $(API_DOCS)
80 TECH_DOCS += MyFirstContribution
81 TECH_DOCS += MyFirstObjectWalk
82 TECH_DOCS += SubmittingPatches
83 TECH_DOCS += technical/hash-function-transition
84 TECH_DOCS += technical/http-protocol
85 TECH_DOCS += technical/index-format
86 TECH_DOCS += technical/long-running-process-protocol
87 TECH_DOCS += technical/multi-pack-index
88 TECH_DOCS += technical/pack-format
89 TECH_DOCS += technical/pack-heuristics
90 TECH_DOCS += technical/pack-protocol
91 TECH_DOCS += technical/partial-clone
92 TECH_DOCS += technical/protocol-capabilities
93 TECH_DOCS += technical/protocol-common
94 TECH_DOCS += technical/protocol-v2
95 TECH_DOCS += technical/racy-git
96 TECH_DOCS += technical/send-pack-pipeline
97 TECH_DOCS += technical/shallow
98 TECH_DOCS += technical/signature-format
99 TECH_DOCS += technical/trivial-merge
100 SP_ARTICLES += $(TECH_DOCS)
101 SP_ARTICLES += technical/api-index
103 ARTICLES_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
104 HTML_FILTER ?= $(ARTICLES_HTML) $(OBSOLETE_HTML)
105 DOC_HTML = $(MAN_HTML) $(filter $(HTML_FILTER),$(ARTICLES_HTML) $(OBSOLETE_HTML))
107 DOC_MAN1 = $(patsubst %.txt,%.1,$(filter $(MAN_FILTER),$(MAN1_TXT)))
108 DOC_MAN5 = $(patsubst %.txt,%.5,$(filter $(MAN_FILTER),$(MAN5_TXT)))
109 DOC_MAN7 = $(patsubst %.txt,%.7,$(filter $(MAN_FILTER),$(MAN7_TXT)))
112 bindir ?= $(prefix)/bin
113 htmldir ?= $(prefix)/share/doc/git-doc
114 infodir ?= $(prefix)/share/info
115 pdfdir ?= $(prefix)/share/doc/git-doc
116 mandir ?= $(prefix)/share/man
117 man1dir = $(mandir)/man1
118 man5dir = $(mandir)/man5
119 man7dir = $(mandir)/man7
124 ASCIIDOC_HTML = xhtml11
125 ASCIIDOC_DOCBOOK = docbook
126 ASCIIDOC_CONF = -f asciidoc.conf
127 ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
128 -amanversion=$(GIT_VERSION) \
129 -amanmanual='Git Manual' -amansource='Git'
130 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
131 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
132 MANPAGE_XSL = manpage-normal.xsl
137 MAN_REPO = ../../git-manpages
138 HTML_REPO = ../../git-htmldocs
141 INSTALL_INFO = install-info
142 DOCBOOK2X_TEXI = docbook2x-texi
144 ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
145 DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
147 PERL_PATH = /usr/bin/perl
150 -include ../config.mak.autogen
151 -include ../config.mak
154 # For docbook-xsl ...
155 # -1.68.1, no extra settings are needed?
156 # 1.69.0, set ASCIIDOC_ROFF?
157 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
158 # 1.71.1, set ASCIIDOC_ROFF?
159 # 1.72.0, set DOCBOOK_XSL_172.
160 # 1.73.0-, no extra settings are needed
163 ifdef DOCBOOK_XSL_172
164 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
165 MANPAGE_XSL = manpage-1.72.xsl
168 # docbook-xsl after 1.72 needs the regular XSL, but will not
169 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
170 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
173 ifndef NO_MAN_BOLD_LITERAL
174 XMLTO_EXTRA += -m manpage-bold-literal.xsl
176 ifdef DOCBOOK_SUPPRESS_SP
177 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
180 # Newer DocBook stylesheet emits warning cruft in the output when
181 # this is not set, and if set it shows an absolute link. Older
182 # stylesheets simply ignore this parameter.
184 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
187 MAN_BASE_URL = file://$(htmldir)/
189 XMLTO_EXTRA += -m manpage-base-url.xsl
191 # If your target system uses GNU groff, it may try to render
192 # apostrophes as a "pretty" apostrophe using unicode. This breaks
193 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
194 # apostrophes. Unfortunately does not work with non-GNU roff.
196 XMLTO_EXTRA += -m manpage-quote-apos.xsl
199 ifdef USE_ASCIIDOCTOR
200 ASCIIDOC = asciidoctor
202 ASCIIDOC_HTML = xhtml5
203 ASCIIDOC_DOCBOOK = docbook5
204 ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
205 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
206 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
208 XMLTO_EXTRA += --skip-validation
209 XMLTO_EXTRA += -x manpage.xsl
212 SHELL_PATH ?= $(SHELL)
214 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
217 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
218 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
222 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
223 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
226 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
229 ifneq ($(findstring $(MAKEFLAGS),w),w)
230 PRINT_DIR = --no-print-directory
235 ifneq ($(findstring $(MAKEFLAGS),s),s)
237 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
238 QUIET_XMLTO = @echo ' ' XMLTO $@;
239 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
240 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
241 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
242 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
243 QUIET_GEN = @echo ' ' GEN $@;
244 QUIET_LINT = @echo ' ' LINT $@;
245 QUIET_STDERR = 2> /dev/null
246 QUIET_SUBDIR0 = +@subdir=
247 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
248 $(MAKE) $(PRINT_DIR) -C $$subdir
262 info: git.info gitman.info
269 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
270 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
271 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
272 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
273 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
274 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
277 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
278 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
279 if test -r $(DESTDIR)$(infodir)/dir; then \
280 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
281 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
283 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
287 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
288 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
291 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
293 ../GIT-VERSION-FILE: FORCE
294 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
296 -include ../GIT-VERSION-FILE
299 # Determine "include::" file references in asciidoc files.
302 mergetools-list.made $(mergetools_txt) \
303 cmd-list.made $(cmds_txt)
305 doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
306 $(QUIET_GEN)$(RM) $@+ $@ && \
307 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
312 cmds_txt = cmds-ancillaryinterrogators.txt \
313 cmds-ancillarymanipulators.txt \
314 cmds-mainporcelain.txt \
315 cmds-plumbinginterrogators.txt \
316 cmds-plumbingmanipulators.txt \
317 cmds-synchingrepositories.txt \
318 cmds-synchelpers.txt \
319 cmds-purehelpers.txt \
320 cmds-foreignscminterface.txt
322 $(cmds_txt): cmd-list.made
324 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
325 $(QUIET_GEN)$(RM) $@ && \
326 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
329 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
331 $(mergetools_txt): mergetools-list.made
333 mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
334 $(QUIET_GEN)$(RM) $@ && \
335 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
336 . ../git-mergetool--lib.sh && \
337 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
338 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
339 . ../git-mergetool--lib.sh && \
340 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
343 TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
345 GIT-ASCIIDOCFLAGS: FORCE
346 @FLAGS='$(TRACK_ASCIIDOCFLAGS)'; \
347 if test x"$$FLAGS" != x"`cat GIT-ASCIIDOCFLAGS 2>/dev/null`" ; then \
348 echo >&2 " * new asciidoc flags"; \
349 echo "$$FLAGS" >GIT-ASCIIDOCFLAGS; \
353 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
354 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
356 $(RM) howto-index.txt howto/*.html doc.dep
357 $(RM) technical/*.html technical/api-index.txt
358 $(RM) SubmittingPatches.txt
359 $(RM) $(cmds_txt) $(mergetools_txt) *.made
360 $(RM) manpage-base-url.xsl
361 $(RM) GIT-ASCIIDOCFLAGS
363 $(MAN_HTML): %.html : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
364 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
365 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
368 $(OBSOLETE_HTML): %.html : %.txto asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
369 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
370 $(TXT_TO_HTML) -o $@+ $< && \
373 manpage-base-url.xsl: manpage-base-url.xsl.in
374 $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
376 %.1 %.5 %.7 : %.xml manpage-base-url.xsl $(wildcard manpage*.xsl)
377 $(QUIET_XMLTO)$(RM) $@ && \
378 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
380 %.xml : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
381 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
382 $(TXT_TO_XML) -d manpage -o $@+ $< && \
385 user-manual.xml: user-manual.txt user-manual.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
386 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
387 $(TXT_TO_XML) -d book -o $@+ $< && \
390 technical/api-index.txt: technical/api-index-skel.txt \
391 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
392 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
394 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
395 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
396 asciidoc.conf GIT-ASCIIDOCFLAGS
397 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
399 SubmittingPatches.txt: SubmittingPatches
400 $(QUIET_GEN) cp $< $@
403 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
405 user-manual.html: user-manual.xml $(XSLT)
406 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
407 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
410 git.info: user-manual.texi
411 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
413 user-manual.texi: user-manual.xml
414 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
415 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
416 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
420 user-manual.pdf: user-manual.xml
421 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
422 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
425 gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
426 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
427 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
428 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
429 rm $(xml)+ &&) true) > $@++ && \
430 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
434 gitman.info: gitman.texi
435 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
437 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
438 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
439 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
442 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
443 $(QUIET_GEN)$(RM) $@+ $@ && \
444 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
447 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
448 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
450 WEBDOC_DEST = /pub/software/scm/git/docs
452 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
453 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt GIT-ASCIIDOCFLAGS
454 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
455 sed -e '1,/^$$/d' $< | \
456 $(TXT_TO_HTML) - >$@+ && \
459 install-webdoc : html
460 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
462 # You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
463 # next to the 'git' repository itself for the following to work.
465 quick-install: quick-install-man
468 @if test ! -d $(MAN_REPO); \
469 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
471 quick-install-man: require-manrepo
472 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
475 @if test ! -d $(HTML_REPO); \
476 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
478 quick-install-html: require-htmlrepo
479 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
482 @for i in $(MAN1_TXT); do echo $$i; done
485 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
487 ifeq ($(wildcard po/Makefile),po/Makefile)
488 doc-l10n install-l10n::