]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
various documentation updates
[public-inbox.git] / Documentation / include.mk
1 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
3 all::
4
5 RSYNC = rsync
6 RSYNC_DEST = public-inbox.org:/srv/public-inbox/
7 docs := README COPYING INSTALL $(shell git ls-files 'Documentation/*.txt')
8 INSTALL = install
9 PANDOC = pandoc
10 PANDOC_OPTS = -f markdown --email-obfuscation=none
11 pandoc = $(PANDOC) $(PANDOC_OPTS)
12
13 m1 =
14 m1 += public-inbox-mda
15 m5 =
16 m7 =
17
18 man1 := $(addsuffix .1, $(m1))
19 man5 := $(addsuffix .5, $(m5))
20 man7 := $(addsuffix .7, $(m7))
21
22 all:: man html
23
24 man: $(man1) $(man5) $(man7)
25
26 prefix ?= $(HOME)
27 mandir ?= $(prefix)/share/man
28 man1dir = $(mandir)/man1
29 man5dir = $(mandir)/man5
30 man7dir = $(mandir)/man7
31
32 install-man: man
33         test -z "$(man1)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
34         test -z "$(man5)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
35         test -z "$(man7)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
36         test -z "$(man1)" || $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
37         test -z "$(man5)" || $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
38         test -z "$(man7)" || $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
39 %.1 %.5 %.7 : Documentation/%.txt
40         $(pandoc) -s -t man < $< > $@+ && mv $@+ $@
41
42 txt2pre = ./Documentation/txt2pre < $< > $@+ && touch -r $< $@+ && mv $@+ $@
43 txt = INSTALL README COPYING
44
45 INSTALL.html: INSTALL
46         $(txt2pre)
47 index.html: README
48         $(txt2pre)
49
50 docs_html := index.html INSTALL.html
51 html: $(docs_html)
52 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
53 rsync_docs := $(gz_docs) $(docs) $(txt) $(docs_html)
54 %.gz: %
55         gzip -9 --rsyncable < $< > $@+
56         touch -r $< $@+
57         mv $@+ $@
58
59 gz-doc: $(gz_docs)
60 rsync-doc:
61         git set-file-times $(docs) $(txt)
62         $(MAKE) gz-doc
63         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
64 clean-doc:
65         $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html)