summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJuro Bystricky <juro.bystricky@intel.com>2016-07-26 09:44:16 -0700
committerAndrew Boie <andrew.p.boie@intel.com>2016-07-27 17:15:56 +0000
commitf25ac092b91b03eb231ee340e5eeffe52f14989e (patch)
treeb2d755acf961799bd490faafdd8bee000d6f59cf /Makefile
parent9915378e8c01c497aac6928fa807b80744826156 (diff)
Makefile: Restructure for multilibs
Several Zephyr SDK toolchains support multilibs. Instead of hard-coding locations of the libraries, the proper/cleanest way is to query the GCC compiler for the locations of libgcc and libc. However, in order to do this, we need to ensure a certain order of initialization in the Makefile: 1. Determine CROSS_COMPILE. We cannot determine LIB_INCLUDE_DIR, TOOLCHAIN_CFLAGS yet, as we don't know the KBUILD_CFLAGS yet. 2. Calculate KBUILD_CFLAGS using CROSS_COMPILE KBUILD_CFLAGS often need the compiler to validate options, i.e: KBUILD_CFLAGS += $(call cc-option,-mabi=aapcs -mthumb -mcpu=cortex-m0) However, LIB_INCLUDE_DIR, TOOLCHAIN_CFLAGS should not be needed for this 3. Finally, using CROSS_COMPILE and KBUILD_CFLAGS determine LIB_INCLUDE_DIR, TOOLCHAIN_CFLAGS by querying GCC using -print-libgcc-file-name and -print-multi-directory command line options. This change should only affect Zephyr SDK toolchains, all other toolchains are expected to function as before. Change-Id: I27b460d46fe65d05fcb8bafb51cd6b3deba275ed Signed-off-by: Juro Bystricky <juro.bystricky@intel.com> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile14
1 files changed, 10 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 484eaec95..6799432d4 100644
--- a/Makefile
+++ b/Makefile
@@ -563,6 +563,7 @@ endif # $(dot-config)
ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH))
export ARCH
+
ifdef ZEPHYR_GCC_VARIANT
include $(srctree)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
else
@@ -570,7 +571,6 @@ $(if $(CROSS_COMPILE),, \
$(error ZEPHYR_GCC_VARIANT is not set. ))
endif
-
-include $(srctree)/ext/Makefile
-include $(srctree)/lib/Makefile
@@ -583,9 +583,6 @@ endif
export COMPILER
endif
-QEMU_BIN_PATH ?= /usr/bin
-QEMU = $(QEMU_BIN_PATH)/$(QEMU_$(ARCH))
-
# The all: target is the default when no target is given on the
# command line.
# This allow a user to issue only 'make' to build a kernel including modules
@@ -718,6 +715,15 @@ endif
export LD_TOOLCHAIN KBUILD_LDS
+ifdef MAKEFILE_TOOLCHAIN_DO_PASS2
+# KBUILD_CFLAGS known at this point.
+# We can now determine which multilib libraries to use
+include $(srctree)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
+endif
+
+QEMU_BIN_PATH ?= /usr/bin
+QEMU = $(QEMU_BIN_PATH)/$(QEMU_$(ARCH))
+
# The all: target is the default when no target is given on the
# command line.
# This allow a user to issue only 'make' to build a kernel including modules