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