File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,23 @@ ifndef CROSS_COMPILE
1313 CROSS_COMPILE: =
1414endif
1515
16- ifeq ($(CC ) ,cc)
17- CC := $(CROSS_COMPILE ) gcc
16+ # We only need to go through this dance of determining the right compiler if we're using
17+ # cross compilation, otherwise $(CC) is fine as-is.
18+ ifneq (,$(CROSS_COMPILE ) )
19+ ifeq ($(origin CC ) ,default)
20+ CSTR := "\# ifdef __clang__\nCLANG\n\#endif\n"
21+ ifeq ($(PLATFORM ) ,FreeBSD)
22+ # XXX: FreeBSD needs extra escaping for some reason
23+ CSTR := $$$(CSTR )
1824endif
25+ ifneq (,$(shell echo $(CSTR ) | $(CC ) -E - | grep CLANG) )
26+ CC := $(CROSS_COMPILE ) clang
27+ else
28+ CC := $(CROSS_COMPILE ) gcc
29+ endif # Clang
30+ endif # cc is Make's default
31+ endif # CROSS_COMPILE non-empty
32+
1933LD: =$(CROSS_COMPILE ) ld
2034AR: =$(CROSS_COMPILE ) ar
2135
@@ -24,7 +38,12 @@ AR:=$(CROSS_COMPILE)ar
2438ARFLAGS: =r
2539
2640ifndef MAKE
27- MAKE: =make
41+ # BSDs refer to GNU Make as gmake
42+ ifneq (,$(findstring $(PLATFORM ) ,FreeBSD OpenBSD DragonFly NetBSD) )
43+ MAKE =gmake
44+ else
45+ MAKE =make
46+ endif
2847endif
2948
3049ifndef INSTALL_CMD
You can’t perform that action at this time.
0 commit comments