Prohibit inclusion of getopt.h without use.
authorJim Meyering <meyering@redhat.com>
Sat, 15 Mar 2008 16:53:00 +0000 (17:53 +0100)
committerJim Meyering <meyering@redhat.com>
Sun, 16 Mar 2008 18:04:29 +0000 (19:04 +0100)
* Makefile.maint (sc_prohibit_getopt_without_use): New rule.

Makefile.maint

index de49669..7a0157b 100644 (file)
@@ -178,6 +178,18 @@ sc_prohibit_assert_without_use:
        else :;                                                         \
        fi
 
+# Prohibit the inclusion of getopt.h without an actual use.
+sc_prohibit_getopt_without_use:
+       @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
+         files=$$(grep -l '# *include <getopt\.h>'                     \
+                   $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) &&           \
+         grep -E -L '\<getopt(_long)? \(' $$files                      \
+             | grep . &&                                               \
+           { echo "$(ME): the above files include <assert.h> but don't use it" \
+                 1>&2; exit 1; } || :;                                 \
+       else :;                                                         \
+       fi
+
 # Don't include quotearg.h unless you use one of its functions.
 sc_prohibit_quotearg_without_use:
        @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \