]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
import: document API for public consumption
[public-inbox.git] / Documentation / include.mk
1 # Copyright (C) 2013-2015 all contributors <meta@public-inbox.org>
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 TODO $(shell git ls-files 'Documentation/*.txt')
8 INSTALL = install
9 POD2MAN ?= pod2man
10 POD2MAN_OPTS = -v --stderr -d 1994-10-02 -c 'public-inbox user manual'
11 pod2man = $(POD2MAN) $(POD2MAN_OPTS)
12 POD2TEXT = pod2text
13 POD2TEXT_OPTS = --stderr
14 pod2text = $(POD2TEXT) $(POD2TEXT_OPTS)
15
16 m1 =
17 m1 += public-inbox-mda
18 m5 =
19 m7 =
20
21 man1 := $(addsuffix .1, $(m1))
22 man5 := $(addsuffix .5, $(m5))
23 man7 := $(addsuffix .7, $(m7))
24
25 all:: man html
26
27 man: $(man1) $(man5) $(man7)
28
29 prefix ?= $(HOME)
30 mandir ?= $(prefix)/share/man
31 man1dir = $(mandir)/man1
32 man5dir = $(mandir)/man5
33 man7dir = $(mandir)/man7
34
35 install-man: man
36         test -z "$(man1)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
37         test -z "$(man5)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
38         test -z "$(man7)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
39         test -z "$(man1)" || $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
40         test -z "$(man5)" || $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
41         test -z "$(man7)" || $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
42
43 %.1 : Documentation/%.pod
44         $(pod2man) -s 1 $< $@+ && mv $@+ $@
45
46 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(m1)))
47 docs += $(mantxt)
48
49 all :: $(mantxt)
50
51 Documentation/%.txt : Documentation/%.pod
52         $(pod2text) $< $@+ && mv $@+ $@
53
54 txt2pre = ./Documentation/txt2pre < $< > $@+ && touch -r $< $@+ && mv $@+ $@
55 txt := INSTALL README COPYING TODO
56 dtxt := design_notes.txt design_www.txt dc-dlvr-spam-flow.txt
57 dtxt := $(addprefix Documentation/, $(dtxt)) $(mantxt)
58
59 %.html: %.txt
60         $(txt2pre)
61 %.html: %
62         $(txt2pre)
63
64 docs_html := $(addsuffix .html, $(subst .txt,,$(dtxt)) $(txt))
65 html: $(docs_html)
66 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
67 rsync_docs := $(gz_docs) $(docs) $(txt) $(docs_html)
68 %.gz: %
69         gzip -9 --rsyncable < $< > $@+
70         touch -r $< $@+
71         mv $@+ $@
72
73 gz-doc: $(gz_docs)
74 rsync-doc:
75         git set-file-times $(docs) $(txt)
76         $(MAKE) gz-doc
77         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
78 clean-doc:
79         $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html) $(mantxt)
80
81 clean :: clean-doc