Skip to content

Commit 7008035

Browse files
committed
Makefile: improve compiler selection
- Use "CC :=" instead of "CC ?=" to ensure the correct compiler - Change order of condition, because of packages like "gcc-$ARCH-linux-gnu" on Fedora/RHEL - Add fallback condition for openSUSE and others - Use tabs Signed-off-by: Valentin Dela <[email protected]>
1 parent 7045f8b commit 7008035

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,15 @@ else ifeq ($(GOOS),linux)
599599
# CC is required for cross-compiling on Linux.
600600
# On Debian, Ubuntu, and related distributions, compilers are named like x86_64-linux-gnu-gcc
601601
# On Fedora, RHEL, and related distributions, the equivalent is x86_64-redhat-linux-gcc
602-
CC ?= $(shell \
603-
if command -v $(call to_uname_m,$(GOARCH))-linux-gnu-gcc >/dev/null 2>&1; then \
604-
echo $(call to_uname_m,$(GOARCH))-linux-gnu-gcc; \
605-
elif command -v $(call to_uname_m,$(GOARCH))-redhat-linux-gcc >/dev/null 2>&1; then \
606-
echo $(call to_uname_m,$(GOARCH))-redhat-linux-gcc; \
607-
fi)
602+
# On openSUSE and as a generic fallback, we simply use gcc
603+
CC := $(shell \
604+
if command -v $(call to_uname_m,$(GOARCH))-redhat-linux-gcc >/dev/null 2>&1; then \
605+
echo $(call to_uname_m,$(GOARCH))-redhat-linux-gcc; \
606+
elif command -v $(call to_uname_m,$(GOARCH))-linux-gnu-gcc >/dev/null 2>&1; then \
607+
echo $(call to_uname_m,$(GOARCH))-linux-gnu-gcc; \
608+
else \
609+
echo gcc; \
610+
fi)
608611
else ifeq ($(GOOS),windows)
609612
# artifact in zip format also provided for Windows.
610613
ARTIFACT_FILE_EXTENSIONS += .zip

0 commit comments

Comments
 (0)