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