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