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