]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
update and add documentation for repository formats
[public-inbox.git] / Documentation / include.mk
1 # Copyright (C) 2013-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <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 # MakeMaker only seems to support manpage sections 1 and 3...
19 m1 =
20 m1 += public-inbox-mda
21 m1 += public-inbox-httpd
22 m1 += public-inbox-nntpd
23 m1 += public-inbox-watch
24 m1 += public-inbox-index
25 m5 =
26 m5 += public-inbox-config
27 m5 += public-inbox-v1-format
28 m5 += public-inbox-v2-format
29 m7 =
30 m7 += public-inbox-overview
31 m8 =
32 m8 += public-inbox-daemon
33
34 man1 := $(addsuffix .1, $(m1))
35 man5 := $(addsuffix .5, $(m5))
36 man7 := $(addsuffix .7, $(m7))
37 man8 := $(addsuffix .8, $(m8))
38
39 all:: man html
40
41 man: $(man1) $(man5) $(man7) $(man8)
42
43 prefix ?= $(PREFIX)
44 prefix ?= $(HOME)
45 mandir ?= $(prefix)/share/man
46 man1dir = $(mandir)/man1
47 man5dir = $(mandir)/man5
48 man7dir = $(mandir)/man7
49 man8dir = $(mandir)/man8
50
51 install-man: man
52         $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
53         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
54         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
55         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
56         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
57         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
58         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
59         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
60
61 doc_install :: install-man
62
63 %.1 %.5 %.7 %.8 : Documentation/%.pod
64         $(podman) -s $(subst .,,$(suffix $@)) $< $@+ && mv $@+ $@
65
66 manuals :=
67 manuals += $(m1)
68 manuals += $(m5)
69 manuals += $(m7)
70 manuals += $(m8)
71
72 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(manuals)))
73 docs += $(mantxt)
74
75 all :: $(mantxt)
76
77 Documentation/%.txt : Documentation/%.pod
78         $(podtext) $< $@+ && mv $@+ $@
79
80 txt2pre = $(PERL) -I lib ./Documentation/txt2pre <$< >$@+ && \
81         touch -r $< $@+ && mv $@+ $@
82 txt := INSTALL README COPYING TODO
83 dtxt := design_notes.txt design_www.txt dc-dlvr-spam-flow.txt hosted.txt
84 dtxt := $(addprefix Documentation/, $(dtxt)) $(mantxt)
85
86 %.html: %.txt
87         TITLE="$(basename $(<F))" $(txt2pre)
88 %.html: %
89         $(txt2pre)
90
91 docs_html := $(addsuffix .html, $(subst .txt,,$(dtxt)) $(txt))
92 html: $(docs_html)
93 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
94 rsync_docs := $(gz_docs) $(docs) $(txt) $(docs_html)
95 %.gz: %
96         gzip -9 --rsyncable <$< >$@+
97         touch -r $< $@+
98         mv $@+ $@
99
100 gz-doc: $(gz_docs)
101 rsync-doc:
102         git set-file-times $(docs) $(txt)
103         $(MAKE) gz-doc
104         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
105 clean-doc:
106         $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html) $(mantxt)
107
108 clean :: clean-doc