-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In preparation for cross-compilation support, the toolchain specific configurations have been decoupled from the build system. Preliminary checks have been added to determine the supported compilers, GCC and Clang. When 'CROSS_COMPILE' is set, the build system will honor it and set CC accordingly. Currently, only the GNU toolchain is supported for cross-compilation.
- Loading branch information
Showing
2 changed files
with
88 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
CC_IS_CLANG := | ||
CC_IS_GCC := | ||
|
||
# FIXME: Cross-compilation using Clang is not supported. | ||
ifdef CROSS_COMPILE | ||
CC := $(CROSS_COMPILE)gcc | ||
endif | ||
|
||
override CC := $(shell which $(CC)) | ||
ifndef CC | ||
$(error "Valid C compiler not found.") | ||
endif | ||
|
||
ifneq ($(shell $(CC) --version | head -n 1 | grep clang),) | ||
CC_IS_CLANG := 1 | ||
else ifneq ($(shell $(CC) --version | grep "Free Software Foundation"),) | ||
CC_IS_GCC := 1 | ||
endif | ||
|
||
ifeq ("$(CC_IS_CLANG)$(CC_IS_GCC)", "") | ||
$(warning Unsupported C compiler) | ||
endif | ||
|
||
ifndef CXX | ||
CXX := $(CROSS_COMPILE)g++ | ||
endif | ||
ifeq ("$(CC_IS_CLANG)", "1") | ||
override CXX := $(dir $(CC))$(subst clang,clang++,$(notdir $(CC))) | ||
endif | ||
|
||
ifndef CPP | ||
CPP := $(CC) -E | ||
endif | ||
|
||
ifndef LD | ||
LD := $(CROSS_COMPILE)ld | ||
endif | ||
|
||
ifndef AR | ||
AR := $(CROSS_COMPILE)ar | ||
endif | ||
|
||
ifndef RANLIB | ||
RANLIB := $(CROSS_COMPILE)ranlib | ||
endif | ||
|
||
ifndef STRIP | ||
STRIP := $(CROSS_COMPILE)strip -sx | ||
endif | ||
|
||
ifndef OBJCOPY | ||
OBJCOPY := $(CROSS_COMPILE)objcopy | ||
endif | ||
|
||
ifndef HOSTCC | ||
HOSTCC := $(HOST_COMPILE)gcc | ||
endif | ||
|
||
ifndef HOSTCXX | ||
HOSTCXX := $(HOST_COMPILE)g++ | ||
endif | ||
|
||
ifndef HOSTCPP | ||
HOSTCPP := $(HOSTCC) -E | ||
endif | ||
|
||
ifndef HOSTLD | ||
HOSTLD := $(HOST_COMPILE)ld | ||
endif | ||
|
||
ifndef HOSTAR | ||
HOSTAR := $(HOST_COMPILE)ar | ||
endif | ||
|
||
ifndef HOSTRANLIB | ||
HOSTRANLIB := $(HOST_COMPILE)ranlib | ||
endif | ||
|
||
ifndef HOSTSTRIP | ||
HOSTSTRIP := $(HOST_COMPILE)strip | ||
endif | ||
|
||
ifndef HOSTOBJCOPY | ||
HOSTOBJCOPY:= $(HOST_COMPILE)objcpy | ||
endif |