]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
624f07f42e4330c3d7c6f6d227cfc14e43a88723
[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.cgi
41 m1 += public-inbox-edit
42 m1 += public-inbox-httpd
43 m1 += public-inbox-index
44 m1 += public-inbox-init
45 m1 += public-inbox-learn
46 m1 += public-inbox-mda
47 m1 += public-inbox-nntpd
48 m1 += public-inbox-purge
49 m1 += public-inbox-watch
50 m1 += public-inbox-xcpdb
51 m5 =
52 m5 += public-inbox-config
53 m5 += public-inbox-v1-format
54 m5 += public-inbox-v2-format
55 m7 =
56 m7 += public-inbox-overview
57 m8 =
58 m8 += public-inbox-daemon
59
60 man1 := $(addsuffix .1, $(m1))
61 man5 := $(addsuffix .5, $(m5))
62 man7 := $(addsuffix .7, $(m7))
63 man8 := $(addsuffix .8, $(m8))
64
65 all:: man html
66
67 manpages = $(man1) $(man5) $(man7) $(man8)
68
69 man: $(manpages)
70
71 prefix ?= $(PREFIX)
72 prefix ?= $(HOME)
73 mandir ?= $(prefix)/share/man
74 man1dir = $(mandir)/man1
75 man5dir = $(mandir)/man5
76 man7dir = $(mandir)/man7
77 man8dir = $(mandir)/man8
78
79 install-man: man
80         $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
81         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
82         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
83         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
84         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
85         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
86         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
87         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
88
89 doc_install :: install-man
90
91 %.1 %.5 %.7 %.8 : Documentation/%.pod
92         $(podman) -s $(subst .,,$(suffix $@)) $< $@+ && mv $@+ $@
93
94 check :: check-man
95 check_man = @echo CHECK80 $<;COLUMNS=80 $(MAN) ./$^ | \
96         $(AWK) '{gsub(/\b./,"")}length>80{print;err=1}END{exit(err)}' >&2 \
97         && >$@
98
99 .%.1.cols : %.1; $(check_man)
100 .%.5.cols : %.5; $(check_man)
101 .%.7.cols : %.7; $(check_man)
102 .%.8.cols : %.8; $(check_man)
103
104 check-man :: $(addprefix .,$(addsuffix .cols, $(manpages)))
105
106 manuals :=
107 manuals += $(m1)
108 manuals += $(m5)
109 manuals += $(m7)
110 manuals += $(m8)
111
112 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(manuals)))
113 docs += $(mantxt)
114 dtxt += $(mantxt)
115 docs += NEWS
116
117 all :: $(docs)
118
119 Documentation/%.txt : Documentation/%.pod
120         $(podtext) $< $@+ && touch -r $< $@+ && mv $@+ $@
121
122 txt2pre = $(PERL) -I lib ./Documentation/txt2pre <$< >$@+ && \
123         touch -r $< $@+ && mv $@+ $@
124
125 Documentation/standards.txt : Documentation/standards.perl
126         $(PERL) $< >$@+ && touch -r $< $@+ && mv $@+ $@
127
128 RELEASES =
129 RELEASES += v1.2.0
130 RELEASES += v1.1.0-pre1
131 RELEASES += v1.0.0
132
133 NEWS NEWS.atom NEWS.html : Documentation/include.mk
134         $(PERL) -I lib -w Documentation/mknews.perl $@ $(RELEASES)
135
136 # check for internal API changes:
137 check :: NEWS .NEWS.atom.check NEWS.html
138
139 .NEWS.atom.check: NEWS.atom
140         $(XMLSTARLET) val NEWS.atom || \
141                 { e=$$?; test $$e -eq 0 || test $$e -eq 127; }
142         >$@
143
144 Documentation/%.html: Documentation/%.txt
145         $(txt2pre)
146
147 %.html: %
148         $(txt2pre)
149
150 docs_html := $(addsuffix .html, $(subst .txt,,$(dtxt)) $(txt)) NEWS.html
151 html: $(docs_html)
152 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
153 rsync_docs := $(gz_docs) $(docs) $(docs_html) NEWS.atom NEWS.atom.gz
154
155 # external manpages which we host ourselves, since some packages
156 # (currently just Xapian) doesn't host manpages themselves.
157 xtxt :=
158 xtxt += .copydatabase.1
159 xtxt += .xapian-compact.1
160 xtxt := $(addprefix Documentation/.x/, $(addsuffix .txt, $(xtxt)))
161 xdocs := $(xtxt)
162 xdocs_html := $(addsuffix .html, $(subst .txt,,$(xtxt)))
163 gz_xdocs := $(addsuffix .gz, $(xdocs) $(xdocs_html))
164 rsync_xdocs := $(gz_xdocs) $(xdocs_html) $(xdocs)
165 xdoc: $(xdocs) $(xdocs_html)
166
167 Documentation/.x:
168         mkdir -p $@
169
170 Documentation/.x/%.txt :: | Documentation/.x
171         $(PERL) -w Documentation/extman.perl $@ >$@+
172         mv $@+ $@
173
174 Documentation/.x/%.html: Documentation/.x/%.txt
175         $(txt2pre)
176
177 doc: $(docs)
178
179 %.gz: %
180         gzip -9 --rsyncable <$< >$@+
181         touch -r $< $@+
182         mv $@+ $@
183
184 gz-doc: $(gz_docs)
185
186 gz-xdoc: $(gz_xdocs)
187
188 rsync-doc: NEWS.atom.gz
189         # /usr/share/doc/rsync/scripts/git-set-file-times{.gz} on Debian systems
190         # It is also at: https://yhbt.net/git-set-file-times
191         -git set-file-times $(docs) $(txt)
192         $(MAKE) gz-doc gz-xdoc
193         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(rsync_xdocs) $(RSYNC_DEST)
194
195 clean-doc:
196         $(RM) $(man1) $(man5) $(man7) $(man8) $(gz_docs) $(docs_html) $(mantxt)
197         $(RM) $(gz_xdocs) $(xdocs_html) $(xdocs)
198         $(RM) NEWS NEWS.atom NEWS.html Documentation/standards.txt
199
200 clean :: clean-doc
201
202 pure_all ::
203         @if test x"$(addprefix g, make)" != xgmake; then \
204         echo W: gmake is currently required to build manpages; fi
205
206 # No camel-cased tarballs or pathnames which MakeMaker creates,
207 # this may not always be a Perl project.
208 git-dist :: ver = $(shell git describe |sed -ne 's/v//p')
209 git-dist :: pkgpfx := public-inbox-$(ver)
210 git-dist :: NEWS
211         git archive --prefix=$(pkgpfx)/ --format=tar HEAD^{tree} >$(pkgpfx).tar
212         mkdir -p $(pkgpfx)
213         cp NEWS $(pkgpfx)/NEWS
214         $(TAR) rf $(pkgpfx).tar $(pkgpfx)/NEWS
215         $(RM) $(pkgpfx)/NEWS
216         rmdir $(pkgpfx)
217         gzip -9 $(pkgpfx).tar
218         @echo $(pkgpfx).tar.gz created