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