[DTrace-devel] [PATCH v2 2/9] build: get the architecture from gcc -dumpmachine, not uname -m

Nick Alcock nick.alcock at oracle.com
Mon Jan 15 19:34:32 UTC 2024


This lays the groundwork for future support of cross-compilation.
It doesn't mean we do support it, but it's the first necessary
prerequisite for such support.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
---
 GNUmakefile | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index 2ffd4c497886..9b01d824ad32 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -18,12 +18,13 @@ VERSION := 2.0.0
 
 # Verify supported hardware.
 
-ARCH := $(shell uname -m)
+ARCHOS := $(shell gcc -dumpmachine | sed 's,-redhat,,; s,-unknown,,; s,-pc,,; s,-gnu$$,,')
+ARCH := $(subst -linux,,$(ARCHOS))
 
 $(if $(subst sparc64,,$(subst aarch64,,$(subst x86_64,,$(ARCH)))), \
     $(error "Error: DTrace for Linux only supports x86_64, ARM64 and sparc64"),)
-$(if $(subst Linux,,$(shell uname -s)), \
-    $(error "Error: DTrace only supports Linux"),)
+$(if $(filter %-linux,$(ARCHOS)),, \
+    $(error "Error: DTrace only supports Linux"))
 
 CFLAGS ?= -O2 -Wall -pedantic -Wno-unknown-pragmas
 LDFLAGS ?=
-- 
2.43.0.272.gce700b77fd




More information about the DTrace-devel mailing list