summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-04-27 14:57:33 +0000
committerJim Meyering <jim@meyering.net>2004-04-27 14:57:33 +0000
commit36968546e5d3835b4d3d2f0a0a4f8b0632eb9003 (patch)
tree6d7f53559399be946333f10ab2c9e30c0908715d /src
parente014b02b5f068d58fb8ba965d11a268de1229d89 (diff)
downloadcoreutils-36968546e5d3835b4d3d2f0a0a4f8b0632eb9003.tar.xz
(sc_src_functions_have_static_scope): New rule.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 61e05b51b..8356f1430 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -270,3 +270,22 @@ s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
done | $(ASSORT) -u ) > $@-t
chmod a-w $@-t
mv $@-t $@
+
+# The following rule is not designed to be portable,
+# and relies on tools that not everyone has.
+
+# Most functions in src/*.c should have static scope.
+# Any that don't must be marked with `extern', but `main'
+# and `usage' are exceptions. They're always extern, but
+# don't need to be marked.
+sc_src_functions_have_static_scope: $(all_programs)
+ @t=exceptions-$$$$; \
+ trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
+ ( printf '^main$$\n^usage$$\n'; \
+ grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
+ | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
+ nm -e *.$(OBJEXT) \
+ | sed -n 's/.* T //p' \
+ | grep -Ev -f $$t && \
+ { echo 'the above functions should have static scope' 1>&2; \
+ exit 1; } || :