From 826c9ef64a983bdc71d7bde591b785f65cf1d268 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 3 Nov 2017 15:55:55 -0700 Subject: [PATCH] build: detect architecture via cc -dumpmachine Similar to commit 98f84e6255 ("build: detect OS via cc -dumpmachine"), we can use the C compiler's -dumpmachine output to detect the target CPU architecture rather than relying on the build machine's uname output. This helps enable correct CPU detection when $(CC) is a cross compiler. Change-Id: I72c34294a1ff7dd9df3aa45dfc319e5b81d51f85 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/385709 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker --- mk/spdk.common.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk index 59063858a..5cdeebe3e 100644 --- a/mk/spdk.common.mk +++ b/mk/spdk.common.mk @@ -57,11 +57,11 @@ ifneq ($(filter freebsd%,$(TARGET_TRIPLET_WORDS)),) OS = FreeBSD endif +TARGET_MACHINE := $(firstword $(TARGET_TRIPLET_WORDS)) COMMON_CFLAGS = -g $(C_OPT) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -fno-strict-aliasing -I$(SPDK_ROOT_DIR)/include -UNAME_P := $(shell uname -p) -ifneq ($(filter ppc%,$(UNAME_P)),) +ifneq ($(filter powerpc%,$(TARGET_MACHINE)),) COMMON_CFLAGS += -mcpu=native else COMMON_CFLAGS += -march=native