newlib: Refactor makefile to fix LLVM compilation failures
This commit is contained in:
parent
2001b36284
commit
fd7a1de9c4
@ -48,17 +48,25 @@ NEWLIB_INCLUDE_DIR ?= $(firstword $(wildcard $(NEWLIB_INCLUDE_PATTERNS)))
|
||||
# If nothing was found we will try to fall back to searching for a cross-gcc in
|
||||
# the current PATH and use a relative path for the includes
|
||||
ifeq (,$(NEWLIB_INCLUDE_DIR))
|
||||
NEWLIB_INCLUDE_DIR := $(abspath $(wildcard $(dir $(shell which $(PREFIX)gcc))../$(TARGET_ARCH)/include))
|
||||
NEWLIB_INCLUDE_DIR := $(abspath $(wildcard $(dir $(shell command -v $(PREFIX)gcc))../$(TARGET_ARCH)/include))
|
||||
endif
|
||||
|
||||
NEWLIB_INCLUDES := -isystem $(NEWLIB_INCLUDE_DIR)
|
||||
ifeq ($(TOOLCHAIN),llvm)
|
||||
# A cross GCC already knows the target libc include path (build-in at compile time)
|
||||
# but Clang, when cross-compiling, needs to be told where to find the headers
|
||||
# for the system being built.
|
||||
# We also add -nostdinc to avoid including the host system headers by mistake
|
||||
# in case some header is missing from the cross tool chain
|
||||
NEWLIB_INCLUDES := -isystem $(NEWLIB_INCLUDE_DIR) -nostdinc
|
||||
NEWLIB_INCLUDES += $(addprefix -isystem ,$(abspath $(wildcard $(dir $(NEWLIB_INCLUDE_DIR))/usr/include)))
|
||||
endif
|
||||
|
||||
ifeq (1,$(USE_NEWLIB_NANO))
|
||||
NEWLIB_NANO_INCLUDE_DIR ?= $(NEWLIB_INCLUDE_DIR)/newlib-nano
|
||||
# newlib-nano overrides newlib.h and its include dir should therefore go before
|
||||
# the regular newlib include dir.
|
||||
NEWLIB_INCLUDES := -isystem $(NEWLIB_NANO_INCLUDE_DIR) $(NEWLIB_INCLUDES)
|
||||
# the regular system include dirs.
|
||||
INCLUDES := -isystem $(NEWLIB_NANO_INCLUDE_DIR) $(INCLUDES)
|
||||
endif
|
||||
|
||||
# Newlib includes should go before GCC includes.
|
||||
export INCLUDES := $(NEWLIB_INCLUDES) $(INCLUDES)
|
||||
# Newlib includes should go after GCC includes.
|
||||
export INCLUDES += $(NEWLIB_INCLUDES)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user