diff top/maint.mk @ 14432:dcc1567d7f4e

maint.mk: allow fine-grained syntax-check exclusion via Make variables Before, you would have had to create one .x-sc_ file per rule in order to exempt offending files. Now, you may instead use a Make variable -- usually defined in cfg.mk -- whose name identifies the affected rule. * top/maint.mk (_sc_excl): Define. (VC_LIST_EXCEPT): Use it to exclude names on a per-rule basis. (_sc_search_regexp): When not using VC_LIST_EXCEPT, exclude here, too.
author Jim Meyering <meyering@redhat.com>
date Wed, 16 Mar 2011 12:14:21 +0100
parents a051be71a31b
children 00046711b6a6
line wrap: on
line diff
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -57,11 +57,13 @@
 # In order to be able to consistently filter "."-relative names,
 # (i.e., with no $(srcdir) prefix), this definition is careful to
 # remove any $(srcdir) prefix, and to restore what it removes.
+_sc_excl = \
+  $(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
 VC_LIST_EXCEPT = \
   $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
 	| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
 	  else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
-	| grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)' \
+	| grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
 	$(_prepend_srcdir_prefix)
 
 ifeq ($(origin prev_version_file), undefined)
@@ -196,6 +198,16 @@
 #  halt
 #
 #     Message to display before to halting execution.
+#
+# Finally, you may exempt files based on an ERE matching file names.
+# For example, to exempt from the sc_space_tab check all files with the
+# .diff suffix, set this Make variable:
+#
+# exclude_file_name_regexp--sc_space_tab = \.diff$
+#
+# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
+# when filtering by name via in_files, we explicitly filter out matching
+# names here as well.
 
 # By default, _sc_search_regexp does not ignore case.
 export ignore_case =
@@ -233,7 +245,8 @@
 									\
    : Filter by file name;						\
    if test -n "$$in_files"; then					\
-     files=$$(find $(srcdir) | grep -E "$$in_files");			\
+     files=$$(find $(srcdir) | grep -E "$$in_files"			\
+              | grep -Ev '$(exclude_file_name_regexp--$@)');		\
    else									\
      files=$$($(VC_LIST_EXCEPT));					\
      if test -n "$$in_vc_files"; then					\