]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
doc/include.mk: remove git use and redundant declarations
[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 # Note: some GNU-isms present and required to build docs
6 # (including manpages), but at least this should not trigger
7 # warnings with BSD make(1) when running "make check"
8 # Maybe it's not worth it to support non-GNU make, though...
9 RSYNC = rsync
10 RSYNC_DEST = public-inbox.org:/srv/public-inbox/
11 txt := INSTALL README COPYING TODO HACKING
12 dtxt := design_notes.txt design_www.txt dc-dlvr-spam-flow.txt hosted.txt
13 dtxt += standards.txt
14 dtxt := $(addprefix Documentation/, $(dtxt))
15 docs := $(txt) $(dtxt)
16
17 INSTALL = install
18 PODMAN = pod2man
19 PODMAN_OPTS = -v --stderr -d 1993-10-02 -c 'public-inbox user manual'
20 PODMAN_OPTS += -r public-inbox.git
21 podman = $(PODMAN) $(PODMAN_OPTS)
22 PODTEXT = pod2text
23 PODTEXT_OPTS = --stderr
24 podtext = $(PODTEXT) $(PODTEXT_OPTS)
25
26 # MakeMaker only seems to support manpage sections 1 and 3...
27 m1 =
28 m1 += public-inbox-mda
29 m1 += public-inbox-httpd
30 m1 += public-inbox-nntpd
31 m1 += public-inbox-watch
32 m1 += public-inbox-index
33 m5 =
34 m5 += public-inbox-config
35 m5 += public-inbox-v1-format
36 m5 += public-inbox-v2-format
37 m7 =
38 m7 += public-inbox-overview
39 m8 =
40 m8 += public-inbox-daemon
41
42 man1 := $(addsuffix .1, $(m1))
43 man5 := $(addsuffix .5, $(m5))
44 man7 := $(addsuffix .7, $(m7))
45 man8 := $(addsuffix .8, $(m8))
46
47 all:: man html
48
49 man: $(man1) $(man5) $(man7) $(man8)
50
51 prefix ?= $(PREFIX)
52 prefix ?= $(HOME)
53 mandir ?= $(prefix)/share/man
54 man1dir = $(mandir)/man1
55 man5dir = $(mandir)/man5
56 man7dir = $(mandir)/man7
57 man8dir = $(mandir)/man8
58
59 install-man: man
60         $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
61         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
62         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
63         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
64         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
65         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
66         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
67         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
68
69 doc_install :: install-man
70
71 %.1 %.5 %.7 %.8 : Documentation/%.pod
72         $(podman) -s $(subst .,,$(suffix $@)) $< $@+ && mv $@+ $@
73
74 manuals :=
75 manuals += $(m1)
76 manuals += $(m5)
77 manuals += $(m7)
78 manuals += $(m8)
79
80 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(manuals)))
81 docs += $(mantxt)
82 dtxt += $(mantxt)
83
84 all :: $(mantxt)
85
86 Documentation/%.txt : Documentation/%.pod
87         $(podtext) $< $@+ && mv $@+ $@
88
89 txt2pre = $(PERL) -I lib ./Documentation/txt2pre <$< >$@+ && \
90         touch -r $< $@+ && mv $@+ $@
91
92 Documentation/standards.txt : Documentation/standards.perl
93         $(PERL) $< >$@+ && mv $@+ $@
94
95 Documentation/%.html: Documentation/%.txt
96         $(txt2pre)
97
98 %.html: %
99         $(txt2pre)
100
101 docs_html := $(addsuffix .html, $(subst .txt,,$(dtxt)) $(txt))
102 html: $(docs_html)
103 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
104 rsync_docs := $(gz_docs) $(docs) $(docs_html)
105
106 doc: $(docs)
107
108 %.gz: %
109         gzip -9 --rsyncable <$< >$@+
110         touch -r $< $@+
111         mv $@+ $@
112
113 gz-doc: $(gz_docs)
114 rsync-doc:
115         git set-file-times $(docs) $(txt)
116         $(MAKE) gz-doc
117         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
118 clean-doc:
119         $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html) $(mantxt)
120
121 clean :: clean-doc
122
123 pure_all ::
124         @if test x"$(addprefix g, make)" != xgmake; then \
125         echo W: gmake is currently required to build manpages; fi