doc: enforce @var{lower} policy
[platform/upstream/coreutils.git] / doc / Makefile.am
1 # Make coreutils documentation.                         -*-Makefile-*-
2
3 # Copyright (C) 1995-1998, 2001-2008 Free Software Foundation, Inc.
4
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 info_TEXINFOS = coreutils.texi
19
20 EXTRA_DIST = perm.texi getdate.texi constants.texi fdl.texi
21
22 # The following is necessary if the package name is 8 characters or longer.
23 # If the info documentation would be split into 10 or more separate files,
24 # then this is necessary even if the package name is 7 characters long.
25 #
26 # Tell makeinfo to put everything in a single info file: <package>.info.
27 # Otherwise, it would also generate files with names like <package>.info-[123],
28 # and those names all map to one 14-byte name (<package>.info-) on some crufty
29 # old systems.
30 AM_MAKEINFOFLAGS = --no-split
31
32 constants.texi: $(top_srcdir)/src/tail.c
33         LC_ALL=C \
34         sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \
35           $(top_srcdir)/src/tail.c > t-$@
36         mv t-$@ $@
37
38 MAINTAINERCLEANFILES = constants.texi
39
40 $(DVIS): $(EXTRA_DIST)
41 $(INFO_DEPS): $(EXTRA_DIST)
42
43 # Extended regular expressions to match word starts and ends.
44 _W = (^|[^A-Za-z0-9_])
45 W_ = ([^A-Za-z0-9_]|$$)
46
47 syntax_checks =         \
48   sc-avoid-io           \
49   sc-avoid-non-zero     \
50   sc-avoid-timezone     \
51   sc-avoid-zeroes       \
52   sc-exponent-grouping  \
53   sc-lower-case-var     \
54   sc-use-small-caps-NUL
55
56 .PHONY: $(syntax_checks) check-texinfo
57
58 # List words/regexps here that should not appear in the texinfo documentation.
59 check-texinfo: $(syntax_checks)
60         @fail=0; \
61         grep '@url{' $(srcdir)/*.texi && fail=1; \
62         grep '\$$@"' $(srcdir)/*.texi && fail=1; \
63         grep -n '[^[:punct:]]@footnote' $(srcdir)/*.texi && fail=1; \
64         grep -n filename $(srcdir)/*.texi \
65             | $(EGREP) -v 'setfilename|[{]filename[}]' \
66           && fail=1; \
67         $(PERL) -e 1 2> /dev/null && { $(PERL) -ne \
68           '/\bPOSIX\b/ && !/\@acronym{POSIX}/ && !/^\* / || /{posix}/ and print,exit 1' \
69           $(srcdir)/*.texi 2> /dev/null || fail=1; }; \
70         $(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \
71         $(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \
72           | $(EGREP) -v 'search path|@vindex PATH$$|@env[{]PATH[}]' && fail=1; \
73         exit $$fail
74
75 # Use `time zone', not `timezone'.
76 sc-avoid-timezone:
77         @$(EGREP) timezone $(srcdir)/*.texi && exit 1 || :
78
79 # Check for insufficient exponent grouping, e.g.,
80 # @math{2^64} should be @math{2^{64}}.
81 sc-exponent-grouping:
82         @$(EGREP) '\{.*\^[0-9][0-9]' $(srcdir)/*.texi && exit 1 || :
83
84 # E.g., use @sc{nul}, not NUL.
85 sc-use-small-caps-NUL:
86         @$(EGREP) '$(_W)NUL$(W_)' $(srcdir)/*.texi && exit 1 || :
87
88 # Say I/O, not IO.
89 sc-avoid-io:
90         @$(EGREP) '$(_W)IO$(W_)' $(srcdir)/*.texi && exit 1 || :
91
92 # I prefer nonzero over non-zero.
93 sc-avoid-non-zero:
94         @$(EGREP) non-zero $(srcdir)/*.texi && exit 1 || :
95
96 # Use `zeros', not `zeroes' (nothing wrong with `zeroes'. just be consistent).
97 sc-avoid-zeroes:
98         @$(EGREP) -i '$(_W)zeroes$(W_)' $(srcdir)/*.texi && exit 1 || :
99
100 # ME = $(subdir)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
101 ME = doc/Makefile
102
103 # The quantity inside @var{...} should not contain upper case letters.
104 # The leading backslash exemption is to permit in-macro uses like
105 # @var{\varName\} where the upper case letter is part of a parameter name.
106 find_upper_case_var =           \
107   '/\@var{/ or next;            \
108    while (/\@var{(.+?)}/g)      \
109      {                          \
110        $$v = $$1;               \
111        $$v =~ /[A-Z]/ && $$v !~ /^\\/ and (print "$$ARGV:$$.:$$_"), $$m = 1 \
112      }                          \
113    END {$$m and (warn "$(ME): do not use upper case in \@var{...}\n"), exit 1}'
114 sc-lower-case-var:
115         @$(PERL) -e 1 2> /dev/null && \
116           $(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
117
118 check: check-texinfo