[PATCH] try generic compiler name "cc" before falling back to "gcc".
From: Rob Landley
Date: Wed Feb 02 2022 - 05:19:37 EST
Distros like debian install the generic "cc" name for both gcc and clang, and
the plumbing already does CC_VERSION_TEXT to include Makefile.clang if necessary.
Signed-off-by: Rob Landley <rob@xxxxxxxxxxx>
---
Tested that llvm works with the hexagon toolchain wrapped as:
$ ls
hexagon-unknown-linux-musl-ar hexagon-unknown-linux-musl-objcopy
hexagon-unknown-linux-musl-c++ hexagon-unknown-linux-musl-objdump
hexagon-unknown-linux-musl-cc hexagon-unknown-linux-musl-ranlib
hexagon-unknown-linux-musl-ld hexagon-unknown-linux-musl-readelf
hexagon-unknown-linux-musl-nm
Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 3f07f0f04475..f3f8df88f249 100644
--- a/Makefile
+++ b/Makefile
@@ -427,7 +427,7 @@ ifneq ($(LLVM),)
HOSTCC = clang
HOSTCXX = clang++
else
-HOSTCC = gcc
+HOSTCC := $(shell cc --version >/dev/null 2>&1 && echo cc || echo gcc)
HOSTCXX = g++
endif
@@ -452,7 +452,8 @@ OBJDUMP = llvm-objdump
READELF = llvm-readelf
STRIP = llvm-strip
else
-CC = $(CROSS_COMPILE)gcc
+CC := $(CROSS_COMPILE)$(shell $(CROSS_COMPILE)cc --version \
+ >/dev/null 2>&1 && echo cc || echo gcc)
LD = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm