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