Blame build-aux/sanity.mk

Packit 437b5e
# Slingshot sanity checking rules for GNU Make.
Packit 437b5e
Packit 437b5e
# ======================================================================
Packit 437b5e
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
Packit 437b5e
# Originally by Jim Meyering, Simon Josefsson, Eric Blake,
Packit 437b5e
#               Akim Demaille, Gary V. Vaughan, and others.
Packit 437b5e
# This version by Gary V. Vaughan, 2013.
Packit 437b5e
#
Packit 437b5e
# This program is free software: you can redistribute it and/or modify
Packit 437b5e
# it under the terms of the GNU General Public License as published by
Packit 437b5e
# the Free Software Foundation, either version 3 of the License, or
Packit 437b5e
# (at your option) any later version.
Packit 437b5e
# 
Packit 437b5e
# This program is distributed in the hope that it will be useful,
Packit 437b5e
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 437b5e
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 437b5e
# GNU General Public License for more details.
Packit 437b5e
#
Packit 437b5e
# You should have received a copy of the GNU General Public License
Packit 437b5e
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 437b5e
# ======================================================================
Packit 437b5e
Packit 437b5e
VC_LIST = $(GIT) ls-files
Packit 437b5e
Packit 437b5e
# You can override this variable in cfg.mk to set your own regexp
Packit 437b5e
# matching files to ignore.
Packit 437b5e
VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$
Packit 437b5e
Packit 437b5e
# This is to preprocess robustly the output of $(VC_LIST), so that even
Packit 437b5e
# when $(srcdir) is a pathological name like "....", the leading sed command
Packit 437b5e
# removes only the intended prefix.
Packit 437b5e
_dot_escaped_srcdir = $(subst .,\.,$(srcdir))
Packit 437b5e
Packit 437b5e
# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only
Packit 437b5e
# when $(srcdir) is not ".".
Packit 437b5e
ifeq ($(srcdir),.)
Packit 437b5e
  _prepend_srcdir_prefix =
Packit 437b5e
else
Packit 437b5e
  _prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|'
Packit 437b5e
endif
Packit 437b5e
Packit 437b5e
# In order to be able to consistently filter "."-relative names,
Packit 437b5e
# (i.e., with no $(srcdir) prefix), this definition is careful to
Packit 437b5e
# remove any $(srcdir) prefix, and to restore what it removes.
Packit 437b5e
_sc_excl = \
Packit 437b5e
  $(or $(exclude_file_name_regexp--$@),^build-aux/sanity.mk$$|gnulib$$|^slingshot$$)
Packit 437b5e
VC_LIST_EXCEPT = \
Packit 437b5e
  $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
Packit 437b5e
	| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
Packit 437b5e
	  else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
Packit 437b5e
	| grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
Packit 437b5e
	$(_prepend_srcdir_prefix)
Packit 437b5e
Packit 437b5e
Packit 437b5e
## --------------- ##
Packit 437b5e
## Sanity checks.  ##
Packit 437b5e
## --------------- ##
Packit 437b5e
Packit 437b5e
-include $(srcdir)/$(_build-aux)/sanity-cfg.mk
Packit 437b5e
Packit 437b5e
_cfg_mk := $(wildcard $(srcdir)/cfg.mk)
Packit 437b5e
Packit 437b5e
# Collect the names of rules starting with 'sc_'.
Packit 437b5e
syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
Packit 437b5e
			$(srcdir)/$(ME) $(_cfg_mk) $(srcdir)/$(_build-aux)/*.mk))
Packit 437b5e
.PHONY: $(syntax-check-rules)
Packit 437b5e
Packit 437b5e
ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0)
Packit 437b5e
  local-checks-available += $(syntax-check-rules)
Packit 437b5e
else
Packit 437b5e
  local-checks-available += no-vc-detected
Packit 437b5e
no-vc-detected:
Packit 437b5e
	@echo "No version control files detected; skipping syntax check"
Packit 437b5e
endif
Packit 437b5e
.PHONY: $(local-checks-available)
Packit 437b5e
Packit 437b5e
# Arrange to print the name of each syntax-checking rule just before running it.
Packit 437b5e
$(syntax-check-rules): %: %.m
Packit 437b5e
sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules))
Packit 437b5e
.PHONY: $(sc_m_rules_)
Packit 437b5e
$(sc_m_rules_):
Packit 437b5e
	@echo $(patsubst sc_%.m, %, $@)
Packit 437b5e
	@date +%s.%N > .sc-start-$(basename $@)
Packit 437b5e
Packit 437b5e
# Compute and print the elapsed time for each syntax-check rule.
Packit 437b5e
sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules))
Packit 437b5e
.PHONY: $(sc_z_rules_)
Packit 437b5e
$(sc_z_rules_): %.z: %
Packit 437b5e
	@end=$$(date +%s.%N);						\
Packit 437b5e
	start=$$(cat .sc-start-$*);					\
Packit 437b5e
	rm -f .sc-start-$*;						\
Packit 437b5e
	awk -v s=$$start -v e=$$end					\
Packit 437b5e
	  'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null
Packit 437b5e
Packit 437b5e
# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper
Packit 437b5e
# that computes and prints elapsed time.
Packit 437b5e
local-check :=								\
Packit 437b5e
  $(patsubst sc_%, sc_%.z,						\
Packit 437b5e
    $(filter-out $(local-checks-to-skip), $(local-checks-available)))
Packit 437b5e
Packit 437b5e
syntax-check: $(local-check)
Packit 437b5e
Packit 437b5e
# _sc_search_regexp
Packit 437b5e
#
Packit 437b5e
# This macro searches for a given construct in the selected files and
Packit 437b5e
# then takes some action.
Packit 437b5e
#
Packit 437b5e
# Parameters (shell variables):
Packit 437b5e
#
Packit 437b5e
#  prohibit | require
Packit 437b5e
#
Packit 437b5e
#     Regular expression (ERE) denoting either a forbidden construct
Packit 437b5e
#     or a required construct.  Those arguments are exclusive.
Packit 437b5e
#
Packit 437b5e
#  exclude
Packit 437b5e
#
Packit 437b5e
#     Regular expression (ERE) denoting lines to ignore that matched
Packit 437b5e
#     a prohibit construct.  For example, this can be used to exclude
Packit 437b5e
#     comments that mention why the nearby code uses an alternative
Packit 437b5e
#     construct instead of the simpler prohibited construct.
Packit 437b5e
#
Packit 437b5e
#  in_vc_files | in_files
Packit 437b5e
#
Packit 437b5e
#     grep-E-style regexp selecting the files to check.  For in_vc_files,
Packit 437b5e
#     the regexp is used to select matching files from the list of all
Packit 437b5e
#     version-controlled files; for in_files, it's from the names printed
Packit 437b5e
#     by "find $(srcdir)".  When neither is specified, use all files that
Packit 437b5e
#     are under version control.
Packit 437b5e
#
Packit 437b5e
#  containing | non_containing
Packit 437b5e
#
Packit 437b5e
#     Select the files (non) containing strings matching this regexp.
Packit 437b5e
#     If both arguments are specified then CONTAINING takes
Packit 437b5e
#     precedence.
Packit 437b5e
#
Packit 437b5e
#  with_grep_options
Packit 437b5e
#
Packit 437b5e
#     Extra options for grep.
Packit 437b5e
#
Packit 437b5e
#  ignore_case
Packit 437b5e
#
Packit 437b5e
#     Ignore case.
Packit 437b5e
#
Packit 437b5e
#  halt
Packit 437b5e
#
Packit 437b5e
#     Message to display before to halting execution.
Packit 437b5e
#
Packit 437b5e
# Finally, you may exempt files based on an ERE matching file names.
Packit 437b5e
# For example, to exempt from the sc_space_tab check all files with the
Packit 437b5e
# .diff suffix, set this Make variable:
Packit 437b5e
#
Packit 437b5e
# exclude_file_name_regexp--sc_space_tab = \.diff$
Packit 437b5e
#
Packit 437b5e
# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
Packit 437b5e
# when filtering by name via in_files, we explicitly filter out matching
Packit 437b5e
# names here as well.
Packit 437b5e
Packit 437b5e
# Initialize each, so that envvar settings cannot interfere.
Packit 437b5e
export require =
Packit 437b5e
export prohibit =
Packit 437b5e
export exclude =
Packit 437b5e
export in_vc_files =
Packit 437b5e
export in_files =
Packit 437b5e
export containing =
Packit 437b5e
export non_containing =
Packit 437b5e
export halt =
Packit 437b5e
export with_grep_options =
Packit 437b5e
Packit 437b5e
# By default, _sc_search_regexp does not ignore case.
Packit 437b5e
export ignore_case =
Packit 437b5e
_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :)
Packit 437b5e
Packit 437b5e
define _sc_say_and_exit
Packit 437b5e
   dummy=; : so we do not need a semicolon before each use;		\
Packit 437b5e
   { printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; };
Packit 437b5e
endef
Packit 437b5e
Packit 437b5e
define _sc_search_regexp
Packit 437b5e
   dummy=; : so we do not need a semicolon before each use;		\
Packit 437b5e
									\
Packit 437b5e
   : Check arguments;							\
Packit 437b5e
   test -n "$$prohibit" && test -n "$$require"				\
Packit 437b5e
     && { msg='Cannot specify both prohibit and require'		\
Packit 437b5e
          $(_sc_say_and_exit) } || :;					\
Packit 437b5e
   test -z "$$prohibit" && test -z "$$require"				\
Packit 437b5e
     && { msg='Should specify either prohibit or require'		\
Packit 437b5e
          $(_sc_say_and_exit) } || :;					\
Packit 437b5e
   test -z "$$prohibit" && test -n "$$exclude"				\
Packit 437b5e
     && { msg='Use of exclude requires a prohibit pattern'		\
Packit 437b5e
          $(_sc_say_and_exit) } || :;					\
Packit 437b5e
   test -n "$$in_vc_files" && test -n "$$in_files"			\
Packit 437b5e
     && { msg='Cannot specify both in_vc_files and in_files'		\
Packit 437b5e
          $(_sc_say_and_exit) } || :;					\
Packit 437b5e
   test "x$$halt" != x							\
Packit 437b5e
     || { msg='halt not defined' $(_sc_say_and_exit) };			\
Packit 437b5e
									\
Packit 437b5e
   : Filter by file name;						\
Packit 437b5e
   if test -n "$$in_files"; then					\
Packit 437b5e
     files=$$(find $(srcdir) | grep -E "$$in_files"			\
Packit 437b5e
              | grep -Ev '$(_sc_excl)');				\
Packit 437b5e
   else									\
Packit 437b5e
     files=$$($(VC_LIST_EXCEPT));					\
Packit 437b5e
     if test -n "$$in_vc_files"; then					\
Packit 437b5e
       files=$$(echo "$$files" | grep -E "$$in_vc_files");		\
Packit 437b5e
     fi;								\
Packit 437b5e
   fi;									\
Packit 437b5e
									\
Packit 437b5e
   : Filter by content;							\
Packit 437b5e
   test -n "$$files" && test -n "$$containing"				\
Packit 437b5e
     && { files=$$(grep -l "$$containing" $$files); } || :;		\
Packit 437b5e
   test -n "$$files" && test -n "$$non_containing"			\
Packit 437b5e
     && { files=$$(grep -vl "$$non_containing" $$files); } || :;	\
Packit 437b5e
									\
Packit 437b5e
   : Check for the construct;						\
Packit 437b5e
   if test -n "$$files"; then						\
Packit 437b5e
     if test -n "$$prohibit"; then					\
Packit 437b5e
       grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
Packit 437b5e
         | grep -vE "$${exclude:-^$$}"					\
Packit 437b5e
         && { msg="$$halt" $(_sc_say_and_exit) } || :;			\
Packit 437b5e
     else								\
Packit 437b5e
       grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
Packit 437b5e
           | grep .							\
Packit 437b5e
         && { msg="$$halt" $(_sc_say_and_exit) } || :;			\
Packit 437b5e
     fi									\
Packit 437b5e
   else :;								\
Packit 437b5e
   fi || :;
Packit 437b5e
endef
Packit 437b5e
Packit 437b5e
sc_avoid_if_before_free:
Packit 437b5e
	@test -f $(srcdir)/$(_build-aux)/useless-if-before-free &&	\
Packit 437b5e
	  $(srcdir)/$(_build-aux)/useless-if-before-free		\
Packit 437b5e
		$(useless_free_options)					\
Packit 437b5e
	    $$($(VC_LIST_EXCEPT) | grep -v useless-if-before-free) &&	\
Packit 437b5e
	  { echo '$(ME): found useless "if" before "free" above' 1>&2;	\
Packit 437b5e
	    exit 1; } || :
Packit 437b5e
Packit 437b5e
sc_cast_of_argument_to_free:
Packit 437b5e
	@prohibit='\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_cast_of_x_alloc_return_value:
Packit 437b5e
	@prohibit='\*\) *x(m|c|re)alloc\>'				\
Packit 437b5e
	halt="don't cast x*alloc return value"				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_cast_of_alloca_return_value:
Packit 437b5e
	@prohibit='\*\) *alloca\>'					\
Packit 437b5e
	halt="don't cast alloca return value"				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_space_tab:
Packit 437b5e
	@prohibit='[ ]	'						\
Packit 437b5e
	halt='found SPACE-TAB sequence; remove the SPACE'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Don't use *scanf or the old ato* functions in "real" code.
Packit 437b5e
# They provide no error checking mechanism.
Packit 437b5e
# Instead, use strto* functions.
Packit 437b5e
sc_prohibit_atoi_atof:
Packit 437b5e
	@prohibit='\<([fs]?scanf|ato([filq]|ll)) *\('				\
Packit 437b5e
	halt='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q'	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Use STREQ rather than comparing strcmp == 0, or != 0.
Packit 437b5e
sp_ = strcmp *\(.+\)
Packit 437b5e
sc_prohibit_strcmp:
Packit 437b5e
	@prohibit='! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)'		\
Packit 437b5e
	exclude='# *define STRN?EQ\('					\
Packit 437b5e
	halt='replace strcmp calls above with STREQ/STRNEQ'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Really.  You don't want to use this function.
Packit 437b5e
# It may fail to NUL-terminate the destination,
Packit 437b5e
# and always NUL-pads out to the specified length.
Packit 437b5e
sc_prohibit_strncpy:
Packit 437b5e
	@prohibit='\
Packit 437b5e
	halt='do not use strncpy, period'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Pass EXIT_*, not number, to usage, exit, and error (when exiting)
Packit 437b5e
# Convert all uses automatically, via these two commands:
Packit 437b5e
# git grep -l '\
Packit 437b5e
#  | grep -vEf .x-sc_prohibit_magic_number_exit \
Packit 437b5e
#  | xargs --no-run-if-empty \
Packit 437b5e
#      perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
Packit 437b5e
# git grep -l '\
Packit 437b5e
#  | grep -vEf .x-sc_prohibit_magic_number_exit \
Packit 437b5e
#  | xargs --no-run-if-empty \
Packit 437b5e
#      perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
Packit 437b5e
sc_prohibit_magic_number_exit:
Packit 437b5e
	@prohibit='(^|[^.])\<(usage|exit|error) ?\(-?[0-9]+[,)]'	\
Packit 437b5e
	exclude='exit \(77\)|error ?\(((0|77),|[^,]*)'			\
Packit 437b5e
	halt='use EXIT_* values rather than magic number'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Using EXIT_SUCCESS as the first argument to error is misleading,
Packit 437b5e
# since when that parameter is 0, error does not exit.  Use '0' instead.
Packit 437b5e
sc_error_exit_success:
Packit 437b5e
	@prohibit='error *\(EXIT_SUCCESS,'				\
Packit 437b5e
	in_vc_files='\.[chly]$$'					\
Packit 437b5e
	halt='found error (EXIT_SUCCESS'				\
Packit 437b5e
	 $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# "FATAL:" should be fully upper-cased in error messages
Packit 437b5e
# "WARNING:" should be fully upper-cased, or fully lower-cased
Packit 437b5e
sc_error_message_warn_fatal:
Packit 437b5e
	@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT))		\
Packit 437b5e
	    | grep -E '"Warning|"Fatal|"fatal' &&			\
Packit 437b5e
	  { echo '$(ME): use FATAL, WARNING or warning'	1>&2;		\
Packit 437b5e
	    exit 1; } || :
Packit 437b5e
Packit 437b5e
# Error messages should not start with a capital letter
Packit 437b5e
sc_error_message_uppercase:
Packit 437b5e
	@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT))		\
Packit 437b5e
	    | grep -E '"[A-Z]'						\
Packit 437b5e
	    | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' &&		\
Packit 437b5e
	  { echo '$(ME): found capitalized error message' 1>&2;		\
Packit 437b5e
	    exit 1; } || :
Packit 437b5e
Packit 437b5e
# Error messages should not end with a period
Packit 437b5e
sc_error_message_period:
Packit 437b5e
	@grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT))		\
Packit 437b5e
	    | grep -E '[^."]\."' &&					\
Packit 437b5e
	  { echo '$(ME): found error message ending in period' 1>&2;	\
Packit 437b5e
	    exit 1; } || :
Packit 437b5e
Packit 437b5e
sc_file_system:
Packit 437b5e
	@prohibit=file''system						\
Packit 437b5e
	ignore_case=1							\
Packit 437b5e
	halt='found use of "file''system"; spell it "file system"'	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_makefile:
Packit 437b5e
	@prohibit=make''flie						\
Packit 437b5e
	ignore_case=1							\
Packit 437b5e
	halt='found misspelled "make''flie"; use "makefile" instead'	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Don't use cpp tests of this symbol.  All code assumes config.h is included.
Packit 437b5e
sc_prohibit_have_config_h:
Packit 437b5e
	@prohibit='^# *if.*HAVE''_CONFIG_H'				\
Packit 437b5e
	halt='found use of HAVE''_CONFIG_H; remove'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Nearly all .c files must include <config.h>.  However, we also permit this
Packit 437b5e
# via inclusion of a package-specific header, if cfg.mk specified one.
Packit 437b5e
# config_h_header must be suitable for grep -E.
Packit 437b5e
config_h_header ?= <config\.h>
Packit 437b5e
sc_require_config_h:
Packit 437b5e
	@require='^# *include $(config_h_header)'			\
Packit 437b5e
	in_vc_files='\.c$$'						\
Packit 437b5e
	halt='the above files do not include <config.h>'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# You must include <config.h> before including any other header file.
Packit 437b5e
# This can possibly be via a package-specific header, if given by cfg.mk.
Packit 437b5e
sc_require_config_h_first:
Packit 437b5e
	@if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then	\
Packit 437b5e
	  fail=0;							\
Packit 437b5e
	  for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do		\
Packit 437b5e
	    grep '^# *include\>' $$i | sed 1q				\
Packit 437b5e
		| grep -E '^# *include $(config_h_header)' > /dev/null	\
Packit 437b5e
	      || { echo $$i; fail=1; };					\
Packit 437b5e
	  done;								\
Packit 437b5e
	  test $$fail = 1 &&						\
Packit 437b5e
	    { echo '$(ME): the above files include some other header'	\
Packit 437b5e
		'before <config.h>' 1>&2; exit 1; } || :;		\
Packit 437b5e
	else :;								\
Packit 437b5e
	fi
Packit 437b5e
Packit 437b5e
sc_prohibit_HAVE_MBRTOWC:
Packit 437b5e
	@prohibit='\bHAVE_MBRTOWC\b'					\
Packit 437b5e
	halt="do not use $$prohibit; it is always defined"		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# To use this "command" macro, you must first define two shell variables:
Packit 437b5e
# h: the header name, with no enclosing <> or ""
Packit 437b5e
# re: a regular expression that matches IFF something provided by $h is used.
Packit 437b5e
define _sc_header_without_use
Packit 437b5e
  dummy=; : so we do not need a semicolon before each use;		\
Packit 437b5e
  h_esc=`echo '[<"]'"$$h"'[">]'|sed 's/\./\\\\./g'`;			\
Packit 437b5e
  if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then		\
Packit 437b5e
    files=$$(grep -l '^# *include '"$$h_esc"				\
Packit 437b5e
	     $$($(VC_LIST_EXCEPT) | grep '\.c$$')) &&			\
Packit 437b5e
    grep -LE "$$re" $$files | grep . &&					\
Packit 437b5e
      { echo "$(ME): the above files include $$h but don't use it"	\
Packit 437b5e
	1>&2; exit 1; } || :;						\
Packit 437b5e
  else :;								\
Packit 437b5e
  fi
Packit 437b5e
endef
Packit 437b5e
Packit 437b5e
# Prohibit the inclusion of assert.h without an actual use of assert.
Packit 437b5e
sc_prohibit_assert_without_use:
Packit 437b5e
	@h='assert.h' re='\
Packit 437b5e
Packit 437b5e
# Prohibit the inclusion of close-stream.h without an actual use.
Packit 437b5e
sc_prohibit_close_stream_without_use:
Packit 437b5e
	@h='close-stream.h' re='\
Packit 437b5e
Packit 437b5e
# Prohibit the inclusion of getopt.h without an actual use.
Packit 437b5e
sc_prohibit_getopt_without_use:
Packit 437b5e
	@h='getopt.h' re='\
Packit 437b5e
Packit 437b5e
# Don't include quotearg.h unless you use one of its functions.
Packit 437b5e
sc_prohibit_quotearg_without_use:
Packit 437b5e
	@h='quotearg.h' re='\
Packit 437b5e
Packit 437b5e
# Don't include quote.h unless you use one of its functions.
Packit 437b5e
sc_prohibit_quote_without_use:
Packit 437b5e
	@h='quote.h' re='\<quote((_n)? *\(|_quoting_options\>)' \
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include this header unless you use one of its functions.
Packit 437b5e
sc_prohibit_long_options_without_use:
Packit 437b5e
	@h='long-options.h' re='\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include this header unless you use one of its functions.
Packit 437b5e
sc_prohibit_inttostr_without_use:
Packit 437b5e
	@h='inttostr.h' re='\<(off|[iu]max|uint)tostr *\(' \
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include this header unless you use one of its functions.
Packit 437b5e
sc_prohibit_ignore_value_without_use:
Packit 437b5e
	@h='ignore-value.h' re='\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include this header unless you use one of its functions.
Packit 437b5e
sc_prohibit_error_without_use:
Packit 437b5e
	@h='error.h' \
Packit 437b5e
	re='\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include xalloc.h unless you use one of its functions.
Packit 437b5e
# Consider these symbols:
Packit 437b5e
# perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
Packit 437b5e
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
Packit 437b5e
# Divide into two sets on case, and filter each through this:
Packit 437b5e
# | sort | perl -MRegexp::Assemble -le \
Packit 437b5e
#  'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
Packit 437b5e
# Note this was produced by the above:
Packit 437b5e
# _xa1 = \
Packit 437b5e
#x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
Packit 437b5e
# But we can do better, in at least two ways:
Packit 437b5e
# 1) take advantage of two "dup"-suffixed strings:
Packit 437b5e
# x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
Packit 437b5e
# 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
Packit 437b5e
# "char|[cmz]"
Packit 437b5e
# x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
Packit 437b5e
_xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
Packit 437b5e
_xa2 = X([CZ]|N?M)ALLOC
Packit 437b5e
sc_prohibit_xalloc_without_use:
Packit 437b5e
	@h='xalloc.h' \
Packit 437b5e
	re='\<($(_xa1)|$(_xa2)) *\('\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Extract function names:
Packit 437b5e
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h
Packit 437b5e
_hash_re = \
Packit 437b5e
clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning
Packit 437b5e
_hash_fn = \<($(_hash_re)) *\(
Packit 437b5e
_hash_struct = (struct )?\<[Hh]ash_(table|tuning)\>
Packit 437b5e
sc_prohibit_hash_without_use:
Packit 437b5e
	@h='hash.h' \
Packit 437b5e
	re='$(_hash_fn)|$(_hash_struct)'\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
sc_prohibit_cloexec_without_use:
Packit 437b5e
	@h='cloexec.h' re='\<(set_cloexec_flag|dup_cloexec) *\(' \
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
sc_prohibit_posixver_without_use:
Packit 437b5e
	@h='posixver.h' re='\
Packit 437b5e
Packit 437b5e
sc_prohibit_same_without_use:
Packit 437b5e
	@h='same.h' re='\
Packit 437b5e
Packit 437b5e
sc_prohibit_hash_pjw_without_use:
Packit 437b5e
	@h='hash-pjw.h' \
Packit 437b5e
	re='\<hash_pjw\>' \
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
sc_prohibit_safe_read_without_use:
Packit 437b5e
	@h='safe-read.h' re='(\<SAFE_READ_ERROR\>|\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
sc_prohibit_argmatch_without_use:
Packit 437b5e
	@h='argmatch.h' \
Packit 437b5e
	re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<(invalid_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
sc_prohibit_canonicalize_without_use:
Packit 437b5e
	@h='canonicalize.h' \
Packit 437b5e
	re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode|file_name)' \
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
sc_prohibit_root_dev_ino_without_use:
Packit 437b5e
	@h='root-dev-ino.h' \
Packit 437b5e
	re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
sc_prohibit_openat_without_use:
Packit 437b5e
	@h='openat.h' \
Packit 437b5e
	re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat)\>' \
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Prohibit the inclusion of c-ctype.h without an actual use.
Packit 437b5e
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
Packit 437b5e
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
Packit 437b5e
sc_prohibit_c_ctype_without_use:
Packit 437b5e
	@h='c-ctype.h' re='\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# The following list was generated by running:
Packit 437b5e
# man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
Packit 437b5e
#   | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
Packit 437b5e
_sig_functions = \
Packit 437b5e
  bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
Packit 437b5e
  sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
Packit 437b5e
  siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
Packit 437b5e
  sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
Packit 437b5e
_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
Packit 437b5e
# The following were extracted from "man signal.h" manually.
Packit 437b5e
_sig_types_and_consts =							\
Packit 437b5e
  MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK		\
Packit 437b5e
  SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL		\
Packit 437b5e
  SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE	\
Packit 437b5e
  SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t	\
Packit 437b5e
  sigstack sigval stack_t ucontext_t
Packit 437b5e
# generated via this:
Packit 437b5e
# perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
Packit 437b5e
_sig_names =								\
Packit 437b5e
  SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT	\
Packit 437b5e
  SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL	\
Packit 437b5e
  SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP	\
Packit 437b5e
  SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR	\
Packit 437b5e
  SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS	\
Packit 437b5e
  SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1	\
Packit 437b5e
  SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW	\
Packit 437b5e
  SIGXCPU SIGXFSZ
Packit 437b5e
_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
Packit 437b5e
Packit 437b5e
# Prohibit the inclusion of signal.h without an actual use.
Packit 437b5e
sc_prohibit_signal_without_use:
Packit 437b5e
	@h='signal.h'							\
Packit 437b5e
	re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>'		\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include stdio--.h unless you use one of its functions.
Packit 437b5e
sc_prohibit_stdio--_without_use:
Packit 437b5e
	@h='stdio--.h' re='\<((f(re)?|p)open|tmpfile) *\('		\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include stdio-safer.h unless you use one of its functions.
Packit 437b5e
sc_prohibit_stdio-safer_without_use:
Packit 437b5e
	@h='stdio-safer.h' re='\<((f(re)?|p)open|tmpfile)_safer *\('	\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Prohibit the inclusion of strings.h without a sensible use.
Packit 437b5e
# Using the likes of bcmp, bcopy, bzero, index or rindex is not sensible.
Packit 437b5e
sc_prohibit_strings_without_use:
Packit 437b5e
	@h='strings.h'							\
Packit 437b5e
	re='\<(strn?casecmp|ffs(ll)?)\>'				\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Get the list of symbol names with this:
Packit 437b5e
# perl -lne '/^# *define ([A-Z]\w+)\(/ and print $1' lib/intprops.h|fmt
Packit 437b5e
_intprops_names =							\
Packit 437b5e
  TYPE_IS_INTEGER TYPE_TWOS_COMPLEMENT TYPE_ONES_COMPLEMENT		\
Packit 437b5e
  TYPE_SIGNED_MAGNITUDE TYPE_SIGNED TYPE_MINIMUM TYPE_MAXIMUM		\
Packit 437b5e
  INT_BITS_STRLEN_BOUND INT_STRLEN_BOUND INT_BUFSIZE_BOUND		\
Packit 437b5e
  INT_ADD_RANGE_OVERFLOW INT_SUBTRACT_RANGE_OVERFLOW			\
Packit 437b5e
  INT_NEGATE_RANGE_OVERFLOW INT_MULTIPLY_RANGE_OVERFLOW			\
Packit 437b5e
  INT_DIVIDE_RANGE_OVERFLOW INT_REMAINDER_RANGE_OVERFLOW		\
Packit 437b5e
  INT_LEFT_SHIFT_RANGE_OVERFLOW INT_ADD_OVERFLOW INT_SUBTRACT_OVERFLOW	\
Packit 437b5e
  INT_NEGATE_OVERFLOW INT_MULTIPLY_OVERFLOW INT_DIVIDE_OVERFLOW		\
Packit 437b5e
  INT_REMAINDER_OVERFLOW INT_LEFT_SHIFT_OVERFLOW
Packit 437b5e
_intprops_syms_re = $(subst $(_sp),|,$(strip $(_intprops_names)))
Packit 437b5e
# Prohibit the inclusion of intprops.h without an actual use.
Packit 437b5e
sc_prohibit_intprops_without_use:
Packit 437b5e
	@h='intprops.h'							\
Packit 437b5e
	re='\<($(_intprops_syms_re)) *\('				\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
_stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t
Packit 437b5e
# Prohibit the inclusion of stddef.h without an actual use.
Packit 437b5e
sc_prohibit_stddef_without_use:
Packit 437b5e
	@h='stddef.h'							\
Packit 437b5e
	re='\<($(_stddef_syms_re))\>'					\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
_de1 = dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)?
Packit 437b5e
_de2 = (versionsort|struct dirent|getdirentries|alphasort|scandir(at)?)(64)?
Packit 437b5e
_de3 = MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen
Packit 437b5e
_dirent_syms_re = $(_de1)|$(_de2)|$(_de3)
Packit 437b5e
# Prohibit the inclusion of dirent.h without an actual use.
Packit 437b5e
sc_prohibit_dirent_without_use:
Packit 437b5e
	@h='dirent.h'							\
Packit 437b5e
	re='\<($(_dirent_syms_re))\>'					\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Prohibit the inclusion of verify.h without an actual use.
Packit 437b5e
sc_prohibit_verify_without_use:
Packit 437b5e
	@h='verify.h'							\
Packit 437b5e
	re='\<(verify(true|expr)?|static_assert) *\('			\
Packit 437b5e
	  $(_sc_header_without_use)
Packit 437b5e
Packit 437b5e
# Don't include xfreopen.h unless you use one of its functions.
Packit 437b5e
sc_prohibit_xfreopen_without_use:
Packit 437b5e
	@h='xfreopen.h' re='\
Packit 437b5e
Packit 437b5e
sc_obsolete_symbols:
Packit 437b5e
	@prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>'			\
Packit 437b5e
	halt='do not use HAVE''_FCNTL_H or O'_NDELAY			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
Packit 437b5e
Packit 437b5e
# Each nonempty ChangeLog line must start with a year number, or a TAB.
Packit 437b5e
sc_changelog:
Packit 437b5e
	@prohibit='^[^12	]'					\
Packit 437b5e
	in_vc_files='^ChangeLog$$'					\
Packit 437b5e
	halt='found unexpected prefix in a ChangeLog'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Ensure that each .c file containing a "main" function also
Packit 437b5e
# calls set_program_name.
Packit 437b5e
sc_program_name:
Packit 437b5e
	@require='set_program_name *\(m?argv\[0\]\);'			\
Packit 437b5e
	in_vc_files='\.c$$'						\
Packit 437b5e
	containing='\
Packit 437b5e
	halt='the above files do not call set_program_name'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Ensure that each .c file containing a "main" function also
Packit 437b5e
# calls bindtextdomain.
Packit 437b5e
sc_bindtextdomain:
Packit 437b5e
	@require='bindtextdomain *\('					\
Packit 437b5e
	in_vc_files='\.c$$'						\
Packit 437b5e
	containing='\
Packit 437b5e
	halt='the above files do not call bindtextdomain'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Require that the final line of each test-lib.sh-using test be this one:
Packit 437b5e
# Exit $fail
Packit 437b5e
# Note: this test requires GNU grep's --label= option.
Packit 437b5e
Exit_witness_file ?= tests/test-lib.sh
Packit 437b5e
Exit_base := $(notdir $(Exit_witness_file))
Packit 437b5e
sc_require_test_exit_idiom:
Packit 437b5e
	@if test -f $(srcdir)/$(Exit_witness_file); then		\
Packit 437b5e
	  die=0;							\
Packit 437b5e
	  for i in $$(grep -l -F 'srcdir/$(Exit_base)'			\
Packit 437b5e
		$$($(VC_LIST) tests)); do				\
Packit 437b5e
	    tail -n1 $$i | grep '^Exit .' > /dev/null			\
Packit 437b5e
	      && : || { die=1; echo $$i; }				\
Packit 437b5e
	  done;								\
Packit 437b5e
	  test $$die = 1 &&						\
Packit 437b5e
	    { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
Packit 437b5e
	      echo 1>&2 'Exit something';				\
Packit 437b5e
	      exit 1; } || :;						\
Packit 437b5e
	fi
Packit 437b5e
Packit 437b5e
sc_trailing_blank:
Packit 437b5e
	@prohibit='[	 ]$$'						\
Packit 437b5e
	halt='found trailing blank(s)'					\
Packit 437b5e
	exclude='^Binary file .* matches$$'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Match lines like the following, but where there is only one space
Packit 437b5e
# between the options and the description:
Packit 437b5e
#   -D, --all-repeated[=delimit-method]  print all duplicate lines\n
Packit 437b5e
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
Packit 437b5e
sc_two_space_separator_in_usage:
Packit 437b5e
	@prohibit='^   *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$'		\
Packit 437b5e
	halt='help2man requires at least two spaces between an option and its description'\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# A regexp matching function names like "error_" that may be used
Packit 437b5e
# to emit translatable messages.
Packit 437b5e
_gl_translatable_diag_func_re ?= error_
Packit 437b5e
Packit 437b5e
# Look for diagnostics that aren't marked for translation.
Packit 437b5e
# This won't find any for which error's format string is on a separate line.
Packit 437b5e
sc_unmarked_diagnostics:
Packit 437b5e
	@prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \
Packit 437b5e
	exclude='(_|ngettext ?)\('					\
Packit 437b5e
	halt='found unmarked diagnostic(s)'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Avoid useless parentheses like those in this example:
Packit 437b5e
# #if defined (SYMBOL) || defined (SYM2)
Packit 437b5e
sc_useless_cpp_parens:
Packit 437b5e
	@prohibit='^# *if .*defined *\('				\
Packit 437b5e
	halt='found useless parentheses in cpp directive'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# List headers for which HAVE_HEADER_H is always true, assuming you are
Packit 437b5e
# using the appropriate gnulib module.  CAUTION: for each "unnecessary"
Packit 437b5e
# #if HAVE_HEADER_H that you remove, be sure that your project explicitly
Packit 437b5e
# requires the gnulib module that guarantees the usability of that header.
Packit 437b5e
gl_assured_headers_ = \
Packit 437b5e
  cd $(gnulib_dir)/lib && echo *.in.h|sed 's/\.in\.h//g'
Packit 437b5e
Packit 437b5e
# Convert the list of names to upper case, and replace each space with "|".
Packit 437b5e
az_ = abcdefghijklmnopqrstuvwxyz
Packit 437b5e
AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ
Packit 437b5e
gl_header_upper_case_or_ =						\
Packit 437b5e
  $$($(gl_assured_headers_)						\
Packit 437b5e
    | tr $(az_)/.- $(AZ_)___						\
Packit 437b5e
    | tr -s ' ' '|'							\
Packit 437b5e
    )
Packit 437b5e
sc_prohibit_always_true_header_tests:
Packit 437b5e
	@or=$(gl_header_upper_case_or_);				\
Packit 437b5e
	re="HAVE_($$or)_H";						\
Packit 437b5e
	prohibit='\<'"$$re"'\>'						\
Packit 437b5e
	halt=$$(printf '%s\n'						\
Packit 437b5e
	'do not test the above HAVE_<header>_H symbol(s);'		\
Packit 437b5e
	'  with the corresponding gnulib module, they are always true')	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_prohibit_defined_have_decl_tests:
Packit 437b5e
	@prohibit='#[	 ]*if(n?def|.*\<defined)\>[	 (]+HAVE_DECL_'	\
Packit 437b5e
	halt='HAVE_DECL macros are always defined'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# ==================================================================
Packit 437b5e
gl_other_headers_ ?= \
Packit 437b5e
  intprops.h	\
Packit 437b5e
  openat.h	\
Packit 437b5e
  stat-macros.h
Packit 437b5e
Packit 437b5e
# Perl -lne code to extract "significant" cpp-defined symbols from a
Packit 437b5e
# gnulib header file, eliminating a few common false-positives.
Packit 437b5e
# The exempted names below are defined only conditionally in gnulib,
Packit 437b5e
# and hence sometimes must/may be defined in application code.
Packit 437b5e
gl_extract_significant_defines_ = \
Packit 437b5e
  /^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\
Packit 437b5e
    && $$2 !~ /(?:rpl_|_used_without_)/\
Packit 437b5e
    && $$1 !~ /^(?:NSIG|ENODATA)$$/\
Packit 437b5e
    && $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\
Packit 437b5e
    and print $$1
Packit 437b5e
Packit 437b5e
# Create a list of regular expressions matching the names
Packit 437b5e
# of macros that are guaranteed to be defined by parts of gnulib.
Packit 437b5e
define def_sym_regex
Packit 437b5e
	gen_h=$(gl_generated_headers_);					\
Packit 437b5e
	(cd $(gnulib_dir)/lib;						\
Packit 437b5e
	  for f in *.in.h $(gl_other_headers_); do			\
Packit 437b5e
	    test -f $$f							\
Packit 437b5e
	      && perl -lne '$(gl_extract_significant_defines_)' $$f;	\
Packit 437b5e
	  done;								\
Packit 437b5e
	) | sort -u							\
Packit 437b5e
	  | sed 's/^/^ *# *(define|undef)  */;s/$$/\\>/'
Packit 437b5e
endef
Packit 437b5e
Packit 437b5e
# Don't define macros that we already get from gnulib header files.
Packit 437b5e
sc_prohibit_always-defined_macros:
Packit 437b5e
	@if test -d $(gnulib_dir); then					\
Packit 437b5e
	  case $$(echo all: | grep -l -f - Makefile) in Makefile);; *)	\
Packit 437b5e
	    echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;;	\
Packit 437b5e
	  esac;								\
Packit 437b5e
	  $(def_sym_regex) | grep -E -f - $$($(VC_LIST_EXCEPT))		\
Packit 437b5e
	    && { echo '$(ME): define the above via some gnulib .h file'	\
Packit 437b5e
		  1>&2;  exit 1; } || :;				\
Packit 437b5e
	fi
Packit 437b5e
# ==================================================================
Packit 437b5e
Packit 437b5e
# Prohibit checked in backup files.
Packit 437b5e
sc_prohibit_backup_files:
Packit 437b5e
	@$(VC_LIST) | grep '~$$' &&				\
Packit 437b5e
	  { echo '$(ME): found version controlled backup file' 1>&2;	\
Packit 437b5e
	    exit 1; } || :
Packit 437b5e
Packit 437b5e
# Require the latest GPL.
Packit 437b5e
sc_GPL_version:
Packit 437b5e
	@prohibit='either ''version [^3]'				\
Packit 437b5e
	halt='GPL vN, N!=3'						\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Require the latest GFDL.  Two regexp, since some .texi files end up
Packit 437b5e
# line wrapping between 'Free Documentation License,' and 'Version'.
Packit 437b5e
_GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any)
Packit 437b5e
sc_GFDL_version:
Packit 437b5e
	@prohibit='$(_GFDL_regexp)'					\
Packit 437b5e
	halt='GFDL vN, N!=3'						\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Don't use Texinfo's @acronym{}.
Packit 437b5e
# http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00321.html
Packit 437b5e
texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$
Packit 437b5e
sc_texinfo_acronym:
Packit 437b5e
	@prohibit='@acronym\{'						\
Packit 437b5e
	in_vc_files='$(texinfo_suffix_re_)'				\
Packit 437b5e
	halt='found use of Texinfo @acronym{}'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
cvs_keywords = \
Packit 437b5e
  Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
Packit 437b5e
Packit 437b5e
sc_prohibit_cvs_keyword:
Packit 437b5e
	@prohibit='\$$($(cvs_keywords))\$$'				\
Packit 437b5e
	halt='do not use CVS keyword expansion'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# This Perl code is slightly obfuscated.  Not only is each "$" doubled
Packit 437b5e
# because it's in a Makefile, but the $$c's are comments;  we cannot
Packit 437b5e
# use "#" due to the way the script ends up concatenated onto one line.
Packit 437b5e
# It would be much more concise, and would produce better output (including
Packit 437b5e
# counts) if written as:
Packit 437b5e
#   perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
Packit 437b5e
# but that would be far less efficient, reading the entire contents
Packit 437b5e
# of each file, rather than just the last two bytes of each.
Packit 437b5e
# In addition, while the code below detects both blank lines and a missing
Packit 437b5e
# newline at EOF, the above detects only the former.
Packit 437b5e
#
Packit 437b5e
# This is a perl script that is expected to be the single-quoted argument
Packit 437b5e
# to a command-line "-le".  The remaining arguments are file names.
Packit 437b5e
# Print the name of each file that does not end in exactly one newline byte.
Packit 437b5e
# I.e., warn if there are blank lines (2 or more newlines), or if the
Packit 437b5e
# last byte is not a newline.  However, currently we don't complain
Packit 437b5e
# about any file that contains exactly one byte.
Packit 437b5e
# Exit nonzero if at least one such file is found, otherwise, exit 0.
Packit 437b5e
# Warn about, but otherwise ignore open failure.  Ignore seek/read failure.
Packit 437b5e
#
Packit 437b5e
# Use this if you want to remove trailing empty lines from selected files:
Packit 437b5e
#   perl -pi -0777 -e 's/\n\n+$/\n/' files...
Packit 437b5e
#
Packit 437b5e
require_exactly_one_NL_at_EOF_ =					\
Packit 437b5e
  foreach my $$f (@ARGV)						\
Packit 437b5e
    {									\
Packit 437b5e
      open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next;	\
Packit 437b5e
      my $$p = sysseek (F, -2, 2);					\
Packit 437b5e
      my $$c = "seek failure probably means file has < 2 bytes; ignore"; \
Packit 437b5e
      my $$last_two_bytes;						\
Packit 437b5e
      defined $$p and $$p = sysread F, $$last_two_bytes, 2;		\
Packit 437b5e
      close F;								\
Packit 437b5e
      $$c = "ignore read failure";					\
Packit 437b5e
      $$p && ($$last_two_bytes eq "\n\n"				\
Packit 437b5e
              || substr ($$last_two_bytes,1) ne "\n")			\
Packit 437b5e
          and (print $$f), $$fail=1;					\
Packit 437b5e
    }									\
Packit 437b5e
  END { exit defined $$fail }
Packit 437b5e
sc_prohibit_empty_lines_at_EOF:
Packit 437b5e
	@perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
Packit 437b5e
	  || { echo '$(ME): empty line(s) or no newline at EOF'		\
Packit 437b5e
		1>&2; exit 1; } || :
Packit 437b5e
Packit 437b5e
# Make sure we don't use st_blocks.  Use ST_NBLOCKS instead.
Packit 437b5e
# This is a bit of a kludge, since it prevents use of the string
Packit 437b5e
# even in comments, but for now it does the job with no false positives.
Packit 437b5e
sc_prohibit_stat_st_blocks:
Packit 437b5e
	@prohibit='[.>]st_blocks'					\
Packit 437b5e
	halt='do not use st_blocks; use ST_NBLOCKS'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Make sure we don't define any S_IS* macros in src/*.c files.
Packit 437b5e
# They're already defined via gnulib's sys/stat.h replacement.
Packit 437b5e
sc_prohibit_S_IS_definition:
Packit 437b5e
	@prohibit='^ *# *define  *S_IS'					\
Packit 437b5e
	halt='do not define S_IS* macros; include <sys/stat.h>'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Perl block to convert a match to FILE_NAME:LINENO:TEST,
Packit 437b5e
# that is shared by two definitions below.
Packit 437b5e
perl_filename_lineno_text_ =						\
Packit 437b5e
    -e '  {'								\
Packit 437b5e
    -e '    $$n = ($$` =~ tr/\n/\n/ + 1);'				\
Packit 437b5e
    -e '    ($$v = $$&) =~ s/\n/\\n/g;'					\
Packit 437b5e
    -e '    print "$$ARGV:$$n:$$v\n";'					\
Packit 437b5e
    -e '  }'
Packit 437b5e
Packit 437b5e
prohibit_doubled_word_RE_ ?= \
Packit 437b5e
  /\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims
Packit 437b5e
prohibit_doubled_word_ =						\
Packit 437b5e
    -e 'while ($(prohibit_doubled_word_RE_))'				\
Packit 437b5e
    $(perl_filename_lineno_text_)
Packit 437b5e
Packit 437b5e
# Define this to a regular expression that matches
Packit 437b5e
# any filename:dd:match lines you want to ignore.
Packit 437b5e
# The default is to ignore no matches.
Packit 437b5e
ignore_doubled_word_match_RE_ ?= ^$$
Packit 437b5e
Packit 437b5e
sc_prohibit_doubled_word:
Packit 437b5e
	@perl -n -0777 $(prohibit_doubled_word_) $$($(VC_LIST_EXCEPT))	\
Packit 437b5e
	  | grep -vE '$(ignore_doubled_word_match_RE_)'			\
Packit 437b5e
	  | grep . && { echo '$(ME): doubled words' 1>&2; exit 1; } || :
Packit 437b5e
Packit 437b5e
# A regular expression matching undesirable combinations of words like
Packit 437b5e
# "can not"; this matches them even when the two words appear on different
Packit 437b5e
# lines, but not when there is an intervening delimiter like "#" or "*".
Packit 437b5e
# Similarly undesirable, "See @xref{...}", since an @xref should start
Packit 437b5e
# a sentence.  Explicitly prohibit any prefix of "see" or "also".
Packit 437b5e
# Also prohibit a prefix matching "\w+ +".
Packit 437b5e
# @pxref gets the same see/also treatment and should be parenthesized;
Packit 437b5e
# presume it must *not* start a sentence.
Packit 437b5e
bad_xref_re_ ?= (?:[\w,:;] +|(?:see|also)\s+)\@xref\{
Packit 437b5e
bad_pxref_re_ ?= (?:[.!?]|(?:see|also))\s+\@pxref\{
Packit 437b5e
prohibit_undesirable_word_seq_RE_ ?=					\
Packit 437b5e
  /(?:\bcan\s+not\b|$(bad_xref_re_)|$(bad_pxref_re_))/gims
Packit 437b5e
prohibit_undesirable_word_seq_ =					\
Packit 437b5e
    -e 'while ($(prohibit_undesirable_word_seq_RE_))'			\
Packit 437b5e
    $(perl_filename_lineno_text_)
Packit 437b5e
# Define this to a regular expression that matches
Packit 437b5e
# any filename:dd:match lines you want to ignore.
Packit 437b5e
# The default is to ignore no matches.
Packit 437b5e
ignore_undesirable_word_sequence_RE_ ?= ^$$
Packit 437b5e
Packit 437b5e
sc_prohibit_undesirable_word_seq:
Packit 437b5e
	@perl -n -0777 $(prohibit_undesirable_word_seq_)		\
Packit 437b5e
	     $$($(VC_LIST_EXCEPT))					\
Packit 437b5e
	  | grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep .	\
Packit 437b5e
	  && { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
Packit 437b5e
Packit 437b5e
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
Packit 437b5e
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
Packit 437b5e
# Using test's -a and -o operators is not portable.
Packit 437b5e
# We prefer test over [, since the latter is spelled [[ in configure.ac.
Packit 437b5e
sc_prohibit_test_minus_ao:
Packit 437b5e
	@prohibit='(\
Packit 437b5e
	halt='$(_ptm1); $(_ptm2)'					\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Avoid a test bashism.
Packit 437b5e
sc_prohibit_test_double_equal:
Packit 437b5e
	@prohibit='(\
Packit 437b5e
	containing='#! */bin/[a-z]*sh'					\
Packit 437b5e
	halt='use "test x = x", not "test x =''= x"'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Each program that uses proper_name_utf8 must link with one of the
Packit 437b5e
# ICONV libraries.  Otherwise, some ICONV library must appear in LDADD.
Packit 437b5e
# The perl -0777 invocation below extracts the possibly-multi-line
Packit 437b5e
# definition of LDADD from the appropriate Makefile.am and exits 0
Packit 437b5e
# when it contains "ICONV".
Packit 437b5e
sc_proper_name_utf8_requires_ICONV:
Packit 437b5e
	@progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
Packit 437b5e
	if test "x$$progs" != x; then					\
Packit 437b5e
	  fail=0;							\
Packit 437b5e
	  for p in $$progs; do						\
Packit 437b5e
	    dir=$$(dirname "$$p");					\
Packit 437b5e
	    perl -0777							\
Packit 437b5e
	      -ne 'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)'	\
Packit 437b5e
	      $$dir/Makefile.am && continue;				\
Packit 437b5e
	    base=$$(basename "$$p" .c);					\
Packit 437b5e
	    grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null	\
Packit 437b5e
	      || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
Packit 437b5e
	  done;								\
Packit 437b5e
	  test $$fail = 1 &&						\
Packit 437b5e
	    { echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
Packit 437b5e
	      exit 1; } || :;						\
Packit 437b5e
	fi
Packit 437b5e
Packit 437b5e
# Warn about "c0nst struct Foo const foo[]",
Packit 437b5e
# but not about "char const *const foo" or "#define const const".
Packit 437b5e
sc_redundant_const:
Packit 437b5e
	@prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b'		\
Packit 437b5e
	halt='redundant "const" in declarations'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_const_long_option:
Packit 437b5e
	@prohibit='^ *static.*struct option '				\
Packit 437b5e
	exclude='const struct option|struct option const'		\
Packit 437b5e
	halt='add "const" to the above declarations'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Ensure that we don't accidentally insert an entry into an old NEWS block.
Packit 437b5e
sc_immutable_NEWS:
Packit 437b5e
	@if test -f $(srcdir)/NEWS; then				\
Packit 437b5e
	  test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : ||		\
Packit 437b5e
	    { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; };	\
Packit 437b5e
	fi
Packit 437b5e
Packit 437b5e
# Ensure that we use only the standard $(VAR) notation,
Packit 437b5e
# not @...@ in Makefile.am, now that we can rely on automake
Packit 437b5e
# to emit a definition for each substituted variable.
Packit 437b5e
# However, there is still one case in which @VAR@ use is not just
Packit 437b5e
# legitimate, but actually required: when augmenting an automake-defined
Packit 437b5e
# variable with a prefix.  For example, gettext uses this:
Packit 437b5e
# MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
Packit 437b5e
# otherwise, makeinfo would put German or French (current locale)
Packit 437b5e
# navigation hints in the otherwise-English documentation.
Packit 437b5e
#
Packit 437b5e
# Allow the package to add exceptions via a hook in cfg.mk;
Packit 437b5e
# for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
Packit 437b5e
# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
Packit 437b5e
_makefile_at_at_check_exceptions ?=
Packit 437b5e
sc_makefile_at_at_check:
Packit 437b5e
	@perl -ne '/\@\w+\@/'						\
Packit 437b5e
          -e ' && !/(\w+)\s+=.*\@\1\@$$/'				\
Packit 437b5e
          -e ''$(_makefile_at_at_check_exceptions)			\
Packit 437b5e
	  -e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}'	\
Packit 437b5e
	    $$($(VC_LIST_EXCEPT) | grep -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \
Packit 437b5e
	  && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
Packit 437b5e
Packit 437b5e
sc_makefile_TAB_only_indentation:
Packit 437b5e
	@prohibit='^	[ ]{8}'						\
Packit 437b5e
	in_vc_files='akefile|\.mk$$'					\
Packit 437b5e
	halt='found TAB-8-space indentation'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_m4_quote_check:
Packit 437b5e
	@prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]'		\
Packit 437b5e
	in_vc_files='(^configure\.ac|\.m4)$$'				\
Packit 437b5e
	halt='quote the first arg to AC_DEF*'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
fix_po_file_diag = \
Packit 437b5e
'you have changed the set of files with translatable diagnostics;\n\
Packit 437b5e
apply the above patch\n'
Packit 437b5e
Packit 437b5e
# Verify that all source files using _() (more specifically, files that
Packit 437b5e
# match $(_gl_translatable_string_re)) are listed in po/POTFILES.in.
Packit 437b5e
po_file ?= $(srcdir)/po/POTFILES.in
Packit 437b5e
generated_files ?= $(srcdir)/lib/*.[ch]
Packit 437b5e
_gl_translatable_string_re ?= \b(N?_|gettext *)\([^)"]*("|$$)
Packit 437b5e
sc_po_check:
Packit 437b5e
	@if test -f $(po_file); then					\
Packit 437b5e
	  grep -E -v '^(#|$$)' $(po_file)				\
Packit 437b5e
	    | grep -v '^src/false\.c$$' | sort > $@-1;			\
Packit 437b5e
	  files=;							\
Packit 437b5e
	  for file in $$($(VC_LIST_EXCEPT)) $(generated_files); do	\
Packit 437b5e
	    test -r $$file || continue;					\
Packit 437b5e
	    case $$file in						\
Packit 437b5e
	      *.m4|*.mk) continue ;;					\
Packit 437b5e
	      *.?|*.??) ;;						\
Packit 437b5e
	      *) continue;;						\
Packit 437b5e
	    esac;							\
Packit 437b5e
	    case $$file in						\
Packit 437b5e
	    *.[ch])							\
Packit 437b5e
	      base=`expr " $$file" : ' \(.*\)\..'`;			\
Packit 437b5e
	      { test -f $$base.l || test -f $$base.y; } && continue;;	\
Packit 437b5e
	    esac;							\
Packit 437b5e
	    files="$$files $$file";					\
Packit 437b5e
	  done;								\
Packit 437b5e
	  grep -E -l '$(_gl_translatable_string_re)' $$files		\
Packit 437b5e
	    | sed 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2;	\
Packit 437b5e
	  diff -u -L $(po_file) -L $(po_file) $@-1 $@-2			\
Packit 437b5e
	    || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; };	\
Packit 437b5e
	  rm -f $@-1 $@-2;						\
Packit 437b5e
	fi
Packit 437b5e
Packit 437b5e
# Sometimes it is useful to change the PATH environment variable
Packit 437b5e
# in Makefiles.  When doing so, it's better not to use the Unix-centric
Packit 437b5e
# path separator of ':', but rather the automake-provided '$(PATH_SEPARATOR)'.
Packit 437b5e
msg = 'Do not use ":" above; use $$(PATH_SEPARATOR) instead'
Packit 437b5e
sc_makefile_path_separator_check:
Packit 437b5e
	@prohibit='PATH[=].*:'						\
Packit 437b5e
	in_vc_files='akefile|\.mk$$'					\
Packit 437b5e
	halt=$(msg)							\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
v_etc_file = $(gnulib_dir)/lib/version-etc.c
Packit 437b5e
sample-test = tests/sample-test
Packit 437b5e
texi = doc/$(PACKAGE).texi
Packit 437b5e
# Make sure that the copyright date in $(v_etc_file) is up to date.
Packit 437b5e
# Do the same for the $(sample-test) and the main doc/.texi file.
Packit 437b5e
sc_copyright_check:
Packit 437b5e
	@require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };'		\
Packit 437b5e
	in_files=$(v_etc_file)						\
Packit 437b5e
	halt='out of date copyright in $(v_etc_file); update it'	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
	@require='# Copyright \(C\) '$$(date +%Y)' Free'		\
Packit 437b5e
	in_vc_files=$(sample-test)					\
Packit 437b5e
	halt='out of date copyright in $(sample-test); update it'	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
	@require='Copyright @copyright\{\} .*'$$(date +%Y)' Free'	\
Packit 437b5e
	in_vc_files=$(texi)						\
Packit 437b5e
	halt='out of date copyright in $(texi); update it'		\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# #if HAVE_... will evaluate to false for any non numeric string.
Packit 437b5e
# That would be flagged by using -Wundef, however gnulib currently
Packit 437b5e
# tests many undefined macros, and so we can't enable that option.
Packit 437b5e
# So at least preclude common boolean strings as macro values.
Packit 437b5e
sc_Wundef_boolean:
Packit 437b5e
	@prohibit='^#define.*(yes|no|true|false)$$'			\
Packit 437b5e
	in_files='$(CONFIG_INCLUDE)'					\
Packit 437b5e
	halt='Use 0 or 1 for macro values'				\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
# Even if you use pathmax.h to guarantee that PATH_MAX is defined, it might
Packit 437b5e
# not be constant, or might overflow a stack.  In general, use PATH_MAX as
Packit 437b5e
# a limit, not an array or alloca size.
Packit 437b5e
sc_prohibit_path_max_allocation:
Packit 437b5e
	@prohibit='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX'		\
Packit 437b5e
	halt='Avoid stack allocations of size PATH_MAX'			\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_vulnerable_makefile_CVE-2009-4029:
Packit 437b5e
	@prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
Packit 437b5e
	in_files='(^|/)Makefile\.in$$'					\
Packit 437b5e
	halt=$$(printf '%s\n'						\
Packit 437b5e
	  'the above files are vulnerable; beware of running'		\
Packit 437b5e
	  '  "make dist*" rules, and upgrade to fixed automake'		\
Packit 437b5e
	  '  see http://bugzilla.redhat.com/542609 for details')	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
sc_vulnerable_makefile_CVE-2012-3386:
Packit 437b5e
	@prohibit='chmod a\+w \$$\(distdir\)'				\
Packit 437b5e
	in_files='(^|/)Makefile\.in$$'					\
Packit 437b5e
	halt=$$(printf '%s\n'						\
Packit 437b5e
	  'the above files are vulnerable; beware of running'		\
Packit 437b5e
	  '  "make distcheck", and upgrade to fixed automake'		\
Packit 437b5e
	  '  see http://bugzilla.redhat.com/CVE-2012-3386 for details')	\
Packit 437b5e
	  $(_sc_search_regexp)
Packit 437b5e
Packit 437b5e
Packit 437b5e
## ------------- ##
Packit 437b5e
## Distribution. ##
Packit 437b5e
## ------------- ##
Packit 437b5e
Packit 437b5e
EXTRA_DIST +=						\
Packit 437b5e
	$(_build-aux)/sanity.mk				\
Packit 437b5e
	$(NOTHING_ELSE)