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 += gitremote-helpers.txt
16MAN1_TXT += gitweb.txt
17
18MAN5_TXT += gitattributes.txt
19MAN5_TXT += githooks.txt
20MAN5_TXT += gitignore.txt
21MAN5_TXT += gitmodules.txt
22MAN5_TXT += gitrepository-layout.txt
23MAN5_TXT += gitweb.conf.txt
24
25MAN7_TXT += gitcli.txt
26MAN7_TXT += gitcore-tutorial.txt
27MAN7_TXT += gitcredentials.txt
28MAN7_TXT += gitcvs-migration.txt
29MAN7_TXT += gitdiffcore.txt
30MAN7_TXT += giteveryday.txt
31MAN7_TXT += gitglossary.txt
32MAN7_TXT += gitnamespaces.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 += MyFirstContribution
77TECH_DOCS += SubmittingPatches
78TECH_DOCS += technical/hash-function-transition
79TECH_DOCS += technical/http-protocol
80TECH_DOCS += technical/index-format
81TECH_DOCS += technical/long-running-process-protocol
82TECH_DOCS += technical/multi-pack-index
83TECH_DOCS += technical/pack-format
84TECH_DOCS += technical/pack-heuristics
85TECH_DOCS += technical/pack-protocol
86TECH_DOCS += technical/partial-clone
87TECH_DOCS += technical/protocol-capabilities
88TECH_DOCS += technical/protocol-common
89TECH_DOCS += technical/protocol-v2
90TECH_DOCS += technical/racy-git
91TECH_DOCS += technical/send-pack-pipeline
92TECH_DOCS += technical/shallow
93TECH_DOCS += technical/signature-format
94TECH_DOCS += technical/trivial-merge
95SP_ARTICLES += $(TECH_DOCS)
96SP_ARTICLES += technical/api-index
97
98ARTICLES_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
99HTML_FILTER ?= $(ARTICLES_HTML) $(OBSOLETE_HTML)
100DOC_HTML = $(MAN_HTML) $(filter $(HTML_FILTER),$(ARTICLES_HTML) $(OBSOLETE_HTML))
101
102DOC_MAN1 = $(patsubst %.txt,%.1,$(filter $(MAN_FILTER),$(MAN1_TXT)))
103DOC_MAN5 = $(patsubst %.txt,%.5,$(filter $(MAN_FILTER),$(MAN5_TXT)))
104DOC_MAN7 = $(patsubst %.txt,%.7,$(filter $(MAN_FILTER),$(MAN7_TXT)))
105
106prefix ?= $(HOME)
107bindir ?= $(prefix)/bin
108htmldir ?= $(prefix)/share/doc/git-doc
109infodir ?= $(prefix)/share/info
110pdfdir ?= $(prefix)/share/doc/git-doc
111mandir ?= $(prefix)/share/man
112man1dir = $(mandir)/man1
113man5dir = $(mandir)/man5
114man7dir = $(mandir)/man7
115# DESTDIR =
116
117ASCIIDOC = asciidoc
118ASCIIDOC_EXTRA =
119ASCIIDOC_HTML = xhtml11
120ASCIIDOC_DOCBOOK = docbook
121ASCIIDOC_CONF = -f asciidoc.conf
122ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
123 -agit_version=$(GIT_VERSION)
124TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
125TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
126MANPAGE_XSL = manpage-normal.xsl
127XMLTO = xmlto
128XMLTO_EXTRA =
129INSTALL ?= install
130RM ?= rm -f
131MAN_REPO = ../../git-manpages
132HTML_REPO = ../../git-htmldocs
133
134MAKEINFO = makeinfo
135INSTALL_INFO = install-info
136DOCBOOK2X_TEXI = docbook2x-texi
137DBLATEX = dblatex
138ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
139DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
140ifndef PERL_PATH
141 PERL_PATH = /usr/bin/perl
142endif
143
144-include ../config.mak.autogen
145-include ../config.mak
146
147#
148# For docbook-xsl ...
149# -1.68.1, no extra settings are needed?
150# 1.69.0, set ASCIIDOC_ROFF?
151# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
152# 1.71.1, set ASCIIDOC_ROFF?
153# 1.72.0, set DOCBOOK_XSL_172.
154# 1.73.0-, no extra settings are needed
155#
156
157ifdef DOCBOOK_XSL_172
158ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
159MANPAGE_XSL = manpage-1.72.xsl
160else
161 ifndef ASCIIDOC_ROFF
162 # docbook-xsl after 1.72 needs the regular XSL, but will not
163 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
164 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
165 endif
166endif
167ifndef NO_MAN_BOLD_LITERAL
168XMLTO_EXTRA += -m manpage-bold-literal.xsl
169endif
170ifdef DOCBOOK_SUPPRESS_SP
171XMLTO_EXTRA += -m manpage-suppress-sp.xsl
172endif
173
174# Newer DocBook stylesheet emits warning cruft in the output when
175# this is not set, and if set it shows an absolute link. Older
176# stylesheets simply ignore this parameter.
177#
178# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
179# or similar.
180ifndef MAN_BASE_URL
181MAN_BASE_URL = file://$(htmldir)/
182endif
183XMLTO_EXTRA += -m manpage-base-url.xsl
184
185# If your target system uses GNU groff, it may try to render
186# apostrophes as a "pretty" apostrophe using unicode. This breaks
187# cut&paste, so you should set GNU_ROFF to force them to be ASCII
188# apostrophes. Unfortunately does not work with non-GNU roff.
189ifdef GNU_ROFF
190XMLTO_EXTRA += -m manpage-quote-apos.xsl
191endif
192
193ifdef USE_ASCIIDOCTOR
194ASCIIDOC = asciidoctor
195ASCIIDOC_CONF =
196ASCIIDOC_HTML = xhtml5
197ASCIIDOC_DOCBOOK = docbook45
198ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
199ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
200ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
201DBLATEX_COMMON =
202endif
203
204SHELL_PATH ?= $(SHELL)
205# Shell quote;
206SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
207
208ifdef DEFAULT_PAGER
209DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
210ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
211endif
212
213ifdef DEFAULT_EDITOR
214DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
215ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
216endif
217
218QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
219QUIET_SUBDIR1 =
220
221ifneq ($(findstring $(MAKEFLAGS),w),w)
222PRINT_DIR = --no-print-directory
223else # "make -w"
224NO_SUBDIR = :
225endif
226
227ifneq ($(findstring $(MAKEFLAGS),s),s)
228ifndef V
229 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
230 QUIET_XMLTO = @echo ' ' XMLTO $@;
231 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
232 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
233 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
234 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
235 QUIET_GEN = @echo ' ' GEN $@;
236 QUIET_LINT = @echo ' ' LINT $@;
237 QUIET_STDERR = 2> /dev/null
238 QUIET_SUBDIR0 = +@subdir=
239 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
240 $(MAKE) $(PRINT_DIR) -C $$subdir
241 export V
242endif
243endif
244
245all: html man
246
247html: $(DOC_HTML)
248
249man: man1 man5 man7
250man1: $(DOC_MAN1)
251man5: $(DOC_MAN5)
252man7: $(DOC_MAN7)
253
254info: git.info gitman.info
255
256pdf: user-manual.pdf
257
258install: install-man
259
260install-man: man
261 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
262 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
263 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
264 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
265 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
266 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
267
268install-info: info
269 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
270 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
271 if test -r $(DESTDIR)$(infodir)/dir; then \
272 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
273 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
274 else \
275 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
276 fi
277
278install-pdf: pdf
279 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
280 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
281
282install-html: html
283 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
284
285../GIT-VERSION-FILE: FORCE
286 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
287
288-include ../GIT-VERSION-FILE
289
290#
291# Determine "include::" file references in asciidoc files.
292#
293docdep_prereqs = \
294 mergetools-list.made $(mergetools_txt) \
295 cmd-list.made $(cmds_txt)
296
297doc.dep : $(docdep_prereqs) $(wildcard *.txt) $(wildcard config/*.txt) build-docdep.perl
298 $(QUIET_GEN)$(RM) $@+ $@ && \
299 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
300 mv $@+ $@
301
302-include doc.dep
303
304cmds_txt = cmds-ancillaryinterrogators.txt \
305 cmds-ancillarymanipulators.txt \
306 cmds-mainporcelain.txt \
307 cmds-plumbinginterrogators.txt \
308 cmds-plumbingmanipulators.txt \
309 cmds-synchingrepositories.txt \
310 cmds-synchelpers.txt \
311 cmds-purehelpers.txt \
312 cmds-foreignscminterface.txt
313
314$(cmds_txt): cmd-list.made
315
316cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
317 $(QUIET_GEN)$(RM) $@ && \
318 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
319 date >$@
320
321mergetools_txt = mergetools-diff.txt mergetools-merge.txt
322
323$(mergetools_txt): mergetools-list.made
324
325mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
326 $(QUIET_GEN)$(RM) $@ && \
327 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
328 . ../git-mergetool--lib.sh && \
329 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
330 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
331 . ../git-mergetool--lib.sh && \
332 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
333 date >$@
334
335TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
336
337GIT-ASCIIDOCFLAGS: FORCE
338 @FLAGS='$(TRACK_ASCIIDOCFLAGS)'; \
339 if test x"$$FLAGS" != x"`cat GIT-ASCIIDOCFLAGS 2>/dev/null`" ; then \
340 echo >&2 " * new asciidoc flags"; \
341 echo "$$FLAGS" >GIT-ASCIIDOCFLAGS; \
342 fi
343
344clean:
345 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
346 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
347 $(RM) *.pdf
348 $(RM) howto-index.txt howto/*.html doc.dep
349 $(RM) technical/*.html technical/api-index.txt
350 $(RM) SubmittingPatches.txt
351 $(RM) $(cmds_txt) $(mergetools_txt) *.made
352 $(RM) manpage-base-url.xsl
353 $(RM) GIT-ASCIIDOCFLAGS
354
355$(MAN_HTML): %.html : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
356 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
357 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
358 mv $@+ $@
359
360$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
361 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
362 $(TXT_TO_HTML) -o $@+ $< && \
363 mv $@+ $@
364
365manpage-base-url.xsl: manpage-base-url.xsl.in
366 $(QUIET_GEN)sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
367
368%.1 %.5 %.7 : %.xml manpage-base-url.xsl $(wildcard manpage*.xsl)
369 $(QUIET_XMLTO)$(RM) $@ && \
370 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
371
372%.xml : %.txt asciidoc.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
373 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
374 $(TXT_TO_XML) -d manpage -o $@+ $< && \
375 mv $@+ $@
376
377user-manual.xml: user-manual.txt user-manual.conf asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
378 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
379 $(TXT_TO_XML) -d book -o $@+ $< && \
380 mv $@+ $@
381
382technical/api-index.txt: technical/api-index-skel.txt \
383 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
384 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
385
386technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
387$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
388 asciidoc.conf GIT-ASCIIDOCFLAGS
389 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
390
391SubmittingPatches.txt: SubmittingPatches
392 $(QUIET_GEN) cp $< $@
393
394XSLT = docbook.xsl
395XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
396
397user-manual.html: user-manual.xml $(XSLT)
398 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
399 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
400 mv $@+ $@
401
402git.info: user-manual.texi
403 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
404
405user-manual.texi: user-manual.xml
406 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
407 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
408 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
409 rm $@++ && \
410 mv $@+ $@
411
412user-manual.pdf: user-manual.xml
413 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
414 $(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
415 mv $@+ $@
416
417gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
418 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
419 ($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
420 $(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
421 rm $(xml)+ &&) true) > $@++ && \
422 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
423 rm $@++ && \
424 mv $@+ $@
425
426gitman.info: gitman.texi
427 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
428
429$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
430 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
431 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
432 mv $@+ $@
433
434howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
435 $(QUIET_GEN)$(RM) $@+ $@ && \
436 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
437 mv $@+ $@
438
439$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
440 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
441
442WEBDOC_DEST = /pub/software/scm/git/docs
443
444howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
445$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt GIT-ASCIIDOCFLAGS
446 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
447 sed -e '1,/^$$/d' $< | \
448 $(TXT_TO_HTML) - >$@+ && \
449 mv $@+ $@
450
451install-webdoc : html
452 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
453
454# You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
455# next to the 'git' repository itself for the following to work.
456
457quick-install: quick-install-man
458
459require-manrepo::
460 @if test ! -d $(MAN_REPO); \
461 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
462
463quick-install-man: require-manrepo
464 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) $(GIT_MAN_REF)
465
466require-htmlrepo::
467 @if test ! -d $(HTML_REPO); \
468 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
469
470quick-install-html: require-htmlrepo
471 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir) $(GIT_MAN_REF)
472
473print-man1:
474 @for i in $(MAN1_TXT); do echo $$i; done
475
476lint-docs::
477 $(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl
478
479ifeq ($(wildcard po/Makefile),po/Makefile)
480doc-l10n install-l10n::
481 $(MAKE) -C po $@
482endif
483
484.PHONY: FORCE