]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
doc: add manpage for public-inbox-init(1)
[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 MAN = man
12
13 # same as pod2text
14 COLUMNS = 76
15
16 txt := INSTALL README COPYING TODO HACKING
17 dtxt := design_notes.txt design_www.txt dc-dlvr-spam-flow.txt hosted.txt
18 dtxt += marketing.txt
19 dtxt += standards.txt
20 dtxt := $(addprefix Documentation/, $(dtxt))
21 docs := $(txt) $(dtxt)
22
23 INSTALL = install
24 PODMAN = pod2man
25 PODMAN_OPTS = -v --stderr -d 1993-10-02 -c 'public-inbox user manual'
26 PODMAN_OPTS += -r public-inbox.git
27 podman = $(PODMAN) $(PODMAN_OPTS)
28 PODTEXT = pod2text
29 PODTEXT_OPTS = --stderr
30 podtext = $(PODTEXT) $(PODTEXT_OPTS)
31
32 # MakeMaker only seems to support manpage sections 1 and 3...
33 m1 =
34 m1 += public-inbox-compact
35 m1 += public-inbox-convert
36 m1 += public-inbox-edit
37 m1 += public-inbox-httpd
38 m1 += public-inbox-index
39 m1 += public-inbox-init
40 m1 += public-inbox-mda
41 m1 += public-inbox-nntpd
42 m1 += public-inbox-watch
43 m1 += public-inbox-xcpdb
44 m5 =
45 m5 += public-inbox-config
46 m5 += public-inbox-v1-format
47 m5 += public-inbox-v2-format
48 m7 =
49 m7 += public-inbox-overview
50 m8 =
51 m8 += public-inbox-daemon
52
53 man1 := $(addsuffix .1, $(m1))
54 man5 := $(addsuffix .5, $(m5))
55 man7 := $(addsuffix .7, $(m7))
56 man8 := $(addsuffix .8, $(m8))
57
58 all:: man html
59
60 man: $(man1) $(man5) $(man7) $(man8)
61
62 prefix ?= $(PREFIX)
63 prefix ?= $(HOME)
64 mandir ?= $(prefix)/share/man
65 man1dir = $(mandir)/man1
66 man5dir = $(mandir)/man5
67 man7dir = $(mandir)/man7
68 man8dir = $(mandir)/man8
69
70 install-man: man
71         $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
72         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
73         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
74         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
75         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
76         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
77         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
78         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
79
80 doc_install :: install-man
81
82 %.1 %.5 %.7 %.8 : Documentation/%.pod
83         $(podman) -s $(subst .,,$(suffix $@)) $< $@+ && mv $@+ $@
84
85 manuals :=
86 manuals += $(m1)
87 manuals += $(m5)
88 manuals += $(m7)
89 manuals += $(m8)
90
91 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(manuals)))
92 docs += $(mantxt)
93 dtxt += $(mantxt)
94
95 all :: $(mantxt)
96
97 Documentation/%.txt : Documentation/%.pod
98         $(podtext) $< $@+ && touch -r $< $@+ && mv $@+ $@
99
100 txt2pre = $(PERL) -I lib ./Documentation/txt2pre <$< >$@+ && \
101         touch -r $< $@+ && mv $@+ $@
102
103 Documentation/standards.txt : Documentation/standards.perl
104         $(PERL) $< >$@+ && touch -r $< $@+ && mv $@+ $@
105
106 Documentation/%.html: Documentation/%.txt
107         $(txt2pre)
108
109 %.html: %
110         $(txt2pre)
111
112 docs_html := $(addsuffix .html, $(subst .txt,,$(dtxt)) $(txt))
113 html: $(docs_html)
114 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
115 rsync_docs := $(gz_docs) $(docs) $(docs_html)
116
117 # external manpages which we host ourselves, since some packages
118 # (currently just Xapian) doesn't host manpages themselves.
119 xtxt :=
120 xtxt += .copydatabase.1
121 xtxt += .xapian-compact.1
122 xtxt := $(addprefix Documentation/.x/, $(addsuffix .txt, $(xtxt)))
123 xdocs := $(xtxt)
124 xdocs_html := $(addsuffix .html, $(subst .txt,,$(xtxt)))
125 gz_xdocs := $(addsuffix .gz, $(xdocs) $(xdocs_html))
126 rsync_xdocs := $(gz_xdocs) $(xdocs_html) $(xdocs)
127 xdoc: $(xdocs) $(xdocs_html)
128
129 Documentation/.x:
130         mkdir -p $@
131
132 Documentation/.x/%.txt :: | Documentation/.x
133         $(PERL) -w Documentation/extman.perl $@ >$@+
134         mv $@+ $@
135
136 Documentation/.x/%.html: Documentation/.x/%.txt
137         $(txt2pre)
138
139 doc: $(docs)
140
141 %.gz: %
142         gzip -9 --rsyncable <$< >$@+
143         touch -r $< $@+
144         mv $@+ $@
145
146 gz-doc: $(gz_docs)
147
148 gz-xdoc: $(gz_xdocs)
149
150 rsync-doc:
151         # /usr/share/doc/rsync/scripts/git-set-file-times{.gz} on Debian systems
152         # It is also at: https://yhbt.net/git-set-file-times
153         -git set-file-times $(docs) $(txt)
154         $(MAKE) gz-doc gz-xdoc
155         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(rsync_xdocs) $(RSYNC_DEST)
156
157 clean-doc:
158         $(RM) $(man1) $(man5) $(man7) $(man8) $(gz_docs) $(docs_html) $(mantxt)
159         $(RM) $(gz_xdocs) $(xdocs_html) $(xdocs)
160
161 clean :: clean-doc
162
163 pure_all ::
164         @if test x"$(addprefix g, make)" != xgmake; then \
165         echo W: gmake is currently required to build manpages; fi