Skip to content

Commit adb610f

Browse files
committed
Make the build logic more robust for BSD systems
This properly sets MAKE (when undefined) on BSDs to gmake rather than make, which refers to the incompatible BSD Make. Further, it betters detection of Clang as the default compiler, which is the case on FreeBSD 11.0+ and OpenBSD 6.0+.
1 parent af67321 commit adb610f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

makefile_include.mk

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@ ifndef CROSS_COMPILE
1313
CROSS_COMPILE:=
1414
endif
1515

16-
ifeq ($(CC),cc)
16+
ifeq ($(origin CC),default)
17+
CSTR := "\#ifdef __clang__\nCLANG\n\#endif\n"
18+
ifeq ($(PLATFORM),FreeBSD)
19+
# XXX: FreeBSD needs extra escaping for some reason
20+
CSTR := $$$(CSTR)
21+
endif
22+
ifneq (,$(shell echo $(CSTR) | $(CC) -E - | grep CLANG))
23+
CC := $(CROSS_COMPILE)clang
24+
else
1725
CC := $(CROSS_COMPILE)gcc
1826
endif
27+
endif
1928
LD:=$(CROSS_COMPILE)ld
2029
AR:=$(CROSS_COMPILE)ar
2130

@@ -24,7 +33,12 @@ AR:=$(CROSS_COMPILE)ar
2433
ARFLAGS:=r
2534

2635
ifndef MAKE
27-
MAKE:=make
36+
# BSDs refer to GNU Make as gmake
37+
ifneq (,$(findstring $(PLATFORM),FreeBSD OpenBSD DragonFly NetBSD))
38+
MAKE=gmake
39+
else
40+
MAKE=make
41+
endif
2842
endif
2943

3044
ifndef INSTALL_CMD

0 commit comments

Comments
 (0)