b4865b59566cf54673cf25c4d1eb065fd15157bb
[ssoma-mda.git] / Documentation / include.mk
1 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
3 all::
4
5 RSYNC = rsync
6 RSYNC_DEST = ssoma.public-inbox.org:/srv/ssoma/
7 docs := README COPYING INSTALL $(shell git ls-files 'Documentation/*.txt')
8 INSTALL = install
9 PANDOC = pandoc
10 PANDOC_OPTS = -f markdown --email-obfuscation=none
11 pandoc = $(PANDOC) $(PANDOC_OPTS)
12
13 m1 =
14 m1 += ssoma
15 m1 += ssoma-mda
16 m1 += ssoma-rm
17
18 m5 =
19 m5 += ssoma_repository
20
21 m7 =
22
23 man1 := $(addsuffix .1, $(m1))
24 man5 := $(addsuffix .5, $(m5))
25 man7 := $(addsuffix .7, $(m7))
26
27 all:: man html
28
29 man: $(man1) $(man5) $(man7)
30
31 prefix ?= $(HOME)
32 mandir ?= $(prefix)/share/man
33 man1dir = $(mandir)/man1
34 man5dir = $(mandir)/man5
35 man7dir = $(mandir)/man7
36
37 install-man: man
38         test -z "$(man1)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
39         test -z "$(man5)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
40         test -z "$(man7)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
41         test -z "$(man1)" || $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
42         test -z "$(man5)" || $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
43         test -z "$(man7)" || $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
44 %.1 %.5 %.7 : Documentation/%.txt
45         $(pandoc) -s -t man < $< > $@+ && mv $@+ $@
46
47 txt2pre = ./Documentation/txt2pre < $< > $@+ && touch -r $< $@+ && mv $@+ $@
48 txt = INSTALL README COPYING
49
50 INSTALL.html: INSTALL
51         $(txt2pre)
52 index.html: README
53         $(txt2pre)
54
55 docs_html := index.html INSTALL.html
56 html: $(docs_html)
57 gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
58 rsync_docs := $(gz_docs) $(docs) $(txt) $(docs_html)
59 %.gz: %
60         gzip -9 --rsyncable < $< > $@+
61         touch -r $< $@+
62         mv $@+ $@
63
64 gz-doc: $(gz_docs)
65 rsync-doc:
66         git set-file-times $(docs) $(txt)
67         $(MAKE) gz-doc
68         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
69 clean-doc:
70         $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html)