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