public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] Makefile: Use make internal string functions
@ 2024-11-27 16:16 Laurent Vivier
  2024-11-27 22:33 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2024-11-27 16:16 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

TARGET_ARCH is computed from '$(CC) -dumpmachine' using external
bash commands like echo, cut, tr and sed. This can be done using
make internal string functions.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index cb7448079de5..1fce73707805 100644
--- a/Makefile
+++ b/Makefile
@@ -17,8 +17,9 @@ DUAL_STACK_SOCKETS := 1
 
 TARGET ?= $(shell $(CC) -dumpmachine)
 # Get 'uname -m'-like architecture description for target
-TARGET_ARCH := $(shell echo $(TARGET) | cut -f1 -d- | tr [A-Z] [a-z])
-TARGET_ARCH := $(shell echo $(TARGET_ARCH) | sed 's/powerpc/ppc/')
+TARGET_ARCH := $(firstword $(subst -, ,$(TARGET)))
+TARGET_ARCH := $(patsubst [:upper:],[:lower:],$(TARGET_ARCH))
+TARGET_ARCH := $(subst powerpc,ppc,$(TARGET_ARCH))
 
 # On some systems enabling optimization also enables source fortification,
 # automagically. Do not override it.
-- 
@@ -17,8 +17,9 @@ DUAL_STACK_SOCKETS := 1
 
 TARGET ?= $(shell $(CC) -dumpmachine)
 # Get 'uname -m'-like architecture description for target
-TARGET_ARCH := $(shell echo $(TARGET) | cut -f1 -d- | tr [A-Z] [a-z])
-TARGET_ARCH := $(shell echo $(TARGET_ARCH) | sed 's/powerpc/ppc/')
+TARGET_ARCH := $(firstword $(subst -, ,$(TARGET)))
+TARGET_ARCH := $(patsubst [:upper:],[:lower:],$(TARGET_ARCH))
+TARGET_ARCH := $(subst powerpc,ppc,$(TARGET_ARCH))
 
 # On some systems enabling optimization also enables source fortification,
 # automagically. Do not override it.
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Makefile: Use make internal string functions
  2024-11-27 16:16 [PATCH] Makefile: Use make internal string functions Laurent Vivier
@ 2024-11-27 22:33 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2024-11-27 22:33 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]

On Wed, Nov 27, 2024 at 05:16:45PM +0100, Laurent Vivier wrote:
> TARGET_ARCH is computed from '$(CC) -dumpmachine' using external
> bash commands like echo, cut, tr and sed. This can be done using
> make internal string functions.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  Makefile | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index cb7448079de5..1fce73707805 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -17,8 +17,9 @@ DUAL_STACK_SOCKETS := 1
>  
>  TARGET ?= $(shell $(CC) -dumpmachine)
>  # Get 'uname -m'-like architecture description for target
> -TARGET_ARCH := $(shell echo $(TARGET) | cut -f1 -d- | tr [A-Z] [a-z])
> -TARGET_ARCH := $(shell echo $(TARGET_ARCH) | sed 's/powerpc/ppc/')
> +TARGET_ARCH := $(firstword $(subst -, ,$(TARGET)))
> +TARGET_ARCH := $(patsubst [:upper:],[:lower:],$(TARGET_ARCH))
> +TARGET_ARCH := $(subst powerpc,ppc,$(TARGET_ARCH))
>  
>  # On some systems enabling optimization also enables source fortification,
>  # automagically. Do not override it.

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-27 23:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-27 16:16 [PATCH] Makefile: Use make internal string functions Laurent Vivier
2024-11-27 22:33 ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).