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