-bison_SOURCES = LR0.c closure.c complain.c conflicts.c \
- parse-gram.y parse-gram.h \
- scan-gram.c \
- derives.c \
- files.c getargs.c gram.c lalr.c main.c nullable.c \
- output.h output.c \
- state.h state.c \
- print_graph.h print_graph.c \
- muscle_tab.h muscle_tab.c \
- options.h options.c \
- print.c reader.c reduce.c symtab.c vcg.c \
- scan-skel.l
-
-BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h
-
-EXTRA_bison_SOURCES = vmsgetargs.c
-
-noinst_HEADERS = LR0.h closure.h complain.h conflicts.h \
- derives.h \
- files.h getargs.h gram.h lalr.h nullable.h \
- print.h reader.h reduce.h symtab.h system.h \
- types.h vcg.h vcg_defaults.h
-
-EXTRA_DIST = build.com bison.cld vmshlp.mar
+# 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.
+#
+# The second nm|grep checks for file-scope variables with `extern' scope.
+sc_tight_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; \
+ if nm -e *.$(OBJEXT) \
+ | sed -n 's/.* T //p' \
+ | grep -Ev -f $$t; then \
+ echo 'the above functions should have static scope' 1>&2; \
+ exit 1; \
+ fi; \
+ ( printf '^program_name$$\n'; \
+ sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \
+ $$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t; \
+ if nm -e *.$(OBJEXT) \
+ | sed -n 's/.* [BD] //p' \
+ | grep -Ev -f $$t; then \
+ echo 'the above variables should have static scope' 1>&2; \
+ exit 1; \
+ fi