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