]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
treewide: run update-copyrights from gnulib for 2019
[public-inbox.git] / Documentation / include.mk
1 # Copyright (C) 2013-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 all::
4
5 RSYNC = rsync
6 RSYNC_DEST = public-inbox.org:/srv/public-inbox/
7 AWK = awk
8 MAN = man
9
10 # this is "xml" on FreeBSD and maybe some other distros:
11 XMLSTARLET = xmlstarlet
12
13 # libgraph-easy-perl from Debian, Graph::Easy from CPAN
14 GRAPH_EASY = graph-easy
15
16 # same as pod2text
17 COLUMNS = 76
18
19 INSTALL = install
20 PODMAN = pod2man
21 PODMAN_OPTS = -v --stderr -d 1993-10-02 -c 'public-inbox user manual'
22 PODMAN_OPTS += -r public-inbox.git
23 podman = $(PODMAN) $(PODMAN_OPTS)
24 PODTEXT = pod2text
25 PODTEXT_OPTS = --stderr
26 podtext = $(PODTEXT) $(PODTEXT_OPTS)
27
28 all:: man
29
30 manpages = $(man1) $(man5) $(man7) $(man8)
31
32 man: $(manpages)
33
34 prefix ?= $(PREFIX)
35 prefix ?= $(HOME)
36 mandir ?= $(INSTALLMAN1DIR)/..
37 man5dir = $(mandir)/man5
38 man7dir = $(mandir)/man7
39 man8dir = $(mandir)/man8
40
41 install-man: man
42         $(INSTALL) -d -m 755 $(DESTDIR)$(INSTALLMAN1DIR)
43         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
44         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
45         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
46         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(INSTALLMAN1DIR)
47         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
48         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
49         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
50
51 doc_install :: install-man
52
53 check :: check-man
54 check_man = $(AWK) '{gsub(/\b./,"")}length>80{print;err=1}END{exit(err)}'\
55         >&2 && >$@
56
57 check-man :: $(check_80)
58
59 all :: $(docs)
60
61 txt2pre = $(PERL) -I lib ./Documentation/txt2pre >$@
62
63 Documentation/standards.txt : Documentation/standards.perl
64         $(PERL) -w Documentation/standards.perl >$@+
65         touch -r Documentation/standards.perl $@+
66         mv $@+ $@
67
68 # flow.txt is checked into git since Graph::Easy isn't in many distros
69 Documentation/flow.txt : Documentation/flow.ge
70         (sed -ne '1,/^$$/p' <Documentation/flow.ge; \
71                 $(GRAPH_EASY) Documentation/flow.ge || \
72                         cat Documentation/flow.txt; \
73                 echo; \
74                 sed -ne '/^# Copyright/,$$p' <Documentation/flow.ge \
75                 ) >$@+
76         touch -r Documentation/flow.ge $@+
77         mv $@+ $@
78
79 NEWS NEWS.atom NEWS.html : $(news_deps)
80         $(PERL) -I lib -w Documentation/mknews.perl $@ $(RELEASES)
81
82 # check for internal API changes:
83 check :: NEWS .NEWS.atom.check NEWS.html
84
85 .NEWS.atom.check: NEWS.atom
86         $(XMLSTARLET) val NEWS.atom || \
87                 { e=$$?; test $$e -eq 0 || test $$e -eq 127; }
88         >$@
89
90 html: $(docs_html)
91
92 doc: $(docs)
93
94 %.gz: %
95         gzip -9 --rsyncable <$< >$@+
96         touch -r $< $@+
97         mv $@+ $@
98
99 gz-doc: $(gz_docs)
100
101 gz-xdoc: $(gz_xdocs)
102
103 rsync-doc: NEWS.atom.gz
104         # /usr/share/doc/rsync/scripts/git-set-file-times{.gz} on Debian systems
105         # It is also at: https://yhbt.net/git-set-file-times
106         -git set-file-times $(docs) $(txt)
107         $(MAKE) gz-doc gz-xdoc
108         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(rsync_xdocs) $(RSYNC_DEST)
109
110 clean-doc:
111         $(RM_F) $(man1) $(man5) $(man7) $(man8) $(gz_docs) $(docs_html) \
112                 $(mantxt) $(rsync_xdocs) \
113                 NEWS NEWS.atom NEWS.html Documentation/standards.txt \
114                 Documentation/flow.html Documentation/flow.html.gz \
115                 Documentation/flow.txt.gz
116
117 clean :: clean-doc
118
119 # No camel-cased tarballs or pathnames which MakeMaker creates,
120 # this may not always be a Perl project.  This should match what
121 # cgit generate, since git maintainers ensure git-archive has
122 # stable tar output
123 DIST_TREE = HEAD^{tree}
124 DIST_VER =
125 git-dist :
126         ver=$$(git describe $(DIST_VER) | sed -ne s/v//p); \
127         pkgpfx=public-inbox-$$ver; \
128         git archive --prefix=$$pkgpfx/ --format=tar $(DIST_TREE) \
129                 | gzip -n >$$pkgpfx.tar.gz; \
130         echo $$pkgpfx.tar.gz created