1# Guard against environment variables
2MAN1_TXT =
3MAN5_TXT =
4MAN7_TXT =
5TECH_DOCS =
6ARTICLES =
7SP_ARTICLES =
8
9MAN1_TXT += $(filter-out \
10 $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
11 $(wildcard git-*.txt))
12MAN1_TXT += git.txt
13MAN1_TXT += gitk.txt
14MAN1_TXT += gitremote-helpers.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 += gitglossary.txt
30MAN7_TXT += gitnamespaces.txt
31MAN7_TXT += gitrevisions.txt
32MAN7_TXT += gittutorial-2.txt
33MAN7_TXT += gittutorial.txt
34MAN7_TXT += gitworkflows.txt
35
36MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
37MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
38MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
39
40OBSOLETE_HTML = git-remote-helpers.html
41DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
42
43ARTICLES += howto-index
44ARTICLES += everyday
45ARTICLES += git-tools
46ARTICLES += git-bisect-lk2009
47# with their own formatting rules.
48SP_ARTICLES += user-manual
49SP_ARTICLES += howto/new-command
50SP_ARTICLES += howto/revert-branch-rebase
51SP_ARTICLES += howto/using-merge-subtree
52SP_ARTICLES += howto/using-signed-tag-in-pull-request
53SP_ARTICLES += howto/use-git-daemon
54SP_ARTICLES += howto/update-hook-example
55SP_ARTICLES += howto/setup-git-server-over-http
56SP_ARTICLES += howto/separating-topic-branches
57SP_ARTICLES += howto/revert-a-faulty-merge
58SP_ARTICLES += howto/recover-corrupted-blob-object
59SP_ARTICLES += howto/recover-corrupted-object-harder
60SP_ARTICLES += howto/rebuild-from-update-hook
61SP_ARTICLES += howto/rebase-from-internal-branch
62SP_ARTICLES += howto/keep-canonical-history-correct
63SP_ARTICLES += howto/maintain-git
64API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
65SP_ARTICLES += $(API_DOCS)
66
67TECH_DOCS += technical/http-protocol
68TECH_DOCS += technical/index-format
69TECH_DOCS += technical/pack-format
70TECH_DOCS += technical/pack-heuristics
71TECH_DOCS += technical/pack-protocol
72TECH_DOCS += technical/protocol-capabilities
73TECH_DOCS += technical/protocol-common
74TECH_DOCS += technical/racy-git
75TECH_DOCS += technical/send-pack-pipeline
76TECH_DOCS += technical/shallow
77TECH_DOCS += technical/trivial-merge
78SP_ARTICLES += $(TECH_DOCS)
79SP_ARTICLES += technical/api-index
80
81DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
82
83DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
84DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
85DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
86
87prefix ?= $(HOME)
88bindir ?= $(prefix)/bin
89htmldir ?= $(prefix)/share/doc/git-doc
90infodir ?= $(prefix)/share/info
91pdfdir ?= $(prefix)/share/doc/git-doc
92mandir ?= $(prefix)/share/man
93man1dir = $(mandir)/man1
94man5dir = $(mandir)/man5
95man7dir = $(mandir)/man7
96# DESTDIR =
97
98ASCIIDOC = asciidoc
99ASCIIDOC_EXTRA =
100ASCIIDOC_HTML = xhtml11
101ASCIIDOC_DOCBOOK = docbook
102ASCIIDOC_CONF = -f asciidoc.conf
103ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
104 -agit-version=$(GIT_VERSION)
105TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
106TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
107MANPAGE_XSL = manpage-normal.xsl
108XMLTO = xmlto
109XMLTO_EXTRA =
110INSTALL ?= install
111RM ?= rm -f
112MAN_REPO = ../../git-manpages
113HTML_REPO = ../../git-htmldocs
114
115MAKEINFO = makeinfo
116INSTALL_INFO = install-info
117DOCBOOK2X_TEXI = docbook2x-texi
118DBLATEX = dblatex
119ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
120ifndef PERL_PATH
121 PERL_PATH = /usr/bin/perl
122endif
123
124-include ../config.mak.autogen
125-include ../config.mak
126
127#
128# For docbook-xsl ...
129# -1.68.1, no extra settings are needed?
130# 1.69.0, set ASCIIDOC_ROFF?
131# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
132# 1.71.1, set ASCIIDOC_ROFF?
133# 1.72.0, set DOCBOOK_XSL_172.
134# 1.73.0-, no extra settings are needed
135#
136
137ifdef DOCBOOK_XSL_172
138ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
139MANPAGE_XSL = manpage-1.72.xsl
140else
141 ifndef ASCIIDOC_ROFF
142 # docbook-xsl after 1.72 needs the regular XSL, but will not
143 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
144 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
145 endif
146endif
147ifdef MAN_BOLD_LITERAL
148XMLTO_EXTRA += -m manpage-bold-literal.xsl
149endif
150ifdef DOCBOOK_SUPPRESS_SP
151XMLTO_EXTRA += -m manpage-suppress-sp.xsl
152endif
153
154# Newer DocBook stylesheet emits warning cruft in the output when
155# this is not set, and if set it shows an absolute link. Older
156# stylesheets simply ignore this parameter.
157#
158# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
159# or similar.
160ifndef MAN_BASE_URL
161MAN_BASE_URL = file://$(htmldir)/
162endif
163XMLTO_EXTRA += -m manpage-base-url.xsl
164
165# If your target system uses GNU groff, it may try to render
166# apostrophes as a "pretty" apostrophe using unicode. This breaks
167# cut&paste, so you should set GNU_ROFF to force them to be ASCII
168# apostrophes. Unfortunately does not work with non-GNU roff.
169ifdef GNU_ROFF
170XMLTO_EXTRA += -m manpage-quote-apos.xsl
171endif
172
173SHELL_PATH ?= $(SHELL)
174# Shell quote;
175SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
176
177ifdef DEFAULT_PAGER
178DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
179ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
180endif
181
182ifdef DEFAULT_EDITOR
183DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
184ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
185endif
186
187QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
188QUIET_SUBDIR1 =
189
190ifneq ($(findstring $(MAKEFLAGS),w),w)
191PRINT_DIR = --no-print-directory
192else # "make -w"
193NO_SUBDIR = :
194endif
195
196ifneq ($(findstring $(MAKEFLAGS),s),s)
197ifndef V
198 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
199 QUIET_XMLTO = @echo ' ' XMLTO $@;
200 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
201 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
202 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
203 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
204 QUIET_GEN = @echo ' ' GEN $@;
205 QUIET_STDERR = 2> /dev/null
206 QUIET_SUBDIR0 = +@subdir=
207 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
208 $(MAKE) $(PRINT_DIR) -C $$subdir
209 export V
210endif
211endif
212
213all: html man
214
215html: $(DOC_HTML)
216
217man: man1 man5 man7
218man1: $(DOC_MAN1)
219man5: $(DOC_MAN5)
220man7: $(DOC_MAN7)
221
222info: git.info gitman.info
223
224pdf: user-manual.pdf
225
226install: install-man
227
228install-man: man
229 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
230 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
231 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
232 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
233 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
234 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
235
236install-info: info
237 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
238 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
239 if test -r $(DESTDIR)$(infodir)/dir; then \
240 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
241 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
242 else \
243 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
244 fi
245
246install-pdf: pdf
247 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
248 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
249
250install-html: html
251 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
252
253../GIT-VERSION-FILE: FORCE
254 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
255
256-include ../GIT-VERSION-FILE
257
258#
259# Determine "include::" file references in asciidoc files.
260#
261docdep_prereqs = \
262 mergetools-list.made $(mergetools_txt) \
263 cmd-list.made $(cmds_txt)
264
265doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
266 $(QUIET_GEN)$(RM) $@+ $@ && \
267 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
268 mv $@+ $@
269
270-include doc.dep
271
272cmds_txt = cmds-ancillaryinterrogators.txt \
273 cmds-ancillarymanipulators.txt \
274 cmds-mainporcelain.txt \
275 cmds-plumbinginterrogators.txt \
276 cmds-plumbingmanipulators.txt \
277 cmds-synchingrepositories.txt \
278 cmds-synchelpers.txt \
279 cmds-purehelpers.txt \
280 cmds-foreignscminterface.txt
281
282$(cmds_txt): cmd-list.made
283
284cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
285 $(QUIET_GEN)$(RM) $@ && \
286 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
287 date >$@
288
289mergetools_txt = mergetools-diff.txt mergetools-merge.txt
290
291$(mergetools_txt): mergetools-list.made
292
293mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
294 $(QUIET_GEN)$(RM) $@ && \
295 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
296 . ../git-mergetool--lib.sh && \
297 show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
298 $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
299 . ../git-mergetool--lib.sh && \
300 show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
301 date >$@
302
303clean:
304 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
305 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
306 $(RM) *.pdf
307 $(RM) howto-index.txt howto/*.html doc.dep
308 $(RM) technical/*.html technical/api-index.txt
309 $(RM) $(cmds_txt) $(mergetools_txt) *.made
310 $(RM) manpage-base-url.xsl
311
312$(MAN_HTML): %.html : %.txt asciidoc.conf
313 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
314 $(TXT_TO_HTML) -d manpage -o $@+ $< && \
315 mv $@+ $@
316
317$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
318 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
319 $(TXT_TO_HTML) -o $@+ $< && \
320 mv $@+ $@
321
322manpage-base-url.xsl: manpage-base-url.xsl.in
323 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
324
325%.1 %.5 %.7 : %.xml manpage-base-url.xsl
326 $(QUIET_XMLTO)$(RM) $@ && \
327 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
328
329%.xml : %.txt asciidoc.conf
330 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
331 $(TXT_TO_XML) -d manpage -o $@+ $< && \
332 mv $@+ $@
333
334user-manual.xml: user-manual.txt user-manual.conf
335 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
336 $(TXT_TO_XML) -d article -o $@+ $< && \
337 mv $@+ $@
338
339technical/api-index.txt: technical/api-index-skel.txt \
340 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
341 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
342
343technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
344$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
345 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
346
347XSLT = docbook.xsl
348XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
349
350user-manual.html: user-manual.xml $(XSLT)
351 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
352 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
353 mv $@+ $@
354
355git.info: user-manual.texi
356 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
357
358user-manual.texi: user-manual.xml
359 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
360 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
361 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
362 rm $@++ && \
363 mv $@+ $@
364
365user-manual.pdf: user-manual.xml
366 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
367 $(DBLATEX) -o $@+ -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty $< && \
368 mv $@+ $@
369
370gitman.texi: $(MAN_XML) cat-texi.perl
371 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
372 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
373 --to-stdout $(xml) &&) true) > $@++ && \
374 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
375 rm $@++ && \
376 mv $@+ $@
377
378gitman.info: gitman.texi
379 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
380
381$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
382 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
383 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
384 mv $@+ $@
385
386howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
387 $(QUIET_GEN)$(RM) $@+ $@ && \
388 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
389 mv $@+ $@
390
391$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
392 $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
393
394WEBDOC_DEST = /pub/software/scm/git/docs
395
396howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
397$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
398 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
399 sed -e '1,/^$$/d' $< | \
400 $(TXT_TO_HTML) - >$@+ && \
401 mv $@+ $@
402
403install-webdoc : html
404 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
405
406# You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
407# next to the 'git' repository itself for the following to work.
408
409quick-install: quick-install-man
410
411require-manrepo::
412 @if test ! -d $(MAN_REPO); \
413 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
414
415quick-install-man: require-manrepo
416 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
417
418require-htmlrepo::
419 @if test ! -d $(HTML_REPO); \
420 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
421
422quick-install-html: require-htmlrepo
423 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
424
425print-man1:
426 @for i in $(MAN1_TXT); do echo $$i; done
427
428.PHONY: FORCE