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