Merge branch 'mo/cvs-server-cleanup' into next
[git/mjg.git] / Documentation / Makefile
blob267dfe135ddef1d5e6cc452d6fdcd8b22b9e36a2
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
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))
16 DOC_HTML=$(MAN_HTML)
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/revert-branch-rebase
25 SP_ARTICLES += howto/using-merge-subtree
26 SP_ARTICLES += howto/using-signed-tag-in-pull-request
27 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
28 SP_ARTICLES += $(API_DOCS)
29 SP_ARTICLES += technical/api-index
31 DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
33 DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
34 DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
35 DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
37 prefix?=$(HOME)
38 bindir?=$(prefix)/bin
39 htmldir?=$(prefix)/share/doc/git-doc
40 pdfdir?=$(prefix)/share/doc/git-doc
41 mandir?=$(prefix)/share/man
42 man1dir=$(mandir)/man1
43 man5dir=$(mandir)/man5
44 man7dir=$(mandir)/man7
45 # DESTDIR=
47 ASCIIDOC = asciidoc
48 ASCIIDOC_EXTRA =
49 MANPAGE_XSL = manpage-normal.xsl
50 XMLTO = xmlto
51 XMLTO_EXTRA =
52 INSTALL?=install
53 RM ?= rm -f
54 MAN_REPO = ../../git-manpages
55 HTML_REPO = ../../git-htmldocs
57 infodir?=$(prefix)/share/info
58 MAKEINFO=makeinfo
59 INSTALL_INFO=install-info
60 DOCBOOK2X_TEXI=docbook2x-texi
61 DBLATEX=dblatex
62 ifndef PERL_PATH
63 PERL_PATH = /usr/bin/perl
64 endif
66 -include ../config.mak.autogen
67 -include ../config.mak
70 # For docbook-xsl ...
71 # -1.68.1, no extra settings are needed?
72 # 1.69.0, set ASCIIDOC_ROFF?
73 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
74 # 1.71.1, set ASCIIDOC_ROFF?
75 # 1.72.0, set DOCBOOK_XSL_172.
76 # 1.73.0-, no extra settings are needed
79 ifdef DOCBOOK_XSL_172
80 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
81 MANPAGE_XSL = manpage-1.72.xsl
82 else
83 ifndef ASCIIDOC_ROFF
84 # docbook-xsl after 1.72 needs the regular XSL, but will not
85 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
86 ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
87 endif
88 endif
89 ifdef MAN_BOLD_LITERAL
90 XMLTO_EXTRA += -m manpage-bold-literal.xsl
91 endif
92 ifdef DOCBOOK_SUPPRESS_SP
93 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
94 endif
96 # Newer DocBook stylesheet emits warning cruft in the output when
97 # this is not set, and if set it shows an absolute link. Older
98 # stylesheets simply ignore this parameter.
100 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
101 # or similar.
102 ifndef MAN_BASE_URL
103 MAN_BASE_URL = file://$(htmldir)/
104 endif
105 XMLTO_EXTRA += -m manpage-base-url.xsl
107 # If your target system uses GNU groff, it may try to render
108 # apostrophes as a "pretty" apostrophe using unicode. This breaks
109 # cut&paste, so you should set GNU_ROFF to force them to be ASCII
110 # apostrophes. Unfortunately does not work with non-GNU roff.
111 ifdef GNU_ROFF
112 XMLTO_EXTRA += -m manpage-quote-apos.xsl
113 endif
115 SHELL_PATH ?= $(SHELL)
116 # Shell quote;
117 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
119 ifdef DEFAULT_PAGER
120 DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
121 ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
122 endif
124 ifdef DEFAULT_EDITOR
125 DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
126 ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
127 endif
129 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
130 QUIET_SUBDIR1 =
132 ifneq ($(findstring $(MAKEFLAGS),w),w)
133 PRINT_DIR = --no-print-directory
134 else # "make -w"
135 NO_SUBDIR = :
136 endif
138 ifneq ($(findstring $(MAKEFLAGS),s),s)
139 ifndef V
140 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
141 QUIET_XMLTO = @echo ' ' XMLTO $@;
142 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
143 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
144 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
145 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
146 QUIET_GEN = @echo ' ' GEN $@;
147 QUIET_STDERR = 2> /dev/null
148 QUIET_SUBDIR0 = +@subdir=
149 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
150 $(MAKE) $(PRINT_DIR) -C $$subdir
151 export V
152 endif
153 endif
155 all: html man
157 html: $(DOC_HTML)
159 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
161 man: man1 man5 man7
162 man1: $(DOC_MAN1)
163 man5: $(DOC_MAN5)
164 man7: $(DOC_MAN7)
166 info: git.info gitman.info
168 pdf: user-manual.pdf
170 install: install-man
172 install-man: man
173 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
174 $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
175 $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
176 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
177 $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
178 $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
180 install-info: info
181 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
182 $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
183 if test -r $(DESTDIR)$(infodir)/dir; then \
184 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
185 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
186 else \
187 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
190 install-pdf: pdf
191 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
192 $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
194 install-html: html
195 '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
197 ../GIT-VERSION-FILE: FORCE
198 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
200 -include ../GIT-VERSION-FILE
203 # Determine "include::" file references in asciidoc files.
205 doc.dep : $(wildcard *.txt) build-docdep.perl
206 $(QUIET_GEN)$(RM) $@+ $@ && \
207 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
208 mv $@+ $@
210 -include doc.dep
212 cmds_txt = cmds-ancillaryinterrogators.txt \
213 cmds-ancillarymanipulators.txt \
214 cmds-mainporcelain.txt \
215 cmds-plumbinginterrogators.txt \
216 cmds-plumbingmanipulators.txt \
217 cmds-synchingrepositories.txt \
218 cmds-synchelpers.txt \
219 cmds-purehelpers.txt \
220 cmds-foreignscminterface.txt
222 $(cmds_txt): cmd-list.made
224 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
225 $(QUIET_GEN)$(RM) $@ && \
226 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
227 date >$@
229 clean:
230 $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
231 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
232 $(RM) *.pdf
233 $(RM) howto-index.txt howto/*.html doc.dep
234 $(RM) technical/api-*.html technical/api-index.txt
235 $(RM) $(cmds_txt) *.made
236 $(RM) manpage-base-url.xsl
238 $(MAN_HTML): %.html : %.txt
239 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
240 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
241 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
242 mv $@+ $@
244 manpage-base-url.xsl: manpage-base-url.xsl.in
245 sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
247 %.1 %.5 %.7 : %.xml manpage-base-url.xsl
248 $(QUIET_XMLTO)$(RM) $@ && \
249 $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
251 %.xml : %.txt
252 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
253 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
254 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
255 mv $@+ $@
257 user-manual.xml: user-manual.txt user-manual.conf
258 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
259 $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
260 mv $@+ $@
262 technical/api-index.txt: technical/api-index-skel.txt \
263 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
264 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
266 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
267 $(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
268 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
269 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
271 XSLT = docbook.xsl
272 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
274 user-manual.html: user-manual.xml $(XSLT)
275 $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
276 xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
277 mv $@+ $@
279 git.info: user-manual.texi
280 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
282 user-manual.texi: user-manual.xml
283 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
284 $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
285 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
286 rm $@++ && \
287 mv $@+ $@
289 user-manual.pdf: user-manual.xml
290 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
291 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
292 mv $@+ $@
294 gitman.texi: $(MAN_XML) cat-texi.perl
295 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
296 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
297 --to-stdout $(xml) &&) true) > $@++ && \
298 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
299 rm $@++ && \
300 mv $@+ $@
302 gitman.info: gitman.texi
303 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
305 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
306 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
307 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
308 mv $@+ $@
310 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
311 $(QUIET_GEN)$(RM) $@+ $@ && \
312 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
313 mv $@+ $@
315 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
316 $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
318 WEBDOC_DEST = /pub/software/scm/git/docs
320 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
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 # You must have a clone of git-htmldocs and git-manpages repositories
330 # next to the git repository itself for the following to work.
332 quick-install: quick-install-man
334 require-manrepo::
335 @if test ! -d $(MAN_REPO); \
336 then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
338 quick-install-man: require-manrepo
339 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
341 require-htmlrepo::
342 @if test ! -d $(HTML_REPO); \
343 then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
345 quick-install-html: require-htmlrepo
346 '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
348 print-man1:
349 @for i in $(MAN1_TXT); do echo $$i; done
351 .PHONY: FORCE