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