]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
Merge remote-tracking branch 'origin/xap-optional' into master
[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 txt := INSTALL README COPYING TODO HACKING
12 dtxt := design_notes.txt design_www.txt dc-dlvr-spam-flow.txt hosted.txt
13 dtxt += marketing.txt
14 dtxt += standards.txt
15 dtxt := $(addprefix Documentation/, $(dtxt))
16 docs := $(txt) $(dtxt)
17
18 INSTALL = install
19 PODMAN = pod2man
20 PODMAN_OPTS = -v --stderr -d 1993-10-02 -c 'public-inbox user manual'
21 PODMAN_OPTS += -r public-inbox.git
22 podman = $(PODMAN) $(PODMAN_OPTS)
23 PODTEXT = pod2text
24 PODTEXT_OPTS = --stderr
25 podtext = $(PODTEXT) $(PODTEXT_OPTS)
26
27 # MakeMaker only seems to support manpage sections 1 and 3...
28 m1 =
29 m1 += public-inbox-mda
30 m1 += public-inbox-httpd
31 m1 += public-inbox-nntpd
32 m1 += public-inbox-watch
33 m1 += public-inbox-index
34 m5 =
35 m5 += public-inbox-config
36 m5 += public-inbox-v1-format
37 m5 += public-inbox-v2-format
38 m7 =
39 m7 += public-inbox-overview
40 m8 =
41 m8 += public-inbox-daemon
42
43 man1 := $(addsuffix .1, $(m1))
44 man5 := $(addsuffix .5, $(m5))
45 man7 := $(addsuffix .7, $(m7))
46 man8 := $(addsuffix .8, $(m8))
47
48 all:: man html
49
50 man: $(man1) $(man5) $(man7) $(man8)
51
52 prefix ?= $(PREFIX)
53 prefix ?= $(HOME)
54 mandir ?= $(prefix)/share/man
55 man1dir = $(mandir)/man1
56 man5dir = $(mandir)/man5
57 man7dir = $(mandir)/man7
58 man8dir = $(mandir)/man8
59
60 install-man: man
61         $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
62         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
63         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
64         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
65         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
66         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
67         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
68         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
69
70 doc_install :: install-man
71
72 %.1 %.5 %.7 %.8 : Documentation/%.pod
73         $(podman) -s $(subst .,,$(suffix $@)) $< $@+ && mv $@+ $@
74
75 manuals :=
76 manuals += $(m1)
77 manuals += $(m5)
78 manuals += $(m7)
79 manuals += $(m8)
80
81 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(manuals)))
82 docs += $(mantxt)
83 dtxt += $(mantxt)
84
85 all :: $(mantxt)
86
87 Documentation/%.txt : Documentation/%.pod
88         $(podtext) $< $@+ && mv $@+ $@
89
90 txt2pre = $(PERL) -I lib ./Documentation/txt2pre <$< >$@+ && \
91         touch -r $< $@+ && mv $@+ $@
92
93 Documentation/standards.txt : Documentation/standards.perl
94         $(PERL) $< >$@+ && mv $@+ $@
95
96 Documentation/%.html: Documentation/%.txt
97         $(txt2pre)
98
99 %.html: %
100         $(txt2pre)
101
102 docs_html := $(addsuffix .html, $(subst .txt,,$(dtxt)) $(txt))
103 html: $(docs_html)
104 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
105 rsync_docs := $(gz_docs) $(docs) $(docs_html)
106
107 doc: $(docs)
108
109 %.gz: %
110         gzip -9 --rsyncable <$< >$@+
111         touch -r $< $@+
112         mv $@+ $@
113
114 gz-doc: $(gz_docs)
115 rsync-doc:
116         git set-file-times $(docs) $(txt)
117         $(MAKE) gz-doc
118         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
119 clean-doc:
120         $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html) $(mantxt)
121
122 clean :: clean-doc
123
124 pure_all ::
125         @if test x"$(addprefix g, make)" != xgmake; then \
126         echo W: gmake is currently required to build manpages; fi