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