[Top][All Lists]

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

[bug#60535] [PATCH] depend2: switch echo|sed to automatic vars

From: Mike Frysinger
Subject: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
Date: Tue, 3 Jan 2023 21:06:46 -0500

The echo|sed is used to split the dirname & filename so it can insert
$(DEPDIR) in the middle, and then chop the trailing object suffix.  In
the generic case, %OBJ% is $@, so we can leverage the POSIX vars $(@D)
and $(@F) to do the pathname splitting and insert $(DEPDIR) in between.
For chopping the object suffix, we can use the $(xxx:...=...) syntax.
This avoids invoking sed completely.

These dirname/filename vars have been in POSIX since at least 2004.
> Each of the internal macros has an alternative form. When an
> uppercase 'D' or 'F' is appended to any of the macros, the
> meaning shall be changed to the directory part for 'D' and
> filename part for 'F'. The directory part is the path prefix
> of the file without a trailing slash; for the current directory,
> the directory part is '.'.

* lib/am/ Change echo|sed logic to make variables.
 lib/am/ | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/am/ b/lib/am/
index 507fa40b54a0..87546f9d8274 100644
--- a/lib/am/
+++ b/lib/am/
@@ -42,7 +42,7 @@ if %FASTDEP%
 ?!GENERIC?     %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??SUBDIROBJ?   %VERBOSE%depbase=`echo %OBJ% | sed 
+?GENERIC??SUBDIROBJ?   %VERBOSE%depbase='$(@D)/$(DEPDIR)/$(@F:.o=)';\
 else !%FASTDEP%
@@ -69,7 +69,7 @@ if %FASTDEP%
 ?!GENERIC?     %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??SUBDIROBJ?   %VERBOSE%depbase=`echo %OBJ% | sed 
+?GENERIC??SUBDIROBJ?   %VERBOSE%depbase='$(@D)/$(DEPDIR)/$(@F:.obj=)';\
 else !%FASTDEP%
@@ -98,7 +98,7 @@ if %FASTDEP%
 ?!GENERIC?     %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Plo
-?GENERIC??SUBDIROBJ?   %VERBOSE%depbase=`echo %OBJ% | sed 
+?GENERIC??SUBDIROBJ?   %VERBOSE%depbase='$(@D)/$(DEPDIR)/$(@F:.lo=)';\
 else !%FASTDEP%

reply via email to

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