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