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
84pdfdir?=$(prefix)/share/doc/git-doc
85mandir?=$(prefix)/share/man
86man1dir=$(mandir)/man1
87man5dir=$(mandir)/man5
88man7dir=$(mandir)/man7
89# DESTDIR=
90
91ASCIIDOC = asciidoc
92ASCIIDOC_EXTRA =
93MANPAGE_XSL = manpage-normal.xsl
94XMLTO = xmlto
95XMLTO_EXTRA =
96INSTALL?=install
97RM ?= rm -f
98MAN_REPO = ../../git-manpages
99HTML_REPO = ../../git-htmldocs
100
101infodir?=$(prefix)/share/info
102MAKEINFO=makeinfo
103INSTALL_INFO=install-info
104DOCBOOK2X_TEXI=docbook2x-texi
105DBLATEX=dblatex
106ifndef PERL_PATH
107 PERL_PATH = /usr/bin/perl
108endif
109
110-include ../config.mak.autogen
111-include ../config.mak
112
113#
114# For docbook-xsl ...
115# -1.68.1, no extra settings are needed?
116# 1.69.0, set ASCIIDOC_ROFF?
117# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
118# 1.71.1, set ASCIIDOC_ROFF?
119# 1.72.0, set DOCBOOK_XSL_172.
120# 1.73.0-, no extra settings are needed
121#
122
123ifdef DOCBOOK_XSL_172
124ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
125MANPAGE_XSL = manpage-1.72.xsl
126else
127 ifndef ASCIIDOC_ROFF
128 # docbook-xsl after 1.72 needs the regular XSL, but will not
129 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
130 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
131 endif
132endif
133ifdef MAN_BOLD_LITERAL
134XMLTO_EXTRA += -m manpage-bold-literal.xsl
135endif
136ifdef DOCBOOK_SUPPRESS_SP
137XMLTO_EXTRA += -m manpage-suppress-sp.xsl
138endif
139
140# Newer DocBook stylesheet emits warning cruft in the output when
141# this is not set, and if set it shows an absolute link. Older
142# stylesheets simply ignore this parameter.
143#
144# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
145# or similar.
146ifndef MAN_BASE_URL
147MAN_BASE_URL = file://$(htmldir)/
148endif
149XMLTO_EXTRA += -m manpage-base-url.xsl
150
151# If your target system uses GNU groff, it may try to render
152# apostrophes as a "pretty" apostrophe using unicode. This breaks
153# cut&paste, so you should set GNU_ROFF to force them to be ASCII
154# apostrophes. Unfortunately does not work with non-GNU roff.
155ifdef GNU_ROFF
156XMLTO_EXTRA += -m manpage-quote-apos.xsl
157endif
158
159SHELL_PATH ?= $(SHELL)
160# Shell quote;
161SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
162
163ifdef DEFAULT_PAGER
164DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
165ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
166endif
167
168ifdef DEFAULT_EDITOR
169DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
170ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
171endif
172
173QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
174QUIET_SUBDIR1 =
175
176ifneq ($(findstring $(MAKEFLAGS),w),w)
177PRINT_DIR = --no-print-directory
178else # "make -w"
179NO_SUBDIR = :
180endif
181
182ifneq ($(findstring $(MAKEFLAGS),s),s)
183ifndef V
184 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
185 QUIET_XMLTO = @echo ' ' XMLTO $@;
186 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
187 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
188 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
189 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
190 QUIET_GEN = @echo ' ' GEN $@;
191 QUIET_STDERR = 2> /dev/null
192 QUIET_SUBDIR0 = +@subdir=
193 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
194 $(MAKE) $(PRINT_DIR) -C $$subdir
195 export V
196endif
197endif
198
199all: html man
200
201html: $(DOC_HTML)
202
203man: man1 man5 man7
204man1: $(DOC_MAN1)
205man5: $(DOC_MAN5)
206man7: $(DOC_MAN7)
207
208info: git.info gitman.info
209
210pdf: user-manual.pdf
211
212install: install-man
213
214install-man: man
215 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
216 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
217 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
218 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
219 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
220 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
221
222install-info: info
223 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
224 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
225 if test -r $(DESTDIR)$(infodir)/dir; then \
226 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
227 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
228 else \
229 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
230 fi
231
232install-pdf: pdf
233 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
234 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
235
236install-html: html
237 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
238
239../GIT-VERSION-FILE: FORCE
240 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
241
242-include ../GIT-VERSION-FILE
243
244#
245# Determine "include::" file references in asciidoc files.
246#
247doc.dep : $(wildcard *.txt) build-docdep.perl
248 $(QUIET_GEN)$(RM) $@+ $@ && \
249 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
250 mv $@+ $@
251
252-include doc.dep
253
254cmds_txt = cmds-ancillaryinterrogators.txt \
255 cmds-ancillarymanipulators.txt \
256 cmds-mainporcelain.txt \
257 cmds-plumbinginterrogators.txt \
258 cmds-plumbingmanipulators.txt \
259 cmds-synchingrepositories.txt \
260 cmds-synchelpers.txt \
261 cmds-purehelpers.txt \
262 cmds-foreignscminterface.txt
263
264$(cmds_txt): cmd-list.made
265
266cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
267 $(QUIET_GEN)$(RM) $@ && \
268 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
269 date >$@
270
271clean:
272 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
273 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
274 $(RM) *.pdf
275 $(RM) howto-index.txt howto/*.html doc.dep
276 $(RM) technical/*.html technical/api-index.txt
277 $(RM) $(cmds_txt) *.made
278 $(RM) manpage-base-url.xsl
279
280$(MAN_HTML): %.html : %.txt asciidoc.conf
281 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
282 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
283 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
284 mv $@+ $@
285
286$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
287 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
288 $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
289 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
290 mv $@+ $@
291
292manpage-base-url.xsl: manpage-base-url.xsl.in
293 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
294
295%.1 %.5 %.7 : %.xml manpage-base-url.xsl
296 $(QUIET_XMLTO)$(RM) $@ && \
297 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
298
299%.xml : %.txt asciidoc.conf
300 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
301 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
302 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
303 mv $@+ $@
304
305user-manual.xml: user-manual.txt user-manual.conf
306 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
307 $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
308 mv $@+ $@
309
310technical/api-index.txt: technical/api-index-skel.txt \
311 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
312 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
313
314technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
315$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
316 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
317 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
318
319XSLT = docbook.xsl
320XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
321
322user-manual.html: user-manual.xml $(XSLT)
323 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
324 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
325 mv $@+ $@
326
327git.info: user-manual.texi
328 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
329
330user-manual.texi: user-manual.xml
331 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
332 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
333 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
334 rm $@++ && \
335 mv $@+ $@
336
337user-manual.pdf: user-manual.xml
338 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
339 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
340 mv $@+ $@
341
342gitman.texi: $(MAN_XML) cat-texi.perl
343 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
344 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
345 --to-stdout $(xml) &&) true) > $@++ && \
346 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
347 rm $@++ && \
348 mv $@+ $@
349
350gitman.info: gitman.texi
351 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
352
353$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
354 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
355 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
356 mv $@+ $@
357
358howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
359 $(QUIET_GEN)$(RM) $@+ $@ && \
360 '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
361 mv $@+ $@
362
363$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
364 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
365
366WEBDOC_DEST = /pub/software/scm/git/docs
367
368howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
369$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
370 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
371 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
372 mv $@+ $@
373
374install-webdoc : html
375 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
376
377# You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
378# next to the 'git' repository itself for the following to work.
379
380quick-install: quick-install-man
381
382require-manrepo::
383 @if test ! -d $(MAN_REPO); \
384 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
385
386quick-install-man: require-manrepo
387 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
388
389require-htmlrepo::
390 @if test ! -d $(HTML_REPO); \
391 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
392
393quick-install-html: require-htmlrepo
394 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
395
396print-man1:
397 @for i in $(MAN1_TXT); do echo $$i; done
398
399.PHONY: FORCE