]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
bfbc495f0470cff4e88131f596e494f7335d21c6
[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 INSTALL = install
18 PODMAN = pod2man
19 PODMAN_OPTS = -v --stderr -d 1993-10-02 -c 'public-inbox user manual'
20 PODMAN_OPTS += -r public-inbox.git
21 podman = $(PODMAN) $(PODMAN_OPTS)
22
23 man2text = COLUMNS=80 MANWIDTH=80 TERM=dumb MANOPT='--nj --nh' man
24
25 all:: man
26
27 manpages = $(man1) $(man5) $(man7) $(man8)
28
29 man: $(manpages)
30
31 prefix ?= $(PREFIX)
32 prefix ?= $(HOME)
33 mandir ?= $(INSTALLMAN1DIR)/..
34 man5dir = $(mandir)/man5
35 man7dir = $(mandir)/man7
36 man8dir = $(mandir)/man8
37
38 install-man: man
39         $(INSTALL) -d -m 755 $(DESTDIR)$(INSTALLMAN1DIR)
40         $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
41         $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
42         $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
43         $(INSTALL) -m 644 $(man1) $(DESTDIR)$(INSTALLMAN1DIR)
44         $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
45         $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
46         $(INSTALL) -m 644 $(man8) $(DESTDIR)$(man8dir)
47
48 doc_install :: install-man
49
50 check :: check-man
51 check_man = $(AWK) \
52         '{gsub(/\b./,"")}$$0 !~ /\.onion/&&length>80{print;e=1}END{exit(e)}' \
53         >&2
54
55 check-man :: $(check_80)
56
57 check-lexgrog :: $(check_lexgrog)
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 Documentation/lei-q.pod : lib/PublicInbox/Search.pm Documentation/common.perl
80         $(PERL) -I lib -w Documentation/common.perl $@
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 rsync-doc: NEWS.atom.gz
105         # /usr/share/doc/rsync/scripts/git-set-file-times{.gz} on Debian systems
106         # It is also at: https://yhbt.net/git-set-file-times
107         -git set-file-times $(docs) $(txt)
108         $(MAKE) gz-doc
109         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
110
111 clean-doc:
112         $(RM_F) $(man1) $(man5) $(man7) $(man8) $(gz_docs) $(docs_html) \
113                 $(mantxt) \
114                 NEWS NEWS.atom NEWS.html Documentation/standards.txt \
115                 Documentation/flow.html Documentation/flow.html.gz \
116                 Documentation/flow.txt.gz
117
118 clean :: clean-doc
119
120 # No camel-cased tarballs or pathnames which MakeMaker creates,
121 # this may not always be a Perl project.  This should match what
122 # cgit generate, since git maintainers ensure git-archive has
123 # stable tar output
124 DIST_TREE = HEAD^{tree}
125 DIST_VER =
126 git-dist :
127         ver=$$(git describe $(DIST_VER) | sed -ne s/v//p); \
128         pkgpfx=public-inbox-$$ver; \
129         git archive --prefix=$$pkgpfx/ --format=tar $(DIST_TREE) \
130                 | gzip -n >$$pkgpfx.tar.gz; \
131         echo $$pkgpfx.tar.gz created