1# Guard against environment variables
2MAN1_TXT =
3MAN5_TXT =
4MAN7_TXT =
5TECH_DOCS =
6ARTICLES =
7SP_ARTICLES =
8OBSOLETE_HTML =
9
10MAN1_TXT += $(filter-out \
11 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
12 $(wildcard git-*.txt))
13MAN1_TXT += git.txt
14MAN1_TXT += gitk.txt
15MAN1_TXT += gitweb.txt
16
17MAN5_TXT += gitattributes.txt
18MAN5_TXT += githooks.txt
19MAN5_TXT += gitignore.txt
20MAN5_TXT += gitmodules.txt
21MAN5_TXT += gitrepository-layout.txt
22MAN5_TXT += gitweb.conf.txt
23
24MAN7_TXT += gitcli.txt
25MAN7_TXT += gitcore-tutorial.txt
26MAN7_TXT += gitcredentials.txt
27MAN7_TXT += gitcvs-migration.txt
28MAN7_TXT += gitdiffcore.txt
29MAN7_TXT += giteveryday.txt
30MAN7_TXT += gitglossary.txt
31MAN7_TXT += gitnamespaces.txt
32MAN7_TXT += gitremote-helpers.txt
33MAN7_TXT += gitrevisions.txt
34MAN7_TXT += gitsubmodules.txt
35MAN7_TXT += gittutorial-2.txt
36MAN7_TXT += gittutorial.txt
37MAN7_TXT += gitworkflows.txt
38
39ifdef MAN_FILTER
40MAN_TXT = $(filter $(MAN_FILTER),$(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT))
41else
42MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
43MAN_FILTER = $(MAN_TXT)
44endif
45
46MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
47MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
48GIT_MAN_REF = master
49
50OBSOLETE_HTML += everyday.html
51OBSOLETE_HTML += git-remote-helpers.html
52
53ARTICLES += howto-index
54ARTICLES += git-tools
55ARTICLES += git-bisect-lk2009
56# with their own formatting rules.
57SP_ARTICLES += user-manual
58SP_ARTICLES += howto/new-command
59SP_ARTICLES += howto/revert-branch-rebase
60SP_ARTICLES += howto/using-merge-subtree
61SP_ARTICLES += howto/using-signed-tag-in-pull-request
62SP_ARTICLES += howto/use-git-daemon
63SP_ARTICLES += howto/update-hook-example
64SP_ARTICLES += howto/setup-git-server-over-http
65SP_ARTICLES += howto/separating-topic-branches
66SP_ARTICLES += howto/revert-a-faulty-merge
67SP_ARTICLES += howto/recover-corrupted-blob-object
68SP_ARTICLES += howto/recover-corrupted-object-harder
69SP_ARTICLES += howto/rebuild-from-update-hook
70SP_ARTICLES += howto/rebase-from-internal-branch
71SP_ARTICLES += howto/keep-canonical-history-correct
72SP_ARTICLES += howto/maintain-git
73API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
74SP_ARTICLES += $(API_DOCS)
75
76TECH_DOCS += SubmittingPatches
77TECH_DOCS += technical/hash-function-transition
78TECH_DOCS += technical/http-protocol
79TECH_DOCS += technical/index-format
80TECH_DOCS += technical/long-running-process-protocol
81TECH_DOCS += technical/multi-pack-index
82TECH_DOCS += technical/pack-format
83TECH_DOCS += technical/pack-heuristics
84TECH_DOCS += technical/pack-protocol
85TECH_DOCS += technical/partial-clone
86TECH_DOCS += technical/protocol-capabilities
87TECH_DOCS += technical/protocol-common
88TECH_DOCS += technical/protocol-v2
89TECH_DOCS += technical/racy-git
90TECH_DOCS += technical/send-pack-pipeline
91TECH_DOCS += technical/shallow
92TECH_DOCS += technical/signature-format
93TECH_DOCS += technical/trivial-merge
94SP_ARTICLES += $(TECH_DOCS)
95SP_ARTICLES += technical/api-index
96
97ARTICLES_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
98HTML_FILTER ?= $(ARTICLES_HTML) $(OBSOLETE_HTML)
99DOC_HTML = $(MAN_HTML) $(filter $(HTML_FILTER),$(ARTICLES_HTML) $(OBSOLETE_HTML))
100
101DOC_MAN1 = $(patsubst %.txt,%.1,$(filter $(MAN_FILTER),$(MAN1_TXT)))
102DOC_MAN5 = $(patsubst %.txt,%.5,$(filter $(MAN_FILTER),$(MAN5_TXT)))
103DOC_MAN7 = $(patsubst %.txt,%.7,$(filter $(MAN_FILTER),$(MAN7_TXT)))
104
105prefix ?= $(HOME)
106bindir ?= $(prefix)/bin
107htmldir ?= $(prefix)/share/doc/git-doc
108infodir ?= $(prefix)/share/info
109pdfdir ?= $(prefix)/share/doc/git-doc
110mandir ?= $(prefix)/share/man
111man1dir = $(mandir)/man1
112man5dir = $(mandir)/man5
113man7dir = $(mandir)/man7
114# DESTDIR =
115
116ASCIIDOC = asciidoc
117ASCIIDOC_EXTRA =
118ASCIIDOC_HTML = xhtml11
119ASCIIDOC_DOCBOOK = docbook
120ASCIIDOC_CONF = -f asciidoc.conf
121ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
122 -agit_version=$(GIT_VERSION)
123TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
124TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
125MANPAGE_XSL = manpage-normal.xsl
126XMLTO = xmlto
127XMLTO_EXTRA =
128INSTALL ?= install
129RM ?= rm -f
130MAN_REPO = ../../git-manpages
131HTML_REPO = ../../git-htmldocs
132
133MAKEINFO = makeinfo
134INSTALL_INFO = install-info
135DOCBOOK2X_TEXI = docbook2x-texi
136DBLATEX = dblatex
137ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
138DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
139ifndef PERL_PATH
140 PERL_PATH = /usr/bin/perl
141endif
142
143-include ../config.mak.autogen
144-include ../config.mak
145
146#
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
154#
155
156ifdef DOCBOOK_XSL_172
157ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
158MANPAGE_XSL = manpage-1.72.xsl
159else
160 ifndef ASCIIDOC_ROFF
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
164 endif
165endif
166ifndef NO_MAN_BOLD_LITERAL
167XMLTO_EXTRA += -m manpage-bold-literal.xsl
168endif
169ifdef DOCBOOK_SUPPRESS_SP
170XMLTO_EXTRA += -m manpage-suppress-sp.xsl
171endif
172
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.
176#
177# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
178# or similar.
179ifndef MAN_BASE_URL
180MAN_BASE_URL = file://$(htmldir)/
181endif
182XMLTO_EXTRA += -m manpage-base-url.xsl
183
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.
188ifdef GNU_ROFF
189XMLTO_EXTRA += -m manpage-quote-apos.xsl
190endif
191
192ifdef USE_ASCIIDOCTOR
193ASCIIDOC = asciidoctor
194ASCIIDOC_CONF =
195ASCIIDOC_HTML = xhtml5
196ASCIIDOC_DOCBOOK = docbook45
197ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
198ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
199ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
200DBLATEX_COMMON =
201endif
202
203SHELL_PATH ?= $(SHELL)
204# Shell quote;
205SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
206
207ifdef DEFAULT_PAGER
208DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
209ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
210endif
211
212ifdef DEFAULT_EDITOR
213DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
214ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
215endif
216
217QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
218QUIET_SUBDIR1 =
219
220ifneq ($(findstring $(MAKEFLAGS),w),w)
221PRINT_DIR = --no-print-directory
222else # "make -w"
223NO_SUBDIR = :
224endif
225
226ifneq ($(findstring $(MAKEFLAGS),s),s)
227ifndef V
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
240 export V
241endif
242endif
243
244all: html man
245
246html: $(DOC_HTML)
247
248man: man1 man5 man7
249man1: $(DOC_MAN1)
250man5: $(DOC_MAN5)
251man7: $(DOC_MAN7)
252
253info: git.info gitman.info
254
255pdf: user-manual.pdf
256
257install: install-man
258
259install-man: man
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)
266
267install-info: info
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 ;\
273 else \
274 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
275 fi
276
277install-pdf: pdf
278 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
279 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
280
281install-html: html
282 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
283
284../GIT-VERSION-FILE: FORCE
285 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
286
287-include ../GIT-VERSION-FILE
288
289#
290# Determine "include::" file references in asciidoc files.
291#
292docdep_prereqs = \
293 mergetools-list.made $(mergetools_txt) \
294 cmd-list.made $(cmds_txt)
295
296doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
297 $(QUIET_GEN)$(RM) $@+ $@ && \
298 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
299 mv $@+ $@
300
301-include doc.dep
302
303cmds_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
312
313$(cmds_txt): cmd-list.made
314
315cmd-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) && \
318 date >$@
319
320mergetools_txt = mergetools-diff.txt mergetools-merge.txt
321
322$(mergetools_txt): mergetools-list.made
323
324mergetools-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 && \
332 date >$@
333
334TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
335
336GIT-ASCIIDOCFLAGS: FORCE
337 @FLAGS='$(TRACK_ASCIIDOCFLAGS)'; \
338 if test x"$$FLAGS" != x"`cat GIT-ASCIIDOCFLAGS 2>/dev/null`" ; then \
339 echo >&2 " * new asciidoc flags"; \
340 echo "$$FLAGS" >GIT-ASCIIDOCFLAGS; \
341 fi
342
343clean:
344 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
345 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
346 $(RM) *.pdf
347 $(RM) howto-index.txt howto/*.html doc.dep
348 $(RM) technical/*.html technical/api-index.txt
349 $(RM) SubmittingPatches.txt
350 $(RM) $(cmds_txt) $(mergetools_txt) *.made
351 $(RM) manpage-base-url.xsl
352 $(RM) GIT-ASCIIDOCFLAGS
353
354$(MAN_HTML): %.html : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
355 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
356 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
357 mv $@+ $@
358
359$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
360 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
361 $(TXT_TO_HTML) -o $@+ $< && \
362 mv $@+ $@
363
364manpage-base-url.xsl: manpage-base-url.xsl.in
365 $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
366
367%.1 %.5 %.7 : %.xml manpage-base-url.xsl $(wildcard manpage*.xsl)
368 $(QUIET_XMLTO)$(RM) $@ && \
369 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
370
371%.xml : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
372 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
373 $(TXT_TO_XML) -d manpage -o $@+ $< && \
374 mv $@+ $@
375
376user-manual.xml: user-manual.txt user-manual.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
377 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
378 $(TXT_TO_XML) -d book -o $@+ $< && \
379 mv $@+ $@
380
381technical/api-index.txt: technical/api-index-skel.txt \
382 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
383 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
384
385technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
386$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
387 asciidoc.conf GIT-ASCIIDOCFLAGS
388 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
389
390SubmittingPatches.txt: SubmittingPatches
391 $(QUIET_GEN) cp $< $@
392
393XSLT = docbook.xsl
394XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
395
396user-manual.html: user-manual.xml $(XSLT)
397 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
398 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
399 mv $@+ $@
400
401git.info: user-manual.texi
402 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
403
404user-manual.texi: user-manual.xml
405 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
406 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
407 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
408 rm $@++ && \
409 mv $@+ $@
410
411user-manual.pdf: user-manual.xml
412 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
413 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
414 mv $@+ $@
415
416gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
417 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
418 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
419 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
420 rm $(xml)+ &&) true) > $@++ && \
421 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
422 rm $@++ && \
423 mv $@+ $@
424
425gitman.info: gitman.texi
426 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
427
428$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
429 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
430 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
431 mv $@+ $@
432
433howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
434 $(QUIET_GEN)$(RM) $@+ $@ && \
435 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
436 mv $@+ $@
437
438$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
439 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
440
441WEBDOC_DEST = /pub/software/scm/git/docs
442
443howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
444$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt GIT-ASCIIDOCFLAGS
445 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
446 sed -e '1,/^$$/d' $< | \
447 $(TXT_TO_HTML) - >$@+ && \
448 mv $@+ $@
449
450install-webdoc : html
451 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
452
453# You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
454# next to the 'git' repository itself for the following to work.
455
456quick-install: quick-install-man
457
458require-manrepo::
459 @if test ! -d $(MAN_REPO); \
460 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
461
462quick-install-man: require-manrepo
463 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
464
465require-htmlrepo::
466 @if test ! -d $(HTML_REPO); \
467 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
468
469quick-install-html: require-htmlrepo
470 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
471
472print-man1:
473 @for i in $(MAN1_TXT); do echo $$i; done
474
475lint-docs::
476 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
477
478ifeq ($(wildcard po/Makefile),po/Makefile)
479doc-l10n install-l10n::
480 $(MAKE) -C po $@
481endif
482
483.PHONY: FORCE