automake-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[automake-commit] branch master updated: dirstamp: switch to a pattern r


From: Mike Frysinger
Subject: [automake-commit] branch master updated: dirstamp: switch to a pattern rule
Date: Thu, 12 Jan 2023 20:26:41 -0500

This is an automated email from the git hooks/post-receive script.

vapier pushed a commit to branch master
in repository automake.

View the commit online:
https://git.savannah.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=55f8fcfd08cbf15d65d61dd2db934b6c3171cf06

The following commit(s) were added to refs/heads/master by this push:
     new 55f8fcfd0 dirstamp: switch to a pattern rule
55f8fcfd0 is described below

commit 55f8fcfd08cbf15d65d61dd2db934b6c3171cf06
Author: Mike Frysinger <vapier@gentoo.org>
AuthorDate: Wed Jan 11 22:07:22 2023 -0500

    dirstamp: switch to a pattern rule
    
    We can leverage $(@D) to generate a single pattern rule for all dirstamp
    rules.  This saves many lines in the output -- normally we create 2 rules
    (or 6 lines) per subdir, and projects that use subdirs tend to use them
    quite a bit.
    
    In the most extreme & unlikely case (1 subdir, no depdir support), the
    line count is the same.  In every other case, it's always a win.
    
    Looking at a few real world projects, the line deltas:
    * GNU libgloss: +3 -66
    * GNU newlib:   +3 -714
    * GNU sim:      +3 -138
    
    There shouldn't be any concerns about portability with $(@D) because:
    (0) This has been in POSIX (and beyond) for decades,
    (1) We only generate this rule iff we know the dirstamp is in a subdir
        (so we'd never have a case where $(@D) would expand to the cwd, and
        that is where a few implementations are known to be buggy),
    (2) We already rely on $(@D) in our depdir code, and have since 2014
        (the Automake 1.16 release).
---
 bin/automake.in | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/bin/automake.in b/bin/automake.in
index 1c13a3187..139d5ad93 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -7893,6 +7893,14 @@ sub require_build_directory
   $directory_map{$directory} = $dirstamp;
   $directory_map{$cdir} = $dirstamp;
 
+  # Generate the pattern rule only once.
+  if (! vardef ('am__dirstamp', TRUE))
+    {
+      $output_rules .= ("%/\$(am__dirstamp):\n"
+                       . "\t\@\$(MKDIR_P) \$(\@D)\n"
+                       . "\t\@: >>\$\@\n");
+    }
+
   # Set a variable for the dirstamp basename.
   define_pretty_variable ('am__dirstamp', TRUE, INTERNAL,
                          '$(am__leading_dot)dirstamp');
@@ -7900,10 +7908,6 @@ sub require_build_directory
   # Directory must be removed by 'make distclean'.
   $clean_files{$dirstamp} = DIST_CLEAN;
 
-  $output_rules .= ("$dirstamp:\n"
-                   . "\t\@\$(MKDIR_P) $directory\n"
-                   . "\t\@: >>$dirstamp\n");
-
   return $dirstamp;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]