maint: extend the always_defined_macros syntax-check
authorJim Meyering <meyering@redhat.com>
Mon, 3 May 2010 10:05:14 +0000 (12:05 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 3 May 2010 11:24:04 +0000 (13:24 +0200)
* cfg.mk (gl_generated_headers_): Define.
(headers_with_interesting_macro_defs): Remove headers covered
by the above.
(.re-defmac): Extract symbol names from many more files.
(sc_always_defined_macros): Use VC_LIST_EXCEPT, not VC_LIST, so
that we can use the usual exception mechanism.
Test for $(gnulib_dir), not system.h.
* .x-sc_always_defined_macros: New file.  Exempt src/seq.c.
* Makefile.am (syntax_check_exceptions): Add it here.

.x-sc_always_defined_macros [new file with mode: 0644]
Makefile.am
cfg.mk

diff --git a/.x-sc_always_defined_macros b/.x-sc_always_defined_macros
new file mode 100644 (file)
index 0000000..8c96958
--- /dev/null
@@ -0,0 +1 @@
+src/seq.c
index 83c28b3..f1417a4 100644 (file)
@@ -41,6 +41,7 @@ changelog_etc =                               \
 
 syntax_check_exceptions =              \
   .x-sc_GPL_version                    \
+  .x-sc_always_defined_macros          \
   .x-sc_error_message_uppercase                \
   .x-sc_file_system                    \
   .x-sc_obsolete_symbols               \
diff --git a/cfg.mk b/cfg.mk
index 3983608..3bdf28c 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -106,24 +106,28 @@ sc_x_sc_dist_check:
                   ) | sort | uniq -u)"                                 \
          && { echo 'Makefile.am: $(sce) mismatch' >&2; exit 1; } || :;
 
+gl_generated_headers_ = \
+  $$(cd $(gnulib_dir)/lib && echo *.in.h|sed 's,sys_,sys/,g;s/\.in\.h/.h/g')
+
 headers_with_interesting_macro_defs = \
   exit.h       \
-  fcntl_.h     \
-  fnmatch_.h   \
   intprops.h   \
-  inttypes_.h  \
   lchown.h     \
   openat.h     \
-  stat-macros.h        \
-  stdint_.h
+  stat-macros.h
+
+gl_extract_significant_defines_ = \
+  /^\# *define ([^_ (][^ (]*)\s*(\(|\w+)/ && $$2 !~ /(?:rpl_|_used_without_)/ \
+    and print $$1
 
 # Create a list of regular expressions matching the names
 # of macros that are guaranteed by parts of gnulib to be defined.
 .re-defmac:
-       @(cd $(srcdir)/lib;                                             \
-         for f in $(headers_with_interesting_macro_defs); do           \
+       @gen_h=$(gl_generated_headers_);                                \
+       (cd $(srcdir)/lib;                                              \
+         for f in $(headers_with_interesting_macro_defs) $$gen_h; do   \
            test -f $$f &&                                              \
-             sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f;  \
+             perl -lne '$(gl_extract_significant_defines_)' $$f;       \
           done;                                                        \
         ) | sort -u                                                    \
           | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX'                     \
@@ -133,12 +137,12 @@ headers_with_interesting_macro_defs = \
 
 # Don't define macros that we already get from gnulib header files.
 sc_always_defined_macros: .re-defmac
-       @if test -f $(srcdir)/src/system.h; then                        \
+       @if test -d $(gnulib_dir); then                                 \
          trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0;                 \
          am__exit='(exit $rc); exit $rc';                              \
          trap "rc=129; $$am__exit" 1; trap "rc=130; $$am__exit" 2;     \
          trap "rc=131; $$am__exit" 3; trap "rc=143; $$am__exit" 15;    \
-         grep -f .re-defmac $$($(VC_LIST))                             \
+         grep -f .re-defmac $$($(VC_LIST_EXCEPT))                      \
            && { echo '$(ME): define the above via some gnulib .h file' \
                  1>&2;  exit 1; } || :;                                \
        fi