]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/include.mk
doc: avoid needless rebuilds of NEWS
[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 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 # same as pod2text
14 COLUMNS = 76
15
16 INSTALL = install
17 PODMAN = pod2man
18 PODMAN_OPTS = -v --stderr -d 1993-10-02 -c 'public-inbox user manual'
19 PODMAN_OPTS += -r public-inbox.git
20 podman = $(PODMAN) $(PODMAN_OPTS)
21 PODTEXT = pod2text
22 PODTEXT_OPTS = --stderr
23 podtext = $(PODTEXT) $(PODTEXT_OPTS)
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) '{gsub(/\b./,"")}length>80{print;err=1}END{exit(err)}'\
52         >&2 && >$@
53
54 check-man :: $(check_80)
55
56 all :: $(docs)
57
58 txt2pre = $(PERL) -I lib ./Documentation/txt2pre >$@
59
60 Documentation/standards.txt : Documentation/standards.perl
61         $(PERL) -w Documentation/standards.perl >$@+
62         touch -r Documentation/standards.perl $@+
63         mv $@+ $@
64
65 NEWS NEWS.atom NEWS.html : $(news_deps)
66         $(PERL) -I lib -w Documentation/mknews.perl $@ $(RELEASES)
67
68 # check for internal API changes:
69 check :: NEWS .NEWS.atom.check NEWS.html
70
71 .NEWS.atom.check: NEWS.atom
72         $(XMLSTARLET) val NEWS.atom || \
73                 { e=$$?; test $$e -eq 0 || test $$e -eq 127; }
74         >$@
75
76 html: $(docs_html)
77
78 Documentation/.x:
79         mkdir -p $@
80
81 doc: $(docs)
82
83 %.gz: %
84         gzip -9 --rsyncable <$< >$@+
85         touch -r $< $@+
86         mv $@+ $@
87
88 gz-doc: $(gz_docs)
89
90 gz-xdoc: $(gz_xdocs)
91
92 rsync-doc: NEWS.atom.gz
93         # /usr/share/doc/rsync/scripts/git-set-file-times{.gz} on Debian systems
94         # It is also at: https://yhbt.net/git-set-file-times
95         -git set-file-times $(docs) $(txt)
96         $(MAKE) gz-doc gz-xdoc
97         $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(rsync_xdocs) $(RSYNC_DEST)
98
99 clean-doc:
100         $(RM_F) $(man1) $(man5) $(man7) $(man8) $(gz_docs) $(docs_html) \
101                 $(mantxt) $(rsync_xdocs) \
102                 NEWS NEWS.atom NEWS.html Documentation/standards.txt
103
104 clean :: clean-doc
105
106 # No camel-cased tarballs or pathnames which MakeMaker creates,
107 # this may not always be a Perl project.  This should match what
108 # cgit generate, since git maintainers ensure git-archive has
109 # stable tar output
110 DIST_TREE = HEAD^{tree}
111 DIST_VER =
112 git-dist :
113         ver=$$(git describe $(DIST_VER) | sed -ne s/v//p); \
114         pkgpfx=public-inbox-$$ver; \
115         git archive --prefix=$$pkgpfx/ --format=tar $(DIST_TREE) \
116                 | gzip -n >$$pkgpfx.tar.gz; \
117         echo $$pkgpfx.tar.gz created