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

Nick Alcock nick.alcock at oracle.com
Wed Nov 29 16:08:26 UTC 2023


This makes it at least *possible* to support 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>
---
 GNUmakefile | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index 2ffd4c497886..c987a1ee19b7 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)))), \
+$(if $(subst sparc64-linux,,$(subst aarch64-linux,,$(subst x86_64-linux,,$(ARCHOS)))), \
     $(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.42.0.271.g85384428f1




More information about the DTrace-devel mailing list