Codebase list virt-viewer / d9825f3
Import GNULIB rules for syntax checking code Daniel P. Berrange 12 years ago
8 changed file(s) with 2123 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 # Having a separate GNUmakefile lets me `include' the dynamically
1 # generated rules created via cfg.mk (package-local configuration)
2 # as well as maint.mk (generic maintainer rules).
3 # This makefile is used only if you run GNU Make.
4 # It is necessary if you want to build targets usually of interest
5 # only to the maintainer.
6
7 # Copyright (C) 2001, 2003, 2006-2011 Free Software Foundation, Inc.
8
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22 # Systems where /bin/sh is not the default shell need this. The $(shell)
23 # command below won't work with e.g. stock DOS/Windows shells.
24 ifeq ($(wildcard /bin/s[h]),/bin/sh)
25 SHELL = /bin/sh
26 else
27 # will be used only with the next shell-test line, then overwritten
28 # by a configured-in value
29 SHELL = sh
30 endif
31
32 # If the user runs GNU make but has not yet run ./configure,
33 # give them a diagnostic.
34 _have-Makefile := $(shell test -f Makefile && echo yes)
35 ifeq ($(_have-Makefile),yes)
36
37 # Make tar archive easier to reproduce.
38 export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
39
40 # Allow the user to add to this in the Makefile.
41 ALL_RECURSIVE_TARGETS =
42
43 include Makefile
44
45 # Some projects override e.g., _autoreconf here.
46 -include $(srcdir)/cfg.mk
47
48 # Allow cfg.mk to override these.
49 _build-aux ?= build-aux
50 _autoreconf ?= autoreconf -v
51
52 include $(srcdir)/maint.mk
53
54 # Ensure that $(VERSION) is up to date for dist-related targets, but not
55 # for others: rerunning autoreconf and recompiling everything isn't cheap.
56 _have-git-version-gen := \
57 $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes)
58 ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
59 _is-dist-target ?= $(filter-out %clean, \
60 $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS)))
61 _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS)))
62 ifneq (,$(_is-dist-target)$(_is-install-target))
63 _curr-ver := $(shell cd $(srcdir) \
64 && $(_build-aux)/git-version-gen \
65 .tarball-version \
66 $(git-version-gen-tag-sed-script))
67 ifneq ($(_curr-ver),$(VERSION))
68 ifeq ($(_curr-ver),UNKNOWN)
69 $(info WARNING: unable to verify if $(VERSION) is the correct version)
70 else
71 ifneq (,$(_is-install-target))
72 # GNU Coding Standards state that 'make install' should not cause
73 # recompilation after 'make all'. But as long as changing the version
74 # string alters config.h, the cost of having 'make all' always have an
75 # up-to-date version is prohibitive. So, as a compromise, we merely
76 # warn when installing a version string that is out of date; the user
77 # should run 'autoreconf' (or something like 'make distcheck') to
78 # fix the version, 'make all' to propagate it, then 'make install'.
79 $(info WARNING: version string $(VERSION) is out of date;)
80 $(info run '$(MAKE) _version' to fix it)
81 else
82 $(info INFO: running autoreconf for new version string: $(_curr-ver))
83 GNUmakefile: _version
84 touch GNUmakefile
85 endif
86 endif
87 endif
88 endif
89 endif
90
91 .PHONY: _version
92 _version:
93 cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf)
94 $(MAKE) $(AM_MAKEFLAGS) Makefile
95
96 else
97
98 .DEFAULT_GOAL := abort-due-to-no-makefile
99 srcdir = .
100
101 # The package can override .DEFAULT_GOAL to run actions like autoreconf.
102 -include ./cfg.mk
103 include ./maint.mk
104
105 ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
106 $(MAKECMDGOALS): abort-due-to-no-makefile
107 endif
108
109 abort-due-to-no-makefile:
110 @echo There seems to be no Makefile in this directory. 1>&2
111 @echo "You must run ./configure before running \`make'." 1>&2
112 @exit 1
113
114 endif
115
116 # Tell version 3.79 and up of GNU make to not build goals in this
117 # directory in parallel, in case someone tries to build multiple
118 # targets, and one of them can cause a recursive target to be invoked.
119
120 # Only set this if Automake doesn't provide it.
121 AM_RECURSIVE_TARGETS ?= $(RECURSIVE_TARGETS:-recursive=) \
122 $(RECURSIVE_CLEAN_TARGETS:-recursive=) \
123 dist distcheck tags ctags
124
125 ALL_RECURSIVE_TARGETS += $(AM_RECURSIVE_TARGETS)
126
127 ifneq ($(word 2, $(MAKECMDGOALS)), )
128 ifneq ($(filter $(ALL_RECURSIVE_TARGETS), $(MAKECMDGOALS)), )
129 .NOTPARALLEL:
130 endif
131 endif
88 intltool-extract.in \
99 intltool-merge.in \
1010 intltool-update.in \
11 GNUmakefile \
12 maint.mk \
13 cfg.mk \
14 build-aux/gitlog-to-changelog \
15 build-aux/useless-if-before-free \
16 build-aux/vc-list-files \
1117 $(NULL)
1218
1319 DISTCLEAN_FILES = \
11
22 set -e
33 set -v
4
5 test -n "$1" && RESULTS=$1 || RESULTS=results.log
46
57 # Make things clean.
68 test -f Makefile && make -k distclean || :
2830 make
2931 make install
3032 fi
33
34 # set -o pipefail is a bashism; this use of exec is the POSIX alternative
35 exec 3>&1
36 st=$(
37 exec 4>&1 >&3
38 { make syntax-check 2>&1 3>&- 4>&-; echo $? >&4; } | tee "$RESULTS"
39 )
40 exec 3>&-
41 test "$st" = 0
42
3143
3244 rm -f *.tar.gz
3345 make dist
0 eval '(exit $?0)' && eval 'exec perl -wST "$0" ${1+"$@"}'
1 & eval 'exec perl -wST "$0" $argv:q'
2 if 0;
3 # Detect instances of "if (p) free (p);".
4 # Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces.
5
6 my $VERSION = '2011-04-20 13:43'; # UTC
7 # The definition above must lie within the first 8 lines in order
8 # for the Emacs time-stamp write hook (at end) to update it.
9 # If you change this file with Emacs, please let the write hook
10 # do its job. Otherwise, update this string manually.
11
12 # Copyright (C) 2008-2011 Free Software Foundation, Inc.
13
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
18
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26
27 # Written by Jim Meyering
28
29 use strict;
30 use warnings;
31 use Getopt::Long;
32
33 (my $ME = $0) =~ s|.*/||;
34
35 # use File::Coda; # http://meyering.net/code/Coda/
36 END {
37 defined fileno STDOUT or return;
38 close STDOUT and return;
39 warn "$ME: failed to close standard output: $!\n";
40 $? ||= 1;
41 }
42
43 sub usage ($)
44 {
45 my ($exit_code) = @_;
46 my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
47 if ($exit_code != 0)
48 {
49 print $STREAM "Try `$ME --help' for more information.\n";
50 }
51 else
52 {
53 print $STREAM <<EOF;
54 Usage: $ME [OPTIONS] FILE...
55
56 Detect any instance in FILE of a useless "if" test before a free call, e.g.,
57 "if (p) free (p);". Any such test may be safely removed without affecting
58 the semantics of the C code in FILE. Use --name=FOO --name=BAR to also
59 detect free-like functions named FOO and BAR.
60
61 OPTIONS:
62
63 --list print only the name of each matching FILE (\\0-terminated)
64 --name=N add name N to the list of \`free\'-like functions to detect;
65 may be repeated
66
67 --help display this help and exit
68 --version output version information and exit
69
70 Exit status:
71
72 0 one or more matches
73 1 no match
74 2 an error
75
76 EXAMPLE:
77
78 For example, this command prints all removable "if" tests before "free"
79 and "kfree" calls in the linux kernel sources:
80
81 git ls-files -z |xargs -0 $ME --name=kfree
82
83 EOF
84 }
85 exit $exit_code;
86 }
87
88 sub is_NULL ($)
89 {
90 my ($expr) = @_;
91 return ($expr eq 'NULL' || $expr eq '0');
92 }
93
94 {
95 sub EXIT_MATCH {0}
96 sub EXIT_NO_MATCH {1}
97 sub EXIT_ERROR {2}
98 my $err = EXIT_NO_MATCH;
99
100 my $list;
101 my @name = qw(free);
102 GetOptions
103 (
104 help => sub { usage 0 },
105 version => sub { print "$ME version $VERSION\n"; exit },
106 list => \$list,
107 'name=s@' => \@name,
108 ) or usage 1;
109
110 # Make sure we have the right number of non-option arguments.
111 # Always tell the user why we fail.
112 @ARGV < 1
113 and (warn "$ME: missing FILE argument\n"), usage EXIT_ERROR;
114
115 my $or = join '|', @name;
116 my $regexp = qr/(?:$or)/;
117
118 # Set the input record separator.
119 # Note: this makes it impractical to print line numbers.
120 $/ = '"';
121
122 my $found_match = 0;
123 FILE:
124 foreach my $file (@ARGV)
125 {
126 open FH, '<', $file
127 or (warn "$ME: can't open `$file' for reading: $!\n"),
128 $err = EXIT_ERROR, next;
129 while (defined (my $line = <FH>))
130 {
131 while ($line =~
132 /\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\)
133 # 1 2 3
134 (?: \s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;|
135 \s*\{\s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;\s*\}))/sxg)
136 {
137 my $all = $1;
138 my ($lhs, $rhs) = ($2, $3);
139 my ($free_opnd, $braced_free_opnd) = ($4, $5);
140 my $non_NULL;
141 if (!defined $rhs) { $non_NULL = $lhs }
142 elsif (is_NULL $rhs) { $non_NULL = $lhs }
143 elsif (is_NULL $lhs) { $non_NULL = $rhs }
144 else { next }
145
146 # Compare the non-NULL part of the "if" expression and the
147 # free'd expression, without regard to white space.
148 $non_NULL =~ tr/ \t//d;
149 my $e2 = defined $free_opnd ? $free_opnd : $braced_free_opnd;
150 $e2 =~ tr/ \t//d;
151 if ($non_NULL eq $e2)
152 {
153 $found_match = 1;
154 $list
155 and (print "$file\0"), next FILE;
156 print "$file: $all\n";
157 }
158 }
159 }
160 }
161 continue
162 {
163 close FH;
164 }
165
166 $found_match && $err == EXIT_NO_MATCH
167 and $err = EXIT_MATCH;
168
169 exit $err;
170 }
171
172 my $foo = <<'EOF';
173 # The above is to *find* them.
174 # This adjusts them, removing the unnecessary "if (p)" part.
175
176 # FIXME: do something like this as an option (doesn't do braces):
177 free=xfree
178 git grep -l -z "$free *(" \
179 | xargs -0 useless-if-before-free -l --name="$free" \
180 | xargs -0 perl -0x3b -pi -e \
181 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\)\s*;)/$2/s'
182
183 # Use the following to remove redundant uses of kfree inside braces.
184 # Note that -0777 puts perl in slurp-whole-file mode;
185 # but we have plenty of memory, these days...
186 free=kfree
187 git grep -l -z "$free *(" \
188 | xargs -0 useless-if-before-free -l --name="$free" \
189 | xargs -0 perl -0777 -pi -e \
190 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s*\{\s*('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\);)\s*\}[^\n]*$/$2/gms'
191
192 Be careful that the result of the above transformation is valid.
193 If the matched string is followed by "else", then obviously, it won't be.
194
195 When modifying files, refuse to process anything other than a regular file.
196 EOF
197
198 ## Local Variables:
199 ## mode: perl
200 ## indent-tabs-mode: nil
201 ## eval: (add-hook 'write-file-hooks 'time-stamp)
202 ## time-stamp-start: "my $VERSION = '"
203 ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
204 ## time-stamp-time-zone: "UTC"
205 ## time-stamp-end: "'; # UTC"
206 ## End:
0 #!/bin/sh
1 # List version-controlled file names.
2
3 # Print a version string.
4 scriptversion=2011-05-16.22; # UTC
5
6 # Copyright (C) 2006-2011 Free Software Foundation, Inc.
7
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21
22 # List the specified version-controlled files.
23 # With no argument, list them all. With a single DIRECTORY argument,
24 # list the version-controlled files in that directory.
25
26 # If there's an argument, it must be a single, "."-relative directory name.
27 # cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
28
29 postprocess=
30 case $1 in
31 --help) cat <<EOF
32 Usage: $0 [-C SRCDIR] [DIR...]
33
34 Output a list of version-controlled files in DIR (default .), relative to
35 SRCDIR (default .). SRCDIR must be the top directory of a checkout.
36
37 Options:
38 --help print this help, then exit
39 --version print version number, then exit
40 -C SRCDIR change directory to SRCDIR before generating list
41
42 Report bugs and patches to <bug-gnulib@gnu.org>.
43 EOF
44 exit ;;
45
46 --version)
47 year=`echo "$scriptversion" | sed 's/[^0-9].*//'`
48 cat <<EOF
49 vc-list-files $scriptversion
50 Copyright (C) $year Free Software Foundation, Inc,
51 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
52 This is free software: you are free to change and redistribute it.
53 There is NO WARRANTY, to the extent permitted by law.
54 EOF
55 exit ;;
56
57 -C)
58 test "$2" = . || postprocess="| sed 's|^|$2/|'"
59 cd "$2" || exit 1
60 shift; shift ;;
61 esac
62
63 test $# = 0 && set .
64
65 for dir
66 do
67 if test -d .git; then
68 test "x$dir" = x. \
69 && dir= sed_esc= \
70 || { dir="$dir/"; sed_esc=`echo "$dir"|env sed 's,\([\\/]\),\\\\\1,g'`; }
71 # Ignore git symlinks - either they point into the tree, in which case
72 # we don't need to visit the target twice, or they point somewhere
73 # else (often into a submodule), in which case the content does not
74 # belong to this package.
75 eval exec git ls-tree -r 'HEAD:"$dir"' \
76 \| sed -n '"s/^100[^ ]*./$sed_esc/p"' $postprocess
77 elif test -d .hg; then
78 eval exec hg locate '"$dir/*"' $postprocess
79 elif test -d .bzr; then
80 test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
81 eval exec bzr ls -R --versioned '"$dir"' $postprocess
82 elif test -d CVS; then
83 test "$postprocess" = '' && postprocess="| sed 's|^\./||'"
84 if test -x build-aux/cvsu; then
85 eval build-aux/cvsu --find --types=AFGM '"$dir"' $postprocess
86 elif (cvsu --help) >/dev/null 2>&1; then
87 eval cvsu --find --types=AFGM '"$dir"' $postprocess
88 else
89 eval awk -F/ \''{ \
90 if (!$1 && $3 !~ /^-/) { \
91 f=FILENAME; \
92 if (f ~ /CVS\/Entries$/) \
93 f = substr(f, 1, length(f)-11); \
94 print f $2; \
95 }}'\'' \
96 `find "$dir" -name Entries -print` /dev/null' $postprocess
97 fi
98 elif test -d .svn; then
99 eval exec svn list -R '"$dir"' $postprocess
100 else
101 echo "$0: Failed to determine type of version control used in `pwd`" 1>&2
102 exit 1
103 fi
104 done
105
106 # Local variables:
107 # eval: (add-hook 'write-file-hooks 'time-stamp)
108 # time-stamp-start: "scriptversion="
109 # time-stamp-format: "%:y-%02m-%02d.%02H"
110 # time-stamp-time-zone: "UTC"
111 # time-stamp-end: "; # UTC"
112 # End:
0 # Customize Makefile.maint. -*- makefile -*-
1 # Copyright (C) 2008-2011 Red Hat, Inc.
2 # Copyright (C) 2003-2008 Free Software Foundation, Inc.
3
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 # Tests not to run as part of "make distcheck".
18 local-checks-to-skip = \
19 changelog-check \
20 check-AUTHORS \
21 makefile-check \
22 makefile_path_separator_check \
23 patch-check \
24 sc_GPL_version \
25 sc_always_defined_macros \
26 sc_cast_of_alloca_return_value \
27 sc_cross_check_PATH_usage_in_tests \
28 sc_dd_max_sym_length \
29 sc_error_exit_success \
30 sc_file_system \
31 sc_immutable_NEWS \
32 sc_makefile_path_separator_check \
33 sc_obsolete_symbols \
34 sc_prohibit_always_true_header_tests \
35 sc_prohibit_S_IS_definition \
36 sc_prohibit_atoi_atof \
37 sc_prohibit_hash_without_use \
38 sc_prohibit_jm_in_m4 \
39 sc_prohibit_quote_without_use \
40 sc_prohibit_quotearg_without_use \
41 sc_prohibit_stat_st_blocks \
42 sc_root_tests \
43 sc_space_tab \
44 sc_sun_os_names \
45 sc_system_h_headers \
46 sc_texinfo_acronym \
47 sc_tight_scope \
48 sc_two_space_separator_in_usage \
49 sc_error_message_uppercase \
50 sc_program_name \
51 sc_require_test_exit_idiom \
52 sc_makefile_check \
53 sc_useless_cpp_parens
54
55 # Files that should never cause syntax check failures.
56 VC_LIST_ALWAYS_EXCLUDE_REGEX = \
57 (^HACKING|\.po|maint.mk)$$
58
59 # Functions like free() that are no-ops on NULL arguments.
60 useless_free_options = \
61 --name=g_free \
62 --name=xmlBufferFree \
63 --name=xmlFree \
64 --name=xmlFreeDoc \
65 --name=xmlXPathFreeContext \
66 --name=xmlFreeParserContext \
67 --name=xmlXPathFreeObject
68
69 # Ensure that no C source file, docs, or rng schema uses TABs for
70 # indentation. Also match *.h.in files, to get libvirt.h.in. Exclude
71 # files in gnulib, since they're imported.
72 space_indent_files=(\.(rng|s?[ch](\.in)?|html.in|py)|(daemon|tools)/.*\.in)
73 sc_TAB_in_indentation:
74 @prohibit='^ * ' \
75 in_vc_files='$(space_indent_files)$$' \
76 halt='indent with space, not TAB, in C, sh, html, py, and RNG schemas' \
77 $(_sc_search_regexp)
78
79 # G_GNUC_UNUSED should only be applied in implementations, not
80 # header declarations
81 sc_avoid_attribute_unused_in_header:
82 @prohibit='^[^#]*G_GNUC_UNUSED([^:]|$$)' \
83 in_vc_files='\.h$$' \
84 halt='use G_GNUC_UNUSED in .c rather than .h files' \
85 $(_sc_search_regexp)
86
87 # Enforce recommended preprocessor indentation style.
88 sc_preprocessor_indentation:
89 @if cppi --version >/dev/null 2>&1; then \
90 $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
91 || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
92 exit 1; }; \
93 else \
94 echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
95 fi
96
97 sc_copyright_format:
98 @require='Copyright .*Red 'Hat', Inc\.' \
99 containing='Copyright .*Red 'Hat \
100 halt='Red Hat copyright is missing Inc.' \
101 $(_sc_search_regexp)
102 @prohibit='Copyright [^(].*Red 'Hat \
103 halt='consistently use (C) in Red Hat copyright' \
104 $(_sc_search_regexp)
105 @prohibit='\<Red''Hat\>' \
106 halt='spell Red Hat as two words' \
107 $(_sc_search_regexp)
108
109 # We don't use this feature of maint.mk.
110 prev_version_file = /dev/null
111
112 # Give credit where due:
113 # Ensure that each commit author email address (possibly mapped via
114 # git log's .mailmap) appears in our AUTHORS file.
115 sc_check_author_list:
116 @fail=0; \
117 for i in $$(git log --pretty=format:%aE%n|sort -u|grep -v '^$$'); do \
118 sanitized=$$(echo "$$i"|LC_ALL=C sed 's/\([^a-zA-Z0-9_@-]\)/\\\1/g'); \
119 grep -iq "<$$sanitized>" $(srcdir)/AUTHORS \
120 || { printf '%s\n' "$$i" >&2; fail=1; }; \
121 done; \
122 test $$fail = 1 \
123 && echo '$(ME): committer(s) not listed in AUTHORS' >&2; \
124 test $$fail = 0
125
126
127 exclude_file_name_regexp--sc_preprocessor_indentation = ^*/*.[ch]
128 exclude_file_name_regexp--sc_prohibit_strcmp = ^*/*.[ch]
129 exclude_file_name_regexp--sc_require_config_h = ^plugin/
130 exclude_file_name_regexp--sc_require_config_h_first = ^plugin/
2424 AC_CONFIG_LIBOBJ_DIR([src])
2525
2626 AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions])
27
28 # Autoconf 2.61a.99 and earlier don't support linking a file only
29 # in VPATH builds. But since GNUmakefile is for maintainer use
30 # only, it does not matter if we skip the link with older autoconf.
31 # Automake 1.10.1 and earlier try to remove GNUmakefile in non-VPATH
32 # builds, so use a shell variable to bypass this.
33 GNUmakefile=GNUmakefile
34 m4_if(m4_version_compare([2.61a.100],
35 m4_defn([m4_PACKAGE_VERSION])), [1], [],
36 [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [],
37 [GNUmakefile=$GNUmakefile])])
2738
2839 VIRT_VIEWER_COMPILE_WARNINGS(maximum)
2940
0 # -*-Makefile-*-
1 # This Makefile fragment tries to be general-purpose enough to be
2 # used by many projects via the gnulib maintainer-makefile module.
3
4 ## Copyright (C) 2001-2011 Free Software Foundation, Inc.
5 ##
6 ## This program is free software: you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, either version 3 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 # This is reported not to work with make-3.79.1
20 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
21 ME := maint.mk
22
23 # Diagnostic for continued use of deprecated variable.
24 # Remove in 2013
25 ifneq ($(build_aux),)
26 $(error "$(ME): \
27 set $$(_build-aux) relative to $$(srcdir) instead of $$(build_aux)")
28 endif
29
30 # Do not save the original name or timestamp in the .tar.gz file.
31 # Use --rsyncable if available.
32 gzip_rsyncable := \
33 $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null \
34 && printf %s --rsyncable)
35 GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
36
37 GIT = git
38 VC = $(GIT)
39
40 VC_LIST = $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir)
41
42 # You can override this variable in cfg.mk to set your own regexp
43 # matching files to ignore.
44 VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$
45
46 # This is to preprocess robustly the output of $(VC_LIST), so that even
47 # when $(srcdir) is a pathological name like "....", the leading sed command
48 # removes only the intended prefix.
49 _dot_escaped_srcdir = $(subst .,\.,$(srcdir))
50
51 # Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
52 # when $(srcdir) is not ".".
53 ifeq ($(srcdir),.)
54 _prepend_srcdir_prefix =
55 else
56 _prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
57 endif
58
59 # In order to be able to consistently filter "."-relative names,
60 # (i.e., with no $(srcdir) prefix), this definition is careful to
61 # remove any $(srcdir) prefix, and to restore what it removes.
62 _sc_excl = \
63 $(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
64 VC_LIST_EXCEPT = \
65 $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
66 | if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
67 else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
68 | grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
69 $(_prepend_srcdir_prefix)
70
71 ifeq ($(origin prev_version_file), undefined)
72 prev_version_file = $(srcdir)/.prev-version
73 endif
74
75 PREV_VERSION := $(shell cat $(prev_version_file) 2>/dev/null)
76 VERSION_REGEXP = $(subst .,\.,$(VERSION))
77 PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
78
79 ifeq ($(VC),$(GIT))
80 this-vc-tag = v$(VERSION)
81 this-vc-tag-regexp = v$(VERSION_REGEXP)
82 else
83 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
84 tag-this-version = $(subst .,_,$(VERSION))
85 this-vc-tag = $(tag-package)-$(tag-this-version)
86 this-vc-tag-regexp = $(this-vc-tag)
87 endif
88 my_distdir = $(PACKAGE)-$(VERSION)
89
90 # Old releases are stored here.
91 release_archive_dir ?= ../release
92
93 # Override gnu_rel_host and url_dir_list in cfg.mk if these are not right.
94 # Use alpha.gnu.org for alpha and beta releases.
95 # Use ftp.gnu.org for stable releases.
96 gnu_ftp_host-alpha = alpha.gnu.org
97 gnu_ftp_host-beta = alpha.gnu.org
98 gnu_ftp_host-stable = ftp.gnu.org
99 gnu_rel_host ?= $(gnu_ftp_host-$(RELEASE_TYPE))
100
101 ifeq ($(gnu_rel_host),ftp.gnu.org)
102 url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE)
103 else
104 url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
105 endif
106
107 # Override this in cfg.mk if you are using a different format in your
108 # NEWS file.
109 today = $(shell date +%Y-%m-%d)
110
111 # Select which lines of NEWS are searched for $(news-check-regexp).
112 # This is a sed line number spec. The default says that we search
113 # lines 1..10 of NEWS for $(news-check-regexp).
114 # If you want to search only line 3 or only lines 20-22, use "3" or "20,22".
115 news-check-lines-spec ?= 1,10
116 news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)'
117
118 # Prevent programs like 'sort' from considering distinct strings to be equal.
119 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
120 export LC_ALL = C
121
122 ## --------------- ##
123 ## Sanity checks. ##
124 ## --------------- ##
125
126 _cfg_mk := $(shell test -f $(srcdir)/cfg.mk && echo '$(srcdir)/cfg.mk')
127
128 # Collect the names of rules starting with `sc_'.
129 syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
130 $(srcdir)/$(ME) $(_cfg_mk)))
131 .PHONY: $(syntax-check-rules)
132
133 ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0)
134 local-checks-available += $(syntax-check-rules)
135 else
136 local-checks-available += no-vc-detected
137 no-vc-detected:
138 @echo "No version control files detected; skipping syntax check"
139 endif
140 .PHONY: $(local-checks-available)
141
142 # Arrange to print the name of each syntax-checking rule just before running it.
143 $(syntax-check-rules): %: %.m
144 sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules))
145 .PHONY: $(sc_m_rules_)
146 $(sc_m_rules_):
147 @echo $(patsubst sc_%.m, %, $@)
148 @date +%s.%N > .sc-start-$(basename $@)
149
150 # Compute and print the elapsed time for each syntax-check rule.
151 sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules))
152 .PHONY: $(sc_z_rules_)
153 $(sc_z_rules_): %.z: %
154 @end=$$(date +%s.%N); \
155 start=$$(cat .sc-start-$*); \
156 rm -f .sc-start-$*; \
157 awk -v s=$$start -v e=$$end \
158 'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null
159
160 # The patsubst here is to replace each sc_% rule with its sc_%.z wrapper
161 # that computes and prints elapsed time.
162 local-check := \
163 $(patsubst sc_%, sc_%.z, \
164 $(filter-out $(local-checks-to-skip), $(local-checks-available)))
165
166 syntax-check: $(local-check)
167
168 # _sc_search_regexp
169 #
170 # This macro searches for a given construct in the selected files and
171 # then takes some action.
172 #
173 # Parameters (shell variables):
174 #
175 # prohibit | require
176 #
177 # Regular expression (ERE) denoting either a forbidden construct
178 # or a required construct. Those arguments are exclusive.
179 #
180 # in_vc_files | in_files
181 #
182 # grep-E-style regexp denoting the files to check. If no files
183 # are specified the default are all the files that are under
184 # version control.
185 #
186 # containing | non_containing
187 #
188 # Select the files (non) containing strings matching this regexp.
189 # If both arguments are specified then CONTAINING takes
190 # precedence.
191 #
192 # with_grep_options
193 #
194 # Extra options for grep.
195 #
196 # ignore_case
197 #
198 # Ignore case.
199 #
200 # halt
201 #
202 # Message to display before to halting execution.
203 #
204 # Finally, you may exempt files based on an ERE matching file names.
205 # For example, to exempt from the sc_space_tab check all files with the
206 # .diff suffix, set this Make variable:
207 #
208 # exclude_file_name_regexp--sc_space_tab = \.diff$
209 #
210 # Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
211 # when filtering by name via in_files, we explicitly filter out matching
212 # names here as well.
213
214 # By default, _sc_search_regexp does not ignore case.
215 export ignore_case =
216 _ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :)
217
218 define _sc_say_and_exit
219 dummy=; : so we do not need a semicolon before each use; \
220 { printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; };
221 endef
222
223 # _sc_search_regexp used to be named _prohibit_regexp. However,
224 # upgrading to the new definition and leaving the old name undefined
225 # would usually convert each custom rule using $(_prohibit_regexp)
226 # (usually defined in cfg.mk) into a no-op. This definition ensures
227 # that people know right away if they're still using the old name.
228 # FIXME: remove in 2012.
229 _prohibit_regexp = \
230 $(error '*** you need to s/_prohibit_regexp/_sc_search_regexp/, and adapt')
231
232 define _sc_search_regexp
233 dummy=; : so we do not need a semicolon before each use; \
234 \
235 : Check arguments; \
236 test -n "$$prohibit" && test -n "$$require" \
237 && { msg='Cannot specify both prohibit and require' \
238 $(_sc_say_and_exit) } || :; \
239 test -z "$$prohibit" && test -z "$$require" \
240 && { msg='Should specify either prohibit or require' \
241 $(_sc_say_and_exit) } || :; \
242 test -n "$$in_vc_files" && test -n "$$in_files" \
243 && { msg='Cannot specify both in_vc_files and in_files' \
244 $(_sc_say_and_exit) } || :; \
245 test "x$$halt" != x \
246 || { msg='halt not defined' $(_sc_say_and_exit) }; \
247 \
248 : Filter by file name; \
249 if test -n "$$in_files"; then \
250 files=$$(find $(srcdir) | grep -E "$$in_files" \
251 | grep -Ev '$(exclude_file_name_regexp--$@)'); \
252 else \
253 files=$$($(VC_LIST_EXCEPT)); \
254 if test -n "$$in_vc_files"; then \
255 files=$$(echo "$$files" | grep -E "$$in_vc_files"); \
256 fi; \
257 fi; \
258 \
259 : Filter by content; \
260 test -n "$$files" && test -n "$$containing" \
261 && { files=$$(grep -l "$$containing" $$files); } || :; \
262 test -n "$$files" && test -n "$$non_containing" \
263 && { files=$$(grep -vl "$$non_containing" $$files); } || :; \
264 \
265 : Check for the construct; \
266 if test -n "$$files"; then \
267 if test -n "$$prohibit"; then \
268 grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
269 && { msg="$$halt" $(_sc_say_and_exit) } || :; \
270 else \
271 grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
272 | grep . \
273 && { msg="$$halt" $(_sc_say_and_exit) } || :; \
274 fi \
275 else :; \
276 fi || :;
277 endef
278
279 sc_avoid_if_before_free:
280 @$(srcdir)/$(_build-aux)/useless-if-before-free \
281 $(useless_free_options) \
282 $$($(VC_LIST_EXCEPT) | grep -v useless-if-before-free) && \
283 { echo '$(ME): found useless "if" before "free" above' 1>&2; \
284 exit 1; } || :
285
286 sc_cast_of_argument_to_free:
287 @prohibit='\<free *\( *\(' halt='don'\''t cast free argument' \
288 $(_sc_search_regexp)
289
290 sc_cast_of_x_alloc_return_value:
291 @prohibit='\*\) *x(m|c|re)alloc\>' \
292 halt='don'\''t cast x*alloc return value' \
293 $(_sc_search_regexp)
294
295 sc_cast_of_alloca_return_value:
296 @prohibit='\*\) *alloca\>' \
297 halt='don'\''t cast alloca return value' \
298 $(_sc_search_regexp)
299
300 sc_space_tab:
301 @prohibit='[ ] ' \
302 halt='found SPACE-TAB sequence; remove the SPACE' \
303 $(_sc_search_regexp)
304
305 # Don't use *scanf or the old ato* functions in `real' code.
306 # They provide no error checking mechanism.
307 # Instead, use strto* functions.
308 sc_prohibit_atoi_atof:
309 @prohibit='\<([fs]?scanf|ato([filq]|ll)) *\(' \
310 halt='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
311 $(_sc_search_regexp)
312
313 # Use STREQ rather than comparing strcmp == 0, or != 0.
314 sc_prohibit_strcmp:
315 @grep -nE '! *str''cmp *\(|\<str''cmp *\(.+\) *[!=]=' \
316 $$($(VC_LIST_EXCEPT)) \
317 | grep -vE ':# *define STRN?EQ\(' && \
318 { echo '$(ME): replace str''cmp calls above with STREQ/STRNEQ' \
319 1>&2; exit 1; } || :
320
321 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
322 # Convert all uses automatically, via these two commands:
323 # git grep -l '\<exit *(1)' \
324 # | grep -vEf .x-sc_prohibit_magic_number_exit \
325 # | xargs --no-run-if-empty \
326 # perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
327 # git grep -l '\<exit *(0)' \
328 # | grep -vEf .x-sc_prohibit_magic_number_exit \
329 # | xargs --no-run-if-empty \
330 # perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
331 sc_prohibit_magic_number_exit:
332 @prohibit='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \
333 halt='use EXIT_* values rather than magic number' \
334 $(_sc_search_regexp)
335
336 # Using EXIT_SUCCESS as the first argument to error is misleading,
337 # since when that parameter is 0, error does not exit. Use `0' instead.
338 sc_error_exit_success:
339 @prohibit='error *\(EXIT_SUCCESS,' \
340 in_vc_files='\.[chly]$$' \
341 halt='found error (EXIT_SUCCESS' \
342 $(_sc_search_regexp)
343
344 # `FATAL:' should be fully upper-cased in error messages
345 # `WARNING:' should be fully upper-cased, or fully lower-cased
346 sc_error_message_warn_fatal:
347 @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
348 | grep -E '"Warning|"Fatal|"fatal' && \
349 { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
350 exit 1; } || :
351
352 # Error messages should not start with a capital letter
353 sc_error_message_uppercase:
354 @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
355 | grep -E '"[A-Z]' \
356 | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
357 { echo '$(ME): found capitalized error message' 1>&2; \
358 exit 1; } || :
359
360 # Error messages should not end with a period
361 sc_error_message_period:
362 @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
363 | grep -E '[^."]\."' && \
364 { echo '$(ME): found error message ending in period' 1>&2; \
365 exit 1; } || :
366
367 sc_file_system:
368 @prohibit=file''system \
369 ignore_case=1 \
370 halt='found use of "file''system"; spell it "file system"' \
371 $(_sc_search_regexp)
372
373 # Don't use cpp tests of this symbol. All code assumes config.h is included.
374 sc_prohibit_have_config_h:
375 @prohibit='^# *if.*HAVE''_CONFIG_H' \
376 halt='found use of HAVE''_CONFIG_H; remove' \
377 $(_sc_search_regexp)
378
379 # Nearly all .c files must include <config.h>. However, we also permit this
380 # via inclusion of a package-specific header, if cfg.mk specified one.
381 # config_h_header must be suitable for grep -E.
382 config_h_header ?= <config\.h>
383 sc_require_config_h:
384 @require='^# *include $(config_h_header)' \
385 in_vc_files='\.c$$' \
386 halt='the above files do not include <config.h>' \
387 $(_sc_search_regexp)
388
389 # You must include <config.h> before including any other header file.
390 # This can possibly be via a package-specific header, if given by cfg.mk.
391 sc_require_config_h_first:
392 @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
393 fail=0; \
394 for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \
395 grep '^# *include\>' $$i | sed 1q \
396 | grep -E '^# *include $(config_h_header)' > /dev/null \
397 || { echo $$i; fail=1; }; \
398 done; \
399 test $$fail = 1 && \
400 { echo '$(ME): the above files include some other header' \
401 'before <config.h>' 1>&2; exit 1; } || :; \
402 else :; \
403 fi
404
405 sc_prohibit_HAVE_MBRTOWC:
406 @prohibit='\bHAVE_MBRTOWC\b' \
407 halt="do not use $$prohibit; it is always defined" \
408 $(_sc_search_regexp)
409
410 # To use this "command" macro, you must first define two shell variables:
411 # h: the header name, with no enclosing <> or ""
412 # re: a regular expression that matches IFF something provided by $h is used.
413 define _sc_header_without_use
414 dummy=; : so we do not need a semicolon before each use; \
415 h_esc=`echo '[<"]'"$$h"'[">]'|sed 's/\./\\\\./g'`; \
416 if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
417 files=$$(grep -l '^# *include '"$$h_esc" \
418 $$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
419 grep -LE "$$re" $$files | grep . && \
420 { echo "$(ME): the above files include $$h but don't use it" \
421 1>&2; exit 1; } || :; \
422 else :; \
423 fi
424 endef
425
426 # Prohibit the inclusion of assert.h without an actual use of assert.
427 sc_prohibit_assert_without_use:
428 @h='assert.h' re='\<assert *\(' $(_sc_header_without_use)
429
430 # Prohibit the inclusion of close-stream.h without an actual use.
431 sc_prohibit_close_stream_without_use:
432 @h='close-stream.h' re='\<close_stream *\(' $(_sc_header_without_use)
433
434 # Prohibit the inclusion of getopt.h without an actual use.
435 sc_prohibit_getopt_without_use:
436 @h='getopt.h' re='\<getopt(_long)? *\(' $(_sc_header_without_use)
437
438 # Don't include quotearg.h unless you use one of its functions.
439 sc_prohibit_quotearg_without_use:
440 @h='quotearg.h' re='\<quotearg(_[^ ]+)? *\(' $(_sc_header_without_use)
441
442 # Don't include quote.h unless you use one of its functions.
443 sc_prohibit_quote_without_use:
444 @h='quote.h' re='\<quote(_n)? *\(' $(_sc_header_without_use)
445
446 # Don't include this header unless you use one of its functions.
447 sc_prohibit_long_options_without_use:
448 @h='long-options.h' re='\<parse_long_options *\(' \
449 $(_sc_header_without_use)
450
451 # Don't include this header unless you use one of its functions.
452 sc_prohibit_inttostr_without_use:
453 @h='inttostr.h' re='\<(off|[iu]max|uint)tostr *\(' \
454 $(_sc_header_without_use)
455
456 # Don't include this header unless you use one of its functions.
457 sc_prohibit_ignore_value_without_use:
458 @h='ignore-value.h' re='\<ignore_(value|ptr) *\(' \
459 $(_sc_header_without_use)
460
461 # Don't include this header unless you use one of its functions.
462 sc_prohibit_error_without_use:
463 @h='error.h' \
464 re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
465 $(_sc_header_without_use)
466
467 # Don't include xalloc.h unless you use one of its functions.
468 # Consider these symbols:
469 # perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
470 # perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
471 # Divide into two sets on case, and filter each through this:
472 # | sort | perl -MRegexp::Assemble -le \
473 # 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
474 # Note this was produced by the above:
475 # _xa1 = \
476 #x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
477 # But we can do better, in at least two ways:
478 # 1) take advantage of two "dup"-suffixed strings:
479 # x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
480 # 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
481 # "char|[cmz]"
482 # x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
483 _xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
484 _xa2 = X([CZ]|N?M)ALLOC
485 sc_prohibit_xalloc_without_use:
486 @h='xalloc.h' \
487 re='\<($(_xa1)|$(_xa2)) *\('\
488 $(_sc_header_without_use)
489
490 # Extract function names:
491 # perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h
492 _hash_re = \
493 clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning
494 _hash_fn = \<($(_hash_re)) *\(
495 _hash_struct = (struct )?\<[Hh]ash_(table|tuning)\>
496 sc_prohibit_hash_without_use:
497 @h='hash.h' \
498 re='$(_hash_fn)|$(_hash_struct)'\
499 $(_sc_header_without_use)
500
501 sc_prohibit_cloexec_without_use:
502 @h='cloexec.h' re='\<(set_cloexec_flag|dup_cloexec) *\(' \
503 $(_sc_header_without_use)
504
505 sc_prohibit_posixver_without_use:
506 @h='posixver.h' re='\<posix2_version *\(' $(_sc_header_without_use)
507
508 sc_prohibit_same_without_use:
509 @h='same.h' re='\<same_name *\(' $(_sc_header_without_use)
510
511 sc_prohibit_hash_pjw_without_use:
512 @h='hash-pjw.h' \
513 re='\<hash_pjw *\(' \
514 $(_sc_header_without_use)
515
516 sc_prohibit_safe_read_without_use:
517 @h='safe-read.h' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
518 $(_sc_header_without_use)
519
520 sc_prohibit_argmatch_without_use:
521 @h='argmatch.h' \
522 re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<(invalid_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \
523 $(_sc_header_without_use)
524
525 sc_prohibit_canonicalize_without_use:
526 @h='canonicalize.h' \
527 re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode)' \
528 $(_sc_header_without_use)
529
530 sc_prohibit_root_dev_ino_without_use:
531 @h='root-dev-ino.h' \
532 re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
533 $(_sc_header_without_use)
534
535 sc_prohibit_openat_without_use:
536 @h='openat.h' \
537 re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat)\>' \
538 $(_sc_header_without_use)
539
540 # Prohibit the inclusion of c-ctype.h without an actual use.
541 ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
542 |isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
543 sc_prohibit_c_ctype_without_use:
544 @h='c-ctype.h' re='\<c_($(ctype_re)) *\(' \
545 $(_sc_header_without_use)
546
547 _empty =
548 _sp = $(_empty) $(_empty)
549 # The following list was generated by running:
550 # man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
551 # | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
552 _sig_functions = \
553 bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
554 sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
555 siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
556 sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
557 _sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
558 # The following were extracted from "man signal.h" manually.
559 _sig_types_and_consts = \
560 MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
561 SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
562 SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
563 SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
564 sigstack sigval stack_t ucontext_t
565 # generated via this:
566 # perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
567 _sig_names = \
568 SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
569 SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
570 SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
571 SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
572 SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
573 SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
574 SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
575 SIGXCPU SIGXFSZ
576 _sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
577
578 # Prohibit the inclusion of signal.h without an actual use.
579 sc_prohibit_signal_without_use:
580 @h='signal.h' \
581 re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
582 $(_sc_header_without_use)
583
584 # Don't include stdio--.h unless you use one of its functions.
585 sc_prohibit_stdio--_without_use:
586 @h='stdio--.h' re='\<((f(re)?|p)open|tmpfile) *\(' \
587 $(_sc_header_without_use)
588
589 # Don't include stdio-safer.h unless you use one of its functions.
590 sc_prohibit_stdio-safer_without_use:
591 @h='stdio-safer.h' re='\<((f(re)?|p)open|tmpfile)_safer *\(' \
592 $(_sc_header_without_use)
593
594 # Prohibit the inclusion of strings.h without a sensible use.
595 # Using the likes of bcmp, bcopy, bzero, index or rindex is not sensible.
596 sc_prohibit_strings_without_use:
597 @h='strings.h' \
598 re='\<(strn?casecmp|ffs(ll)?)\>' \
599 $(_sc_header_without_use)
600
601 # Get the list of symbol names with this:
602 # perl -lne '/^# *define ([A-Z]\w+)\(/ and print $1' lib/intprops.h|fmt
603 _intprops_names = \
604 TYPE_IS_INTEGER TYPE_TWOS_COMPLEMENT TYPE_ONES_COMPLEMENT \
605 TYPE_SIGNED_MAGNITUDE TYPE_SIGNED TYPE_MINIMUM TYPE_MAXIMUM \
606 INT_BITS_STRLEN_BOUND INT_STRLEN_BOUND INT_BUFSIZE_BOUND \
607 INT_ADD_RANGE_OVERFLOW INT_SUBTRACT_RANGE_OVERFLOW \
608 INT_NEGATE_RANGE_OVERFLOW INT_MULTIPLY_RANGE_OVERFLOW \
609 INT_DIVIDE_RANGE_OVERFLOW INT_REMAINDER_RANGE_OVERFLOW \
610 INT_LEFT_SHIFT_RANGE_OVERFLOW INT_ADD_OVERFLOW INT_SUBTRACT_OVERFLOW \
611 INT_NEGATE_OVERFLOW INT_MULTIPLY_OVERFLOW INT_DIVIDE_OVERFLOW \
612 INT_REMAINDER_OVERFLOW INT_LEFT_SHIFT_OVERFLOW
613 _intprops_syms_re = $(subst $(_sp),|,$(strip $(_intprops_names)))
614 # Prohibit the inclusion of intprops.h without an actual use.
615 sc_prohibit_intprops_without_use:
616 @h='intprops.h' \
617 re='\<($(_intprops_syms_re)) *\(' \
618 $(_sc_header_without_use)
619
620 _stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t
621 # Prohibit the inclusion of stddef.h without an actual use.
622 sc_prohibit_stddef_without_use:
623 @h='stddef.h' \
624 re='\<($(_stddef_syms_re))\>' \
625 $(_sc_header_without_use)
626
627 _de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)?
628 _de2 = (versionsort|struct dirent|getdirentries|alphasort|scandir(at)?)(64)?
629 _de3 = MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
630 _dirent_syms_re = $(_de1)|$(_de2)|$(_de3)
631 # Prohibit the inclusion of dirent.h without an actual use.
632 sc_prohibit_dirent_without_use:
633 @h='dirent.h' \
634 re='\<($(_dirent_syms_re))\>' \
635 $(_sc_header_without_use)
636
637 # Prohibit the inclusion of verify.h without an actual use.
638 sc_prohibit_verify_without_use:
639 @h='verify.h' \
640 re='\<(verify(true|expr)?|static_assert) *\(' \
641 $(_sc_header_without_use)
642
643 # Don't include xfreopen.h unless you use one of its functions.
644 sc_prohibit_xfreopen_without_use:
645 @h='xfreopen.h' re='\<xfreopen *\(' $(_sc_header_without_use)
646
647 sc_obsolete_symbols:
648 @prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
649 halt='do not use HAVE''_FCNTL_H or O'_NDELAY \
650 $(_sc_search_regexp)
651
652 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
653
654 # Each nonempty ChangeLog line must start with a year number, or a TAB.
655 sc_changelog:
656 @prohibit='^[^12 ]' \
657 in_vc_files='^ChangeLog$$' \
658 halt='found unexpected prefix in a ChangeLog' \
659 $(_sc_search_regexp)
660
661 # Ensure that each .c file containing a "main" function also
662 # calls set_program_name.
663 sc_program_name:
664 @require='set_program_name *\(m?argv\[0\]\);' \
665 in_vc_files='\.c$$' \
666 containing='\<main *(' \
667 halt='the above files do not call set_program_name' \
668 $(_sc_search_regexp)
669
670 # Ensure that each .c file containing a "main" function also
671 # calls bindtextdomain.
672 sc_bindtextdomain:
673 @require='bindtextdomain *\(' \
674 in_vc_files='\.c$$' \
675 containing='\<main *(' \
676 halt='the above files do not call bindtextdomain' \
677 $(_sc_search_regexp)
678
679 # Require that the final line of each test-lib.sh-using test be this one:
680 # Exit $fail
681 # Note: this test requires GNU grep's --label= option.
682 Exit_witness_file ?= tests/test-lib.sh
683 Exit_base := $(notdir $(Exit_witness_file))
684 sc_require_test_exit_idiom:
685 @if test -f $(srcdir)/$(Exit_witness_file); then \
686 die=0; \
687 for i in $$(grep -l -F 'srcdir/$(Exit_base)' \
688 $$($(VC_LIST) tests)); do \
689 tail -n1 $$i | grep '^Exit .' > /dev/null \
690 && : || { die=1; echo $$i; } \
691 done; \
692 test $$die = 1 && \
693 { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
694 echo 1>&2 'Exit something'; \
695 exit 1; } || :; \
696 fi
697
698 sc_trailing_blank:
699 @prohibit='[ ]$$' \
700 halt='found trailing blank(s)' \
701 $(_sc_search_regexp)
702
703 # Match lines like the following, but where there is only one space
704 # between the options and the description:
705 # -D, --all-repeated[=delimit-method] print all duplicate lines\n
706 longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
707 sc_two_space_separator_in_usage:
708 @prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
709 halt='help2man requires at least two spaces between an option and its description'\
710 $(_sc_search_regexp)
711
712 # A regexp matching function names like "error" that may be used
713 # to emit translatable messages.
714 _gl_translatable_diag_func_re ?= error
715
716 # Look for diagnostics that aren't marked for translation.
717 # This won't find any for which error's format string is on a separate line.
718 sc_unmarked_diagnostics:
719 @grep -nE \
720 '\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
721 $$($(VC_LIST_EXCEPT)) \
722 | grep -Ev '(_|ngettext ?)\(' && \
723 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
724 exit 1; } || :
725
726 # Avoid useless parentheses like those in this example:
727 # #if defined (SYMBOL) || defined (SYM2)
728 sc_useless_cpp_parens:
729 @prohibit='^# *if .*defined *\(' \
730 halt='found useless parentheses in cpp directive' \
731 $(_sc_search_regexp)
732
733 # List headers for which HAVE_HEADER_H is always true, assuming you are
734 # using the appropriate gnulib module. CAUTION: for each "unnecessary"
735 # #if HAVE_HEADER_H that you remove, be sure that your project explicitly
736 # requires the gnulib module that guarantees the usability of that header.
737 gl_assured_headers_ = \
738 cd $(gnulib_dir)/lib && echo *.in.h|sed 's/\.in\.h//g'
739
740 # Convert the list of names to upper case, and replace each space with "|".
741 az_ = abcdefghijklmnopqrstuvwxyz
742 AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ
743 gl_header_upper_case_or_ = \
744 $$($(gl_assured_headers_) \
745 | tr $(az_)/.- $(AZ_)___ \
746 | tr -s ' ' '|' \
747 )
748 sc_prohibit_always_true_header_tests:
749 @or=$(gl_header_upper_case_or_); \
750 re="HAVE_($$or)_H"; \
751 prohibit='\<'"$$re"'\>' \
752 halt=$$(printf '%s\n' \
753 'do not test the above HAVE_<header>_H symbol(s);' \
754 ' with the corresponding gnulib module, they are always true') \
755 $(_sc_search_regexp)
756
757 # ==================================================================
758 gl_other_headers_ ?= \
759 intprops.h \
760 openat.h \
761 stat-macros.h
762
763 # Perl -lne code to extract "significant" cpp-defined symbols from a
764 # gnulib header file, eliminating a few common false-positives.
765 # The exempted names below are defined only conditionally in gnulib,
766 # and hence sometimes must/may be defined in application code.
767 gl_extract_significant_defines_ = \
768 /^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\
769 && $$2 !~ /(?:rpl_|_used_without_)/\
770 && $$1 !~ /^(?:NSIG|ENODATA)$$/\
771 && $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\
772 and print $$1
773
774 # Create a list of regular expressions matching the names
775 # of macros that are guaranteed to be defined by parts of gnulib.
776 define def_sym_regex
777 gen_h=$(gl_generated_headers_); \
778 (cd $(gnulib_dir)/lib; \
779 for f in *.in.h $(gl_other_headers_); do \
780 test -f $$f \
781 && perl -lne '$(gl_extract_significant_defines_)' $$f; \
782 done; \
783 ) | sort -u \
784 | sed 's/^/^ *# *(define|undef) */;s/$$/\\>/'
785 endef
786
787 # Don't define macros that we already get from gnulib header files.
788 sc_prohibit_always-defined_macros:
789 @if test -d $(gnulib_dir); then \
790 case $$(echo all: | grep -l -f - Makefile) in Makefile);; *) \
791 echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \
792 esac; \
793 $(def_sym_regex) | grep -E -f - $$($(VC_LIST_EXCEPT)) \
794 && { echo '$(ME): define the above via some gnulib .h file' \
795 1>&2; exit 1; } || :; \
796 fi
797 # ==================================================================
798
799 # Prohibit checked in backup files.
800 sc_prohibit_backup_files:
801 @$(VC_LIST) | grep '~$$' && \
802 { echo '$(ME): found version controlled backup file' 1>&2; \
803 exit 1; } || :
804
805 # Require the latest GPL.
806 sc_GPL_version:
807 @prohibit='either ''version [^3]' \
808 halt='GPL vN, N!=3' \
809 $(_sc_search_regexp)
810
811 # Require the latest GFDL. Two regexp, since some .texi files end up
812 # line wrapping between 'Free Documentation License,' and 'Version'.
813 _GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any)
814 sc_GFDL_version:
815 @prohibit='$(_GFDL_regexp)' \
816 halt='GFDL vN, N!=3' \
817 $(_sc_search_regexp)
818
819 # Don't use Texinfo's @acronym{}.
820 # http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00321.html
821 texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$
822 sc_texinfo_acronym:
823 @prohibit='@acronym\{' \
824 in_vc_files='$(texinfo_suffix_re_)' \
825 halt='found use of Texinfo @acronym{}' \
826 $(_sc_search_regexp)
827
828 cvs_keywords = \
829 Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
830
831 sc_prohibit_cvs_keyword:
832 @prohibit='\$$($(cvs_keywords))\$$' \
833 halt='do not use CVS keyword expansion' \
834 $(_sc_search_regexp)
835
836 # This Perl code is slightly obfuscated. Not only is each "$" doubled
837 # because it's in a Makefile, but the $$c's are comments; we cannot
838 # use "#" due to the way the script ends up concatenated onto one line.
839 # It would be much more concise, and would produce better output (including
840 # counts) if written as:
841 # perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
842 # but that would be far less efficient, reading the entire contents
843 # of each file, rather than just the last two bytes of each.
844 # In addition, while the code below detects both blank lines and a missing
845 # newline at EOF, the above detects only the former.
846 #
847 # This is a perl script that is expected to be the single-quoted argument
848 # to a command-line "-le". The remaining arguments are file names.
849 # Print the name of each file that ends in exactly one newline byte.
850 # I.e., warn if there are blank lines (2 or more newlines), or if the
851 # last byte is not a newline. However, currently we don't complain
852 # about any file that contains exactly one byte.
853 # Exit nonzero if at least one such file is found, otherwise, exit 0.
854 # Warn about, but otherwise ignore open failure. Ignore seek/read failure.
855 #
856 # Use this if you want to remove trailing empty lines from selected files:
857 # perl -pi -0777 -e 's/\n\n+$/\n/' files...
858 #
859 require_exactly_one_NL_at_EOF_ = \
860 foreach my $$f (@ARGV) \
861 { \
862 open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \
863 my $$p = sysseek (F, -2, 2); \
864 my $$c = "seek failure probably means file has < 2 bytes; ignore"; \
865 my $$last_two_bytes; \
866 defined $$p and $$p = sysread F, $$last_two_bytes, 2; \
867 close F; \
868 $$c = "ignore read failure"; \
869 $$p && ($$last_two_bytes eq "\n\n" \
870 || substr ($$last_two_bytes,1) ne "\n") \
871 and (print $$f), $$fail=1; \
872 } \
873 END { exit defined $$fail }
874 sc_prohibit_empty_lines_at_EOF:
875 @perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
876 || { echo '$(ME): empty line(s) or no newline at EOF' \
877 1>&2; exit 1; } || :
878
879 # Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
880 # This is a bit of a kludge, since it prevents use of the string
881 # even in comments, but for now it does the job with no false positives.
882 sc_prohibit_stat_st_blocks:
883 @prohibit='[.>]st_blocks' \
884 halt='do not use st_blocks; use ST_NBLOCKS' \
885 $(_sc_search_regexp)
886
887 # Make sure we don't define any S_IS* macros in src/*.c files.
888 # They're already defined via gnulib's sys/stat.h replacement.
889 sc_prohibit_S_IS_definition:
890 @prohibit='^ *# *define *S_IS' \
891 halt='do not define S_IS* macros; include <sys/stat.h>' \
892 $(_sc_search_regexp)
893
894 # Perl block to convert a match to FILE_NAME:LINENO:TEST,
895 # that is shared by two definitions below.
896 perl_filename_lineno_text_ = \
897 -e ' {' \
898 -e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \
899 -e ' ($$v = $$&) =~ s/\n/\\n/g;' \
900 -e ' print "$$ARGV:$$n:$$v\n";' \
901 -e ' }'
902
903 prohibit_doubled_word_RE_ ?= \
904 /\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims
905 prohibit_doubled_word_ = \
906 -e 'while ($(prohibit_doubled_word_RE_))' \
907 $(perl_filename_lineno_text_)
908
909 # Define this to a regular expression that matches
910 # any filename:dd:match lines you want to ignore.
911 # The default is to ignore no matches.
912 ignore_doubled_word_match_RE_ ?= ^$$
913
914 sc_prohibit_doubled_word:
915 @perl -n -0777 $(prohibit_doubled_word_) $$($(VC_LIST_EXCEPT)) \
916 | grep -vE '$(ignore_doubled_word_match_RE_)' \
917 | grep . && { echo '$(ME): doubled words' 1>&2; exit 1; } || :
918
919 # A regular expression matching undesirable combinations of words like
920 # "can not"; this matches them even when the two words appear on different
921 # lines, but not when there is an intervening delimiter like "#" or "*".
922 prohibit_undesirable_word_seq_RE_ ?= \
923 /\bcan\s+not\b/gims
924 prohibit_undesirable_word_seq_ = \
925 -e 'while ($(prohibit_undesirable_word_seq_RE_))' \
926 $(perl_filename_lineno_text_)
927 # Define this to a regular expression that matches
928 # any filename:dd:match lines you want to ignore.
929 # The default is to ignore no matches.
930 ignore_undesirable_word_sequence_RE_ ?= ^$$
931
932 sc_prohibit_undesirable_word_seq:
933 @perl -n -0777 $(prohibit_undesirable_word_seq_) \
934 $$($(VC_LIST_EXCEPT)) \
935 | grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep . \
936 && { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
937
938 _ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
939 _ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
940 # Using test's -a and -o operators is not portable.
941 # We prefer test over [, since the latter is spelled [[ in configure.ac.
942 sc_prohibit_test_minus_ao:
943 @prohibit='(\<test| \[+) .+ -[ao] ' \
944 halt='$(_ptm1); $(_ptm2)' \
945 $(_sc_search_regexp)
946
947 # Avoid a test bashism.
948 sc_prohibit_test_double_equal:
949 @prohibit='(\<test| \[+) .+ == ' \
950 containing='#! */bin/[a-z]*sh' \
951 halt='use "test x = x", not "test x =''= x"' \
952 $(_sc_search_regexp)
953
954 # Each program that uses proper_name_utf8 must link with one of the
955 # ICONV libraries. Otherwise, some ICONV library must appear in LDADD.
956 # The perl -0777 invocation below extracts the possibly-multi-line
957 # definition of LDADD from the appropriate Makefile.am and exits 0
958 # when it contains "ICONV".
959 sc_proper_name_utf8_requires_ICONV:
960 @progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
961 if test "x$$progs" != x; then \
962 fail=0; \
963 for p in $$progs; do \
964 dir=$$(dirname "$$p"); \
965 perl -0777 \
966 -ne 'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)' \
967 $$dir/Makefile.am && continue; \
968 base=$$(basename "$$p" .c); \
969 grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
970 || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
971 done; \
972 test $$fail = 1 && \
973 { echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
974 exit 1; } || :; \
975 fi
976
977 # Warn about "c0nst struct Foo const foo[]",
978 # but not about "char const *const foo" or "#define const const".
979 sc_redundant_const:
980 @prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
981 halt='redundant "const" in declarations' \
982 $(_sc_search_regexp)
983
984 sc_const_long_option:
985 @grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
986 | grep -Ev 'const struct option|struct option const' && { \
987 echo 1>&2 '$(ME): add "const" to the above declarations'; \
988 exit 1; } || :
989
990 NEWS_hash = \
991 $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
992 $(srcdir)/NEWS \
993 | perl -0777 -pe \
994 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \
995 | md5sum - \
996 | sed 's/ .*//')
997
998 # Ensure that we don't accidentally insert an entry into an old NEWS block.
999 sc_immutable_NEWS:
1000 @if test -f $(srcdir)/NEWS; then \
1001 test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
1002 { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
1003 fi
1004
1005 # Update the hash stored above. Do this after each release and
1006 # for any corrections to old entries.
1007 update-NEWS-hash: NEWS
1008 perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \
1009 $(srcdir)/cfg.mk
1010
1011 # Ensure that we use only the standard $(VAR) notation,
1012 # not @...@ in Makefile.am, now that we can rely on automake
1013 # to emit a definition for each substituted variable.
1014 # However, there is still one case in which @VAR@ use is not just
1015 # legitimate, but actually required: when augmenting an automake-defined
1016 # variable with a prefix. For example, gettext uses this:
1017 # MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
1018 # otherwise, makeinfo would put German or French (current locale)
1019 # navigation hints in the otherwise-English documentation.
1020 #
1021 # Allow the package to add exceptions via a hook in cfg.mk;
1022 # for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
1023 # setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
1024 _makefile_at_at_check_exceptions ?=
1025 sc_makefile_at_at_check:
1026 @perl -ne '/\@[A-Z_0-9]+\@/' \
1027 -e ' && !/([A-Z_0-9]+)\s+=.*\@\1\@$$/' \
1028 -e ''$(_makefile_at_at_check_exceptions) \
1029 -e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
1030 $$($(VC_LIST_EXCEPT) | grep -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \
1031 && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
1032
1033 news-check: NEWS
1034 if sed -n $(news-check-lines-spec)p $(srcdir)/NEWS \
1035 | grep -E $(news-check-regexp) >/dev/null; then \
1036 :; \
1037 else \
1038 echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
1039 exit 1; \
1040 fi
1041
1042 sc_makefile_TAB_only_indentation:
1043 @prohibit='^ [ ]{8}' \
1044 in_vc_files='akefile|\.mk$$' \
1045 halt='found TAB-8-space indentation' \
1046 $(_sc_search_regexp)
1047
1048 sc_m4_quote_check:
1049 @prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
1050 in_vc_files='(^configure\.ac|\.m4)$$' \
1051 halt='quote the first arg to AC_DEF*' \
1052 $(_sc_search_regexp)
1053
1054 fix_po_file_diag = \
1055 'you have changed the set of files with translatable diagnostics;\n\
1056 apply the above patch\n'
1057
1058 # Verify that all source files using _() are listed in po/POTFILES.in.
1059 po_file ?= $(srcdir)/po/POTFILES.in
1060 generated_files ?= $(srcdir)/lib/*.[ch]
1061 sc_po_check:
1062 @if test -f $(po_file); then \
1063 grep -E -v '^(#|$$)' $(po_file) \
1064 | grep -v '^src/false\.c$$' | sort > $@-1; \
1065 files=; \
1066 for file in $$($(VC_LIST_EXCEPT)) $(generated_files); do \
1067 test -r $$file || continue; \
1068 case $$file in \
1069 *.m4|*.mk) continue ;; \
1070 *.?|*.??) ;; \
1071 *) continue;; \
1072 esac; \
1073 case $$file in \
1074 *.[ch]) \
1075 base=`expr " $$file" : ' \(.*\)\..'`; \
1076 { test -f $$base.l || test -f $$base.y; } && continue;; \
1077 esac; \
1078 files="$$files $$file"; \
1079 done; \
1080 grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
1081 | sed 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2; \
1082 diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
1083 || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
1084 rm -f $@-1 $@-2; \
1085 fi
1086
1087 # Sometimes it is useful to change the PATH environment variable
1088 # in Makefiles. When doing so, it's better not to use the Unix-centric
1089 # path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'.
1090 msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead'
1091 sc_makefile_path_separator_check:
1092 @prohibit='PATH[=].*:' \
1093 in_vc_files='akefile|\.mk$$' \
1094 halt=$(msg) \
1095 $(_sc_search_regexp)
1096
1097 # Check that `make alpha' will not fail at the end of the process,
1098 # i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release)
1099 # and is read-only.
1100 writable-files:
1101 if test -d $(release_archive_dir); then \
1102 for file in $(DIST_ARCHIVES); do \
1103 for p in ./ $(release_archive_dir)/; do \
1104 test -e $$p$$file || continue; \
1105 test -w $$p$$file \
1106 || { echo ERROR: $$p$$file is not writable; fail=1; }; \
1107 done; \
1108 done; \
1109 test "$$fail" && exit 1 || : ; \
1110 else :; \
1111 fi
1112
1113 v_etc_file = $(gnulib_dir)/lib/version-etc.c
1114 sample-test = tests/sample-test
1115 texi = doc/$(PACKAGE).texi
1116 # Make sure that the copyright date in $(v_etc_file) is up to date.
1117 # Do the same for the $(sample-test) and the main doc/.texi file.
1118 sc_copyright_check:
1119 @require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \
1120 in_files=$(v_etc_file) \
1121 halt='out of date copyright in $(v_etc_file); update it' \
1122 $(_sc_search_regexp)
1123 @require='# Copyright \(C\) '$$(date +%Y)' Free' \
1124 in_vc_files=$(sample-test) \
1125 halt='out of date copyright in $(sample-test); update it' \
1126 $(_sc_search_regexp)
1127 @require='Copyright @copyright\{\} .*'$$(date +%Y)' Free' \
1128 in_vc_files=$(texi) \
1129 halt='out of date copyright in $(texi); update it' \
1130 $(_sc_search_regexp)
1131
1132 # If tests/help-version exists and seems to be new enough, assume that its
1133 # use of init.sh and path_prepend_ is correct, and ensure that every other
1134 # use of init.sh is identical.
1135 # This is useful because help-version cross-checks prog --version
1136 # with $(VERSION), which verifies that its path_prepend_ invocation
1137 # sets PATH correctly. This is an inexpensive way to ensure that
1138 # the other init.sh-using tests also get it right.
1139 _hv_file ?= $(srcdir)/tests/help-version
1140 _hv_regex_weak ?= ^ *\. .*/init\.sh"
1141 # Fix syntax-highlighters "
1142 _hv_regex_strong ?= ^ *\. "\$${srcdir=\.}/init\.sh"
1143 sc_cross_check_PATH_usage_in_tests:
1144 @if test -f $(_hv_file); then \
1145 grep -l 'VERSION mismatch' $(_hv_file) >/dev/null \
1146 || { echo "$@: skipped: no such file: $(_hv_file)" 1>&2; \
1147 exit 0; }; \
1148 grep -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null \
1149 || { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \
1150 exit 1; }; \
1151 good=$$(grep -E '$(_hv_regex_strong)' $(_hv_file)); \
1152 grep -LFx "$$good" \
1153 $$(grep -lE '$(_hv_regex_weak)' $$($(VC_LIST_EXCEPT))) \
1154 | grep . && \
1155 { echo "$(ME): the above files use path_prepend_ inconsistently" \
1156 1>&2; exit 1; } || :; \
1157 fi
1158
1159 # #if HAVE_... will evaluate to false for any non numeric string.
1160 # That would be flagged by using -Wundef, however gnulib currently
1161 # tests many undefined macros, and so we can't enable that option.
1162 # So at least preclude common boolean strings as macro values.
1163 sc_Wundef_boolean:
1164 @prohibit='^#define.*(yes|no|true|false)$$' \
1165 in_files='$(CONFIG_INCLUDE)' \
1166 halt='Use 0 or 1 for macro values' \
1167 $(_sc_search_regexp)
1168
1169 # Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might
1170 # not be constant, or might overflow a stack. In general, use PATH_MAX as
1171 # a limit, not an array or alloca size.
1172 sc_prohibit_path_max_allocation:
1173 @prohibit='(\balloca *\([^)]*|\[[^]]*)PATH_MAX' \
1174 halt='Avoid stack allocations of size PATH_MAX' \
1175 $(_sc_search_regexp)
1176
1177 sc_vulnerable_makefile_CVE-2009-4029:
1178 @prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
1179 in_files=$$(find $(srcdir) -name Makefile.in) \
1180 halt=$$(printf '%s\n' \
1181 'the above files are vulnerable; beware of running' \
1182 ' "make dist*" rules, and upgrade to fixed automake' \
1183 ' see http://bugzilla.redhat.com/542609 for details') \
1184 $(_sc_search_regexp)
1185
1186 vc-diff-check:
1187 (unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :
1188 if test -s vc-diffs; then \
1189 cat vc-diffs; \
1190 echo "Some files are locally modified:" 1>&2; \
1191 exit 1; \
1192 else \
1193 rm vc-diffs; \
1194 fi
1195
1196 rel-files = $(DIST_ARCHIVES)
1197
1198 gnulib_dir ?= $(srcdir)/gnulib
1199 gnulib-version = $$(cd $(gnulib_dir) && git describe)
1200 bootstrap-tools ?= autoconf,automake,gnulib
1201
1202 # If it's not already specified, derive the GPG key ID from
1203 # the signed tag we've just applied to mark this release.
1204 gpg_key_ID ?= \
1205 $$(git cat-file tag v$(VERSION) > .ann-sig \
1206 && gpgv .ann-sig - < /dev/null 2>&1 \
1207 | sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig)
1208
1209 translation_project_ ?= coordinator@translationproject.org
1210
1211 # Make info-gnu the default only for a stable release.
1212 ifeq ($(RELEASE_TYPE),stable)
1213 announcement_Cc_ ?= $(translation_project_), $(PACKAGE_BUGREPORT)
1214 announcement_mail_headers_ ?= \
1215 To: info-gnu@gnu.org \
1216 Cc: $(announcement_Cc_) \
1217 Mail-Followup-To: $(PACKAGE_BUGREPORT)
1218 else
1219 announcement_Cc_ ?= $(translation_project_)
1220 announcement_mail_headers_ ?= \
1221 To: $(PACKAGE_BUGREPORT) \
1222 Cc: $(announcement_Cc_)
1223 endif
1224
1225 announcement: NEWS ChangeLog $(rel-files)
1226 @$(srcdir)/$(_build-aux)/announce-gen \
1227 --mail-headers='$(announcement_mail_headers_)' \
1228 --release-type=$(RELEASE_TYPE) \
1229 --package=$(PACKAGE) \
1230 --prev=$(PREV_VERSION) \
1231 --curr=$(VERSION) \
1232 --gpg-key-id=$(gpg_key_ID) \
1233 --news=$(srcdir)/NEWS \
1234 --bootstrap-tools=$(bootstrap-tools) \
1235 --gnulib-version=$(gnulib-version) \
1236 --no-print-checksums \
1237 $(addprefix --url-dir=, $(url_dir_list))
1238
1239 ## ---------------- ##
1240 ## Updating files. ##
1241 ## ---------------- ##
1242
1243 ftp-gnu = ftp://ftp.gnu.org/gnu
1244 www-gnu = http://www.gnu.org
1245
1246 upload_dest_dir_ ?= $(PACKAGE)
1247 emit_upload_commands:
1248 @echo =====================================
1249 @echo =====================================
1250 @echo "$(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \\"
1251 @echo " --to $(gnu_rel_host):$(upload_dest_dir_) \\"
1252 @echo " $(rel-files)"
1253 @echo '# send the ~/announce-$(my_distdir) e-mail'
1254 @echo =====================================
1255 @echo =====================================
1256
1257 define emit-commit-log
1258 printf '%s\n' 'maint: post-release administrivia' '' \
1259 '* NEWS: Add header line for next release.' \
1260 '* .prev-version: Record previous version.' \
1261 '* cfg.mk (old_NEWS_hash): Auto-update.'
1262 endef
1263
1264 .PHONY: no-submodule-changes
1265 no-submodule-changes:
1266 if test -d $(srcdir)/.git; then \
1267 diff=$$(cd $(srcdir) && git submodule -q foreach \
1268 git diff-index --name-only HEAD) \
1269 || exit 1; \
1270 case $$diff in '') ;; \
1271 *) echo '$(ME): submodule files are locally modified:'; \
1272 echo "$$diff"; exit 1;; esac; \
1273 else \
1274 : ; \
1275 fi
1276
1277 submodule-checks ?= no-submodule-changes public-submodule-commit
1278
1279 # Ensure that each sub-module commit we're using is public.
1280 # Without this, it is too easy to tag and release code that
1281 # cannot be built from a fresh clone.
1282 .PHONY: public-submodule-commit
1283 public-submodule-commit:
1284 $(AM_V_GEN)if test -d $(srcdir)/.git; then \
1285 cd $(srcdir) && \
1286 git submodule --quiet foreach test '$$(git rev-parse $$sha1)' \
1287 = '$$(git merge-base origin $$sha1)' \
1288 || { echo '$(ME): found non-public submodule commit' >&2; \
1289 exit 1; }; \
1290 else \
1291 : ; \
1292 fi
1293 # This rule has a high enough utility/cost ratio that it should be a
1294 # dependent of "check" by default. However, some of us do occasionally
1295 # commit a temporary change that deliberately points to a non-public
1296 # submodule commit, and want to be able to use rules like "make check".
1297 # In that case, run e.g., "make check gl_public_submodule_commit="
1298 # to disable this test.
1299 gl_public_submodule_commit ?= public-submodule-commit
1300 check: $(gl_public_submodule_commit)
1301
1302 .PHONY: alpha beta stable
1303 ALL_RECURSIVE_TARGETS += alpha beta stable
1304 alpha beta stable: $(local-check) writable-files $(submodule-checks)
1305 test $@ = stable \
1306 && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
1307 || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
1308 || :
1309 $(MAKE) vc-diff-check
1310 $(MAKE) news-check
1311 $(MAKE) distcheck
1312 $(MAKE) dist XZ_OPT=-9ev
1313 $(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
1314 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
1315
1316 # Override this in cfg.mk if you follow different procedures.
1317 release-prep-hook ?= release-prep
1318
1319 gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?]
1320 .PHONY: release-prep
1321 release-prep:
1322 case $$RELEASE_TYPE in alpha|beta|stable) ;; \
1323 *) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac
1324 $(MAKE) --no-print-directory -s announcement > ~/announce-$(my_distdir)
1325 if test -d $(release_archive_dir); then \
1326 ln $(rel-files) $(release_archive_dir); \
1327 chmod a-w $(rel-files); \
1328 fi
1329 echo $(VERSION) > $(prev_version_file)
1330 $(MAKE) update-NEWS-hash
1331 perl -pi -e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' NEWS
1332 $(emit-commit-log) > .ci-msg
1333 $(VC) commit -F .ci-msg -a
1334 rm .ci-msg
1335
1336 # Override this with e.g., -s $(srcdir)/some_other_name.texi
1337 # if the default $(PACKAGE)-derived name doesn't apply.
1338 gendocs_options_ ?=
1339
1340 .PHONY: web-manual
1341 web-manual:
1342 @test -z "$(manual_title)" \
1343 && { echo define manual_title in cfg.mk 1>&2; exit 1; } || :
1344 @cd '$(srcdir)/doc'; \
1345 $(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \
1346 -o '$(abs_builddir)/doc/manual' \
1347 --email $(PACKAGE_BUGREPORT) $(PACKAGE) \
1348 "$(PACKAGE_NAME) - $(manual_title)"
1349 @echo " *** Upload the doc/manual directory to web-cvs."
1350
1351 # Code Coverage
1352
1353 init-coverage:
1354 $(MAKE) $(AM_MAKEFLAGS) clean
1355 lcov --directory . --zerocounters
1356
1357 COVERAGE_CCOPTS ?= "-g --coverage"
1358 COVERAGE_OUT ?= doc/coverage
1359
1360 build-coverage:
1361 $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS)
1362 $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) check
1363 mkdir -p $(COVERAGE_OUT)
1364 lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \
1365 --capture
1366
1367 gen-coverage:
1368 genhtml --output-directory $(COVERAGE_OUT) \
1369 $(COVERAGE_OUT)/$(PACKAGE).info \
1370 --highlight --frames --legend \
1371 --title "$(PACKAGE_NAME)"
1372
1373 coverage: init-coverage build-coverage gen-coverage
1374
1375 # Update gettext files.
1376 PACKAGE ?= $(shell basename $(PWD))
1377 PO_DOMAIN ?= $(PACKAGE)
1378 POURL = http://translationproject.org/latest/$(PO_DOMAIN)/
1379 PODIR ?= po
1380 refresh-po:
1381 rm -f $(PODIR)/*.po && \
1382 echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
1383 wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \
1384 echo 'en@boldquot' > $(PODIR)/LINGUAS && \
1385 echo 'en@quot' >> $(PODIR)/LINGUAS && \
1386 ls $(PODIR)/*.po | sed 's/\.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS
1387
1388 # Running indent once is not idempotent, but running it twice is.
1389 INDENT_SOURCES ?= $(C_SOURCES)
1390 .PHONY: indent
1391 indent:
1392 indent $(INDENT_SOURCES)
1393 indent $(INDENT_SOURCES)
1394
1395 # If you want to set UPDATE_COPYRIGHT_* environment variables,
1396 # put the assignments in this variable.
1397 update-copyright-env ?=
1398
1399 # Run this rule once per year (usually early in January)
1400 # to update all FSF copyright year lists in your project.
1401 # If you have an additional project-specific rule,
1402 # add it in cfg.mk along with a line 'update-copyright: prereq'.
1403 # By default, exclude all variants of COPYING; you can also
1404 # add exemptions (such as ChangeLog..* for rotated change logs)
1405 # in the file .x-update-copyright.
1406 .PHONY: update-copyright
1407 update-copyright:
1408 grep -l -w Copyright \
1409 $$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \
1410 | $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@
1411
1412 # This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not
1413 # overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS.
1414
1415 # NOTE: to override any _gl_TS_* default value, you must
1416 # define the variable(s) using "export" in cfg.mk.
1417 _gl_TS_dir ?= src
1418
1419 ALL_RECURSIVE_TARGETS += sc_tight_scope
1420 sc_tight_scope: tight-scope.mk
1421 @fail=0; \
1422 if ! grep '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \
1423 > /dev/null \
1424 && ! grep -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \
1425 > /dev/null 2>&1; then \
1426 echo '$(ME): skipping $@'; \
1427 else \
1428 $(MAKE) -s -C $(_gl_TS_dir) \
1429 -f Makefile \
1430 -f $(abs_top_srcdir)/cfg.mk \
1431 -f $(abs_top_builddir)/$< \
1432 _gl_tight_scope \
1433 || fail=1; \
1434 fi; \
1435 rm -f $<; \
1436 exit $$fail
1437
1438 tight-scope.mk: $(ME)
1439 @rm -f $@ $@-t
1440 @perl -ne '/^# TS-start/.../^# TS-end/ and print' $(ME) > $@-t
1441 @chmod a=r $@-t && mv $@-t $@
1442
1443 ifeq (a,b)
1444 # TS-start
1445
1446 # Most functions should have static scope.
1447 # Any that don't must be marked with `extern', but `main'
1448 # and `usage' are exceptions: they're always extern, but
1449 # do not need to be marked. Symbols matching `__.*' are
1450 # reserved by the compiler, so are automatically excluded below.
1451 _gl_TS_unmarked_extern_functions ?= main usage
1452 _gl_TS_function_match ?= /^(?:$(_gl_TS_extern)) +.*?(\S+) *\(/
1453
1454 # If your project uses a macro like "XTERN", then put
1455 # the following in cfg.mk to override this default:
1456 # export _gl_TS_extern = extern|XTERN
1457 _gl_TS_extern ?= extern
1458
1459 # The second nm|grep checks for file-scope variables with `extern' scope.
1460 # Without gnulib's progname module, you might put program_name here.
1461 # Symbols matching `__.*' are reserved by the compiler,
1462 # so are automatically excluded below.
1463 _gl_TS_unmarked_extern_vars ?=
1464
1465 # NOTE: the _match variables are perl expressions -- not mere regular
1466 # expressions -- so that you can extend them to match other patterns
1467 # and easily extract matched variable names.
1468 # For example, if your project declares some global variables via
1469 # a macro like this: GLOBAL(type, var_name, initializer), then you
1470 # can override this definition to automatically extract those names:
1471 # export _gl_TS_var_match = \
1472 # /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/
1473 _gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?\])?;/
1474
1475 # The names of object files in (or relative to) $(_gl_TS_dir).
1476 _gl_TS_obj_files ?= *.$(OBJEXT)
1477
1478 # Files in which to search for the one-line style extern declarations.
1479 # $(_gl_TS_dir)-relative.
1480 _gl_TS_headers ?= $(noinst_HEADERS)
1481
1482 .PHONY: _gl_tight_scope
1483 _gl_tight_scope: $(bin_PROGRAMS)
1484 t=exceptions-$$$$; \
1485 trap 's=$$?; rm -f $$t; exit $$s' 0; \
1486 for sig in 1 2 3 13 15; do \
1487 eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
1488 done; \
1489 src=`for f in $(SOURCES); do \
1490 test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
1491 hdr=`for f in $(_gl_TS_headers); do \
1492 test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
1493 ( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_functions); \
1494 grep -h -A1 '^extern .*[^;]$$' $$src \
1495 | grep -vE '^(extern |--)' | sed 's/ .*//'; \
1496 perl -lne \
1497 '$(_gl_TS_function_match) and print "^$$1\$$"' $$hdr; \
1498 ) | sort -u > $$t; \
1499 nm -e $(_gl_TS_obj_files) | sed -n 's/.* T //p'|grep -Ev -f $$t \
1500 && { echo the above functions should have static scope >&2; \
1501 exit 1; } || : ; \
1502 ( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars); \
1503 perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' $$hdr *.h \
1504 ) | sort -u > $$t; \
1505 nm -e $(_gl_TS_obj_files) | sed -n 's/.* [BCDGRS] //p' \
1506 | sort -u | grep -Ev -f $$t \
1507 && { echo the above variables should have static scope >&2; \
1508 exit 1; } || :
1509 # TS-end
1510 endif