each file with a "main" must also declare program_name
authorJim Meyering <meyering@redhat.com>
Mon, 2 Jun 2008 15:48:11 +0000 (17:48 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 2 Jun 2008 16:50:00 +0000 (18:50 +0200)
* maint.mk (sc_program_name): New rule.
* .x-sc_program_name: New file.
* Makefile.am (EXTRA_DIST): Add .x-sc_program_name.

.x-sc_program_name [new file with mode: 0644]
Makefile.am
maint.mk

diff --git a/.x-sc_program_name b/.x-sc_program_name
new file mode 100644 (file)
index 0000000..eb4855f
--- /dev/null
@@ -0,0 +1,2 @@
+gl/lib/randint.c
+lib/euidaccess-stat.c
index 14f777e..8c99923 100644 (file)
@@ -22,7 +22,9 @@ EXTRA_DIST = cfg.mk maint.mk \
   .vg-suppressions \
   .x-po-check \
   .x-sc_GPL_version \
-  .x-sc_file_system .x-sc_obsolete_symbols \
+  .x-sc_file_system \
+  .x-sc_obsolete_symbols \
+  .x-sc_program_name \
   .x-sc_prohibit_atoi_atof \
   .x-sc_prohibit_strcmp \
   .x-sc_require_config_h \
index 91e26a4..25551a8 100644 (file)
--- a/maint.mk
+++ b/maint.mk
@@ -341,6 +341,18 @@ sc_system_h_headers: .re-list
                  1>&2;  exit 1; } || :;                                \
        fi
 
+# Ensure that each .c file containing a "main" function also
+# declares "char *program_name", with or without "const".
+sc_program_name:
+       @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then          \
+         files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \
+         grep -EL '^(char const|(const )?char) \*program_name;' $$files \
+             | grep . &&                                               \
+         { echo '$(ME): the above files do not declare program_name'   \
+               1>&2; exit 1; } || :;                                   \
+       else :;                                                         \
+       fi
+
 # Require that the final line of each test-lib.sh-using test be this one:
 # (exit $fail); exit $fail
 # Note: this test requires GNU grep's --label= option.