]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
doc: sync .txt mtime to .pod mtime
[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-compact
30 m1 += public-inbox-httpd
31 m1 += public-inbox-index
32 m1 += public-inbox-mda
33 m1 += public-inbox-nntpd
34 m1 += public-inbox-watch
35 m1 += public-inbox-xcpdb
36 m5 =
37 m5 += public-inbox-config
38 m5 += public-inbox-v1-format
39 m5 += public-inbox-v2-format
40 m7 =
41 m7 += public-inbox-overview
42 m8 =
43 m8 += public-inbox-daemon
44
45 man1 := $(addsuffix .1, $(m1))
46 man5 := $(addsuffix .5, $(m5))
47 man7 := $(addsuffix .7, $(m7))
48 man8 := $(addsuffix .8, $(m8))
49
50 all:: man html
51
52 man: $(man1) $(man5) $(man7) $(man8)
53
54 prefix ?= $(PREFIX)
55 prefix ?= $(HOME)
56 mandir ?= $(prefix)/share/man
57 man1dir = $(mandir)/man1
58 man5dir = $(mandir)/man5
59 man7dir = $(mandir)/man7
60 man8dir = $(mandir)/man8
61
62 install-man: man
63         $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
64         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
65         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
66         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
67         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
68         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
69         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
70         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
71
72 doc_install :: install-man
73
74 %.1 %.5 %.7 %.8 : Documentation/%.pod
75         $(podman) -s $(subst .,,$(suffix $@)) $< $@+ && mv $@+ $@
76
77 manuals :=
78 manuals += $(m1)
79 manuals += $(m5)
80 manuals += $(m7)
81 manuals += $(m8)
82
83 mantxt = $(addprefix Documentation/, $(addsuffix .txt, $(manuals)))
84 docs += $(mantxt)
85 dtxt += $(mantxt)
86
87 all :: $(mantxt)
88
89 Documentation/%.txt : Documentation/%.pod
90         $(podtext) $< $@+ && touch -r $< $@+ && mv $@+ $@
91
92 txt2pre = $(PERL) -I lib ./Documentation/txt2pre <$< >$@+ && \
93         touch -r $< $@+ && mv $@+ $@
94
95 Documentation/standards.txt : Documentation/standards.perl
96         $(PERL) $< >$@+ && touch -r $< $@+ && mv $@+ $@
97
98 Documentation/%.html: Documentation/%.txt
99         $(txt2pre)
100
101 %.html: %
102         $(txt2pre)
103
104 docs_html := $(addsuffix .html, $(subst .txt,,$(dtxt)) $(txt))
105 html: $(docs_html)
106 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
107 rsync_docs := $(gz_docs) $(docs) $(docs_html)
108
109 doc: $(docs)
110
111 %.gz: %
112         gzip -9 --rsyncable <$< >$@+
113         touch -r $< $@+
114         mv $@+ $@
115
116 gz-doc: $(gz_docs)
117 rsync-doc:
118         # /usr/share/doc/rsync/scripts/git-set-file-times{.gz} on Debian systems
119         # It is also at: https://yhbt.net/git-set-file-times
120         -git set-file-times $(docs) $(txt)
121         $(MAKE) gz-doc
122         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
123 clean-doc:
124         $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html) $(mantxt)
125
126 clean :: clean-doc
127
128 pure_all ::
129         @if test x"$(addprefix g, make)" != xgmake; then \
130         echo W: gmake is currently required to build manpages; fi