1MAN1_TXT= \
2 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
3 $(wildcard git-*.txt)) \
4 gitk.txt git.txt
5MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
6 gitrepository-layout.txt
7MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
8 gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
9 gitdiffcore.txt gitworkflows.txt
10
11MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
12MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
13MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
14
15DOC_HTML=$(MAN_HTML)
16
17ARTICLES = howto-index
18ARTICLES += everyday
19ARTICLES += git-tools
20# with their own formatting rules.
21SP_ARTICLES = howto/revert-branch-rebase howto/using-merge-subtree user-manual
22API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
23SP_ARTICLES += $(API_DOCS)
24SP_ARTICLES += technical/api-index
25
26DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
27
28DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
29DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
30DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
31
32prefix?=$(HOME)
33bindir?=$(prefix)/bin
34htmldir?=$(prefix)/share/doc/git-doc
35pdfdir?=$(prefix)/share/doc/git-doc
36mandir?=$(prefix)/share/man
37man1dir=$(mandir)/man1
38man5dir=$(mandir)/man5
39man7dir=$(mandir)/man7
40# DESTDIR=
41
42ASCIIDOC=asciidoc
43ASCIIDOC_EXTRA =
44MANPAGE_XSL = manpage-normal.xsl
45XMLTO_EXTRA =
46INSTALL?=install
47RM ?= rm -f
48DOC_REF = origin/man
49HTML_REF = origin/html
50
51infodir?=$(prefix)/share/info
52MAKEINFO=makeinfo
53INSTALL_INFO=install-info
54DOCBOOK2X_TEXI=docbook2x-texi
55DBLATEX=dblatex
56ifndef PERL_PATH
57 PERL_PATH = /usr/bin/perl
58endif
59
60-include ../config.mak.autogen
61-include ../config.mak
62
63#
64# For asciidoc ...
65# -7.1.2, no extra settings are needed.
66# 8.0-, set ASCIIDOC8.
67#
68
69#
70# For docbook-xsl ...
71# -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
72# 1.69.0, no extra settings are needed?
73# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
74# 1.71.1, no extra settings are needed?
75# 1.72.0, set DOCBOOK_XSL_172.
76# 1.73.0-, set ASCIIDOC_NO_ROFF
77#
78
79#
80# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
81# of 'the ".ft C" problem' in your generated manpages, and you
82# instead ended up with weird characters around callouts, try
83# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
84#
85
86ifdef ASCIIDOC8
87ASCIIDOC_EXTRA += -a asciidoc7compatible -a no-inline-literal
88endif
89ifdef DOCBOOK_XSL_172
90ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
91MANPAGE_XSL = manpage-1.72.xsl
92else
93 ifdef ASCIIDOC_NO_ROFF
94 # docbook-xsl after 1.72 needs the regular XSL, but will not
95 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
96 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
97 endif
98endif
99ifdef MAN_BOLD_LITERAL
100XMLTO_EXTRA += -m manpage-bold-literal.xsl
101endif
102ifdef DOCBOOK_SUPPRESS_SP
103XMLTO_EXTRA += -m manpage-suppress-sp.xsl
104endif
105
106# Newer DocBook stylesheet emits warning cruft in the output when
107# this is not set, and if set it shows an absolute link. We can
108# use MAN_BASE_URL=http://www.kernel.org/pub/software/scm/git/docs/
109# but distros may want to set it to /usr/share/doc/git-core/docs/ or
110# something like that.
111XMLTO_EXTRA += --stringparam man.base.url.for.relative.links=$(MAN_BASE_URL)
112
113# If your target system uses GNU groff, it may try to render
114# apostrophes as a "pretty" apostrophe using unicode. This breaks
115# cut&paste, so you should set GNU_ROFF to force them to be ASCII
116# apostrophes. Unfortunately does not work with non-GNU roff.
117ifdef GNU_ROFF
118XMLTO_EXTRA += -m manpage-quote-apos.xsl
119endif
120
121SHELL_PATH ?= $(SHELL)
122# Shell quote;
123SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
124
125#
126# Please note that there is a minor bug in asciidoc.
127# The version after 6.0.3 _will_ include the patch found here:
128# http://marc.theaimsgroup.com/?l=git&m=111558757202243&w=2
129#
130# Until that version is released you may have to apply the patch
131# yourself - yes, all 6 characters of it!
132#
133
134QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
135QUIET_SUBDIR1 =
136
137ifneq ($(findstring $(MAKEFLAGS),w),w)
138PRINT_DIR = --no-print-directory
139else # "make -w"
140NO_SUBDIR = :
141endif
142
143ifneq ($(findstring $(MAKEFLAGS),s),s)
144ifndef V
145 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
146 QUIET_XMLTO = @echo ' ' XMLTO $@;
147 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
148 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
149 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
150 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
151 QUIET_GEN = @echo ' ' GEN $@;
152 QUIET_STDERR = 2> /dev/null
153 QUIET_SUBDIR0 = +@subdir=
154 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
155 $(MAKE) $(PRINT_DIR) -C $$subdir
156 export V
157endif
158endif
159
160all: html man
161
162html: $(DOC_HTML)
163
164$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
165
166man: man1 man5 man7
167man1: $(DOC_MAN1)
168man5: $(DOC_MAN5)
169man7: $(DOC_MAN7)
170
171info: git.info gitman.info
172
173pdf: user-manual.pdf
174
175install: install-man
176
177install-man: man
178 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
179 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
180 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
181 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
182 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
183 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
184
185install-info: info
186 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
187 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
188 if test -r $(DESTDIR)$(infodir)/dir; then \
189 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
190 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
191 else \
192 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
193 fi
194
195install-pdf: pdf
196 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
197 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
198
199install-html: html
200 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
201
202../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
203 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
204
205-include ../GIT-VERSION-FILE
206
207#
208# Determine "include::" file references in asciidoc files.
209#
210doc.dep : $(wildcard *.txt) build-docdep.perl
211 $(QUIET_GEN)$(RM) $@+ $@ && \
212 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
213 mv $@+ $@
214
215-include doc.dep
216
217cmds_txt = cmds-ancillaryinterrogators.txt \
218 cmds-ancillarymanipulators.txt \
219 cmds-mainporcelain.txt \
220 cmds-plumbinginterrogators.txt \
221 cmds-plumbingmanipulators.txt \
222 cmds-synchingrepositories.txt \
223 cmds-synchelpers.txt \
224 cmds-purehelpers.txt \
225 cmds-foreignscminterface.txt
226
227$(cmds_txt): cmd-list.made
228
229cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
230 $(QUIET_GEN)$(RM) $@ && \
231 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
232 date >$@
233
234clean:
235 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
236 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
237 $(RM) howto-index.txt howto/*.html doc.dep
238 $(RM) technical/api-*.html technical/api-index.txt
239 $(RM) $(cmds_txt) *.made
240
241$(MAN_HTML): %.html : %.txt
242 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
243 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
244 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
245 mv $@+ $@
246
247%.1 %.5 %.7 : %.xml
248 $(QUIET_XMLTO)$(RM) $@ && \
249 xmlto -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
250
251%.xml : %.txt
252 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
253 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
254 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
255 mv $@+ $@
256
257user-manual.xml: user-manual.txt user-manual.conf
258 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book $<
259
260technical/api-index.txt: technical/api-index-skel.txt \
261 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
262 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
263
264$(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
265 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
266 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
267
268XSLT = docbook.xsl
269XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
270
271user-manual.html: user-manual.xml
272 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
273
274git.info: user-manual.texi
275 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
276
277user-manual.texi: user-manual.xml
278 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
279 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
280 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
281 rm $@++ && \
282 mv $@+ $@
283
284user-manual.pdf: user-manual.xml
285 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
286 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
287 mv $@+ $@
288
289gitman.texi: $(MAN_XML) cat-texi.perl
290 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
291 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
292 --to-stdout $(xml) &&) true) > $@++ && \
293 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
294 rm $@++ && \
295 mv $@+ $@
296
297gitman.info: gitman.texi
298 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
299
300$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
301 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
302 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
303 mv $@+ $@
304
305howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
306 $(QUIET_GEN)$(RM) $@+ $@ && \
307 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
308 mv $@+ $@
309
310$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
311 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
312
313WEBDOC_DEST = /pub/software/scm/git/docs
314
315$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
316 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
317 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
318 mv $@+ $@
319
320install-webdoc : html
321 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
322
323quick-install: quick-install-man
324
325quick-install-man:
326 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
327
328quick-install-html:
329 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
330
331.PHONY: .FORCE-GIT-VERSION-FILE