]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
automake: disable GNU make's internal pattern rules, for speed.
authorBruno Haible <bruno@clisp.org>
Fri, 21 Jul 2023 01:03:27 +0000 (18:03 -0700)
committerKarl Berry <karl@freefriends.org>
Fri, 21 Jul 2023 01:03:27 +0000 (18:03 -0700)
From https://bugs.gnu.org/64743.

* lib/am/footer.am: Disable GNU make's internal pattern rules.
* lib/Automake/Rule.pm (_conditionals_for_rule): Add special handling
for these pattern rules from footer.am.
(define): Likewise.
* t/nodep.sh: Update test to avoid matching the new %:: rules.
* t/fnoc.sh: Update test to avoid matching the new %:: SCCS rule.

* NEWS: Mention this.
* doc/automake.texi (Suffixes): Likewise.
(Doc changes written by Karl.)

NEWS
doc/automake.texi
lib/Automake/Rule.pm
lib/am/footer.am
t/fnoc.sh
t/nodep.sh

diff --git a/NEWS b/NEWS
index c64d4ef15120c2bfb024141fde478df479163fee..ced0fd640bc67417b76a05a38f211a108b524ddd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,9 @@ New in 1.17:
   - Variables using escaped \# will trigger portability warnings, but be
     retained when appended.  GNU Make & BSD Makes are known to support it.
 
+  - GNU Make's default pattern rules are disabled, for speed and debugging.
+    (.SUFFIXES was already cleared.) (bug#64743)
+
   - For Texinfo documents, if a .texi.in file exists, but no .texi, the
     .texi.in will be read. Texinfo source files need not be present at
     all, and if present, need not contain @setfilename. Then the file name
index 4561d1948639a8c317413edd93bb637858508b66..3b4f06e73f3db835e1786876ca55ae10e6824812 100644 (file)
@@ -10977,6 +10977,14 @@ Automake generate the suffix list for @code{.SUFFIXES}.  Any given
 @code{SUFFIXES} go at the start of the generated suffixes list, followed
 by Automake generated suffixes not already in the list.
 
+@c https://bugs.gnu.org/64743.
+@cindex built-in suffix and pattern rules, disabled
+@cindex suffix rules of Make, disabled
+@cindex pattern rules of GNU Make, disabled
+Automake disables the Make program's built-in rules with a
+@code{.SUFFIXES:} rule, and then adds whatever suffixes are
+necessary.  Automake also disables GNU Make's built-in pattern rules.
+
 @node Include
 @chapter Include
 
index 9f72d2728830de107166f7692302c56cc5bebc08..52ee3be4a237567a9f0c16b738794adb91c0bdee 100644 (file)
@@ -695,6 +695,9 @@ sub _conditionals_for_rule ($$$$)
 
   return $cond if !$message; # No ambiguity.
 
+  # Don't coalesce the several pattern rules from footer.am into a single one.
+  return $cond if $target eq "%:" && $where->get =~ /\/am\/footer\.am$/;
+
   if ($owner == RULE_USER)
     {
       # For user rules, just diagnose the ambiguity.
@@ -764,23 +767,27 @@ sub define ($$$$$)
 
   my $tdef = _rule_defn_with_exeext_awareness ($target, $cond, $where);
 
-  # A GNU make-style pattern rule has a single "%" in the target name.
-  msg ('portability', $where,
-       "'%'-style pattern rules are a GNU make extension")
-    if $target =~ /^[^%]*%[^%]*$/;
-
-  # See whether this is a duplicated target declaration.
-  if ($tdef)
+  # The pattern rules in footer.am look like duplicates, but really aren't.
+  if ($source !~ /\/am\/footer\.am$/)
     {
-      # Diagnose invalid target redefinitions, if any.  Note that some
-      # target redefinitions are valid (e.g., for multiple-targets
-      # pattern rules).
-      _maybe_warn_about_duplicated_target ($target, $tdef, $source,
-                                           $owner, $cond, $where);
-      # Return so we don't redefine the rule in our tables, don't check
-      # for ambiguous condition, etc.  The rule will be output anyway
-      # because '&read_am_file' ignores the return code.
-      return ();
+      # A GNU make-style pattern rule has a single "%" in the target name.
+      msg ('portability', $where,
+           "'%'-style pattern rules are a GNU make extension")
+        if $target =~ /^[^%]*%[^%]*$/;
+
+      # See whether this is a duplicated target declaration.
+      if ($tdef)
+        {
+          # Diagnose invalid target redefinitions, if any.  Note that some
+          # target redefinitions are valid (e.g., for multiple-targets
+          # pattern rules).
+          _maybe_warn_about_duplicated_target ($target, $tdef, $source,
+                                               $owner, $cond, $where);
+          # Return so we don't redefine the rule in our tables, don't check
+          # for ambiguous condition, etc.  The rule will be output anyway
+          # because '&read_am_file' ignores the return code.
+          return ();
+        }
     }
 
   my $rule = _crule $target;
index 9715c826c2e8c16872f8de352afb3ce07505df49..388defb1441acd3b2bcff64a4adf60c4045dfe63 100644 (file)
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
+
+# Tell GNU make to disable its built-in pattern rules.
+## This reduces make's internal processing.
+## Recommended by Paul Smith in
+## <https://lists.gnu.org/archive/html/bug-make/2023-07/msg00063.html>.
+## These rules have no effect on non-GNU make implementations.
+%:: %,v
+%:: RCS/%,v
+%:: RCS/%
+%:: s.%
+%:: SCCS/s.%
index 97b694c630ba9db97efde2bfa581efb5d95895d1..7d6b490969656781ddb2eb992666da31b28a0443 100644 (file)
--- a/t/fnoc.sh
+++ b/t/fnoc.sh
@@ -35,5 +35,10 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '[^F]CC' Makefile.in | grep -v MKDEP && exit 1
+# In bug#64743, explicit rules were added to disable make's default
+# built-in rules, including one for SCCS:
+# %:: SCCS/s.%
+# So don't match that. Meanwhile, MKDEP does not occur in the output
+# any more, but leaving it in in case it comes back.
+grep '[^F]CC' Makefile.in | grep -v MKDEP | grep -v SCCS && exit 1
 exit 0
index 4201c8ead2dfb49e53fcfc90d55b3384521f3523..0174b838e31357b86a82066c1bfb514428b8200d 100644 (file)
@@ -37,6 +37,6 @@ $ACLOCAL
 $AUTOMAKE
 
 sed 's/printf .*%s//' Makefile.in > Makefile.tmp
-grep '%' Makefile.tmp && exit 1
+grep -v '^%::' Makefile.tmp | grep '%' && exit 1
 
 :