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