Merge branch 'maint'
[platform/upstream/automake.git] / syntax-checks.mk
index 402e17f..77d2f42 100644 (file)
@@ -31,7 +31,7 @@ xtests := $(shell \
      done; \
    done | sort)
 
-xdefs = $(srcdir)/defs $(srcdir)/defs-static.in
+xdefs = $(srcdir)/t/ax/test-init.sh $(srcdir)/defs $(srcdir)/defs-static.in
 
 ams := $(shell find $(srcdir) -name '*.dir' -prune -o -name '*.am' -print)
 
@@ -39,7 +39,6 @@ ams := $(shell find $(srcdir) -name '*.dir' -prune -o -name '*.am' -print)
 # guaranteed to work on my machine.
 syntax_check_rules = \
 $(sc_tests_plain_check_rules) \
-sc_test_names \
 sc_diff_automake_in_automake \
 sc_diff_aclocal_in_automake \
 sc_perl_syntax \
@@ -56,13 +55,16 @@ sc_perl_at_uscore_in_scalar_context \
 sc_perl_local \
 sc_AMDEP_TRUE_in_automake_in \
 sc_tests_make_without_am_makeflags \
+$(sc_obsolete_requirements_rules) \
 sc_tests_obsolete_variables \
 sc_tests_here_document_format \
+sc_tests_command_subst \
 sc_tests_Exit_not_exit \
 sc_tests_automake_fails \
 sc_tests_required_after_defs \
 sc_tests_overriding_macros_on_cmdline \
 sc_tests_plain_sleep \
+sc_tests_ls_t \
 sc_m4_am_plain_egrep_fgrep \
 sc_tests_no_configure_in \
 sc_tests_PATH_SEPARATOR \
@@ -73,69 +75,6 @@ sc_unquoted_DESTDIR \
 sc_tabs_in_texi \
 sc_at_in_texi
 
-## Look for test whose names can cause spurious failures when used as
-## first argument to AC_INIT (chiefly because they might contain an
-## m4/m4sugar builtin or macro name).
-m4_builtins = \
-  __gnu__ \
-  __unix__ \
-  bpatsubst \
-  bregexp \
-  builtin \
-  changecom \
-  changequote \
-  changeword \
-  debugfile \
-  debugmode \
-  decr \
-  define \
-  defn \
-  divert \
-  divnum \
-  dnl \
-  dumpdef \
-  errprint \
-  esyscmd \
-  eval \
-  format \
-  ifdef \
-  ifelse \
-  include \
-  incr \
-  index \
-  indir \
-  len \
-  m4exit \
-  m4wrap \
-  maketemp \
-  mkstemp \
-  patsubst \
-  popdef \
-  pushdef \
-  regexp \
-  shift \
-  sinclude \
-  substr \
-  symbols \
-  syscmd \
-  sysval \
-  traceoff \
-  traceon \
-  translit \
-  undefine \
-  undivert
-sc_test_names:
-       @m4_builtin_rx=`echo $(m4_builtins) | sed 's/ /|/g'`; \
-        m4_macro_rx="\\<($$m4_builtin_rx)\\>|\\<_?(A[CUMHS]|m4)_"; \
-        if { \
-          for t in $(xtests); do echo $$t; done \
-            | LC_ALL=C grep -E "$$m4_macro_rx"; \
-        }; then \
-          echo "the names of the tests above can be problematic" 1>&2; \
-          echo "Avoid test names that contain names of m4 macros" 1>&2; \
-          exit 1; \
-        fi
-
 ## These check avoids accidental configure substitutions in the source.
 ## There are exactly 9 lines that should be modified from automake.in to
 ## automake, and 10 lines that should be modified from aclocal.in to
@@ -158,10 +97,10 @@ sc_perl_syntax:
        @perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w automake
        @perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w aclocal
 
-## expect no instances of '${...}'.  However, $${...} is ok, since that
+## Expect no instances of '${...}'.  However, $${...} is ok, since that
 ## is a shell construct, not a Makefile construct.
 sc_no_brace_variable_expansions:
-       @if grep -F '$${' $(ams) | grep -F -v '$$$$'; then \
+       @if grep -v '^ *#' $(ams) | grep -F '$${' | grep -F -v '$$$$'; then \
          echo "Found too many uses of '\$${' in the lines above." 1>&2; \
          exit 1;                               \
        else :; fi
@@ -169,7 +108,7 @@ sc_no_brace_variable_expansions:
 ## Make sure 'rm' is called with '-f'.
 sc_rm_minus_f:
        @if grep -v '^#' $(ams) $(xtests) \
-          | grep -v '/spy-rm\.tap:' \
+          | grep -vE '/(spy-rm\.tap|subobj-clean.*-pr10697\.sh):' \
           | grep -E '\<rm ([^-]|\-[^f ]*\>)'; \
        then \
          echo "Suspicious 'rm' invocation." 1>&2; \
@@ -300,6 +239,19 @@ sc_tests_obsolete_variables:
          exit 1; \
        else :; fi
 
+## Look out for obsolete requirements specified in the test cases.
+sc_obsolete_requirements_rules = sc_no_texi2dvi-o sc_no_makeinfo-html
+modern-requirement.texi2dvi-o = texi2dvi
+modern-requirement.makeinfo-html = makeinfo
+
+$(sc_obsolete_requirements_rules): sc_no_% :
+       @if grep -E 'required=.*\b$*\b' $(xtests); then \
+         echo "Requirement '$*' is obsolete and shouldn't" \
+              "be used anymore." >&2; \
+         echo "You should use '$(modern-requirement.$*)' instead." >&2; \
+         exit 1; \
+       fi
+
 ## Tests should never call some programs directly, but only through the
 ## corresponding variable (e.g., '$MAKE', not 'make').  This will allow
 ## the programs to be overridden at configure time (for less brittleness)
@@ -335,19 +287,46 @@ $(sc_tests_plain_check_rules): sc_tests_plain_% :
 ## Tests should only use END and EOF for here documents
 ## (so that the next test is effective).
 sc_tests_here_document_format:
-       @if grep '<<' $(xtests) | grep -Ev '\b(END|EOF)\b|\bstd::cout <<'; then \
+       @if grep '<<' $(xtests) | grep -Ev '\b(END|EOF)\b|\bcout <<'; then \
          echo 'Use here documents with "END" and "EOF" only, for greppability.' 1>&2; \
          exit 1; \
        fi
 
+## Our test case should use the $(...) POSIX form for command substitution,
+## rather than the older `...` form.
+## The point of ignoring text on here-documents is that we want to exempt
+## Makefile.am rules, configure.ac code and helper shell script created and
+## used by out shell scripts, because Autoconf (as of version 2.69) does not
+## yet ensure that $CONFIG_SHELL will be set to a proper POSIX shell.
+sc_tests_command_subst:
+       @found=false; \
+       scan () { \
+         sed -n -e '/^#/d' \
+                -e '/<<.*END/,/^END/b' -e '/<<.*EOF/,/^EOF/b' \
+                -e 's/\\`/\\{backtick}/' \
+                -e "s/[^\\]'\([^']*\`[^']*\)*'/'{quoted-text}'/g" \
+                -e '/`/p' $$*; \
+       }; \
+       for file in $(xtests); do \
+         res=`scan $$file`; \
+         if test -n "$$res"; then \
+           echo "$$file:$$res"; \
+           found=true; \
+         fi; \
+       done; \
+       if $$found; then \
+         echo 'Use $$(...), not `...`, for command substitutions.' >&2; \
+         exit 1; \
+       fi
+
 ## Tests should never call exit directly, but use Exit.
 ## This is so that the exit status is transported correctly across the 0 trap.
-## Ignore comments, testsuite self tests, and one perl line in ext2.sh.
+## Ignore comments and our testsuite's own self tests.
 sc_tests_Exit_not_exit:
        @found=false; for file in $(xtests); do \
          case $$file in */self-check-*) continue;; esac; \
-         res=`sed -n -e '/^#/d; /^\$$PERL/d' -e '/<<.*END/,/^END/b' \
-                     -e '/<<.*EOF/,/^EOF/b' -e '/exit [$$0-9]/p' $$file`; \
+         res=`sed -n -e '/^#/d' -e '/<<.*END/,/^END/b' -e '/<<.*EOF/,/^EOF/b' \
+                     -e '/exit [$$0-9]/p' $$file`; \
          if test -n "$$res"; then \
            echo "$$file:$$res"; \
            found=true; \
@@ -416,6 +395,16 @@ sc_tests_overriding_macros_on_cmdline:
          exit 1; \
        fi
 
+## Prefer use of our 'is_newest' auxiliary script over the more hacky
+## idiom "test $(ls -1t new old | sed 1q) = new", which is both more
+## cumbersome and more fragile.
+sc_tests_ls_t:
+       @if LC_ALL=C grep -E '\bls(\s+-[a-zA-Z0-9]+)*\s+-[a-zA-Z0-9]*t' \
+           $(xtests); then \
+         echo "Use 'is_newest' rather than hacks based on 'ls -t'" 1>&2; \
+         exit 1; \
+       fi
+
 ## Never use 'sleep 1' to create files with different timestamps.
 ## Use '$sleep' instead.  Some filesystems (e.g., Windows) have only
 ## a 2sec resolution.