This fixes the mkimage build for situations where HOSTCC and friends
need to be overridden and the u-boot makefile defaults don't work.

Signed-off-by: Stefan Müller-Klieser <s.mueller-klie...@phytec.de>
---
 ...file-improve-cross_tools-target-usability.patch | 35 ++++++++++++++++++
 ...ile-add-override-statements-for-cross_too.patch | 41 ++++++++++++++++++++++
 meta/recipes-bsp/u-boot/u-boot-mkimage_2016.03.bb  |  8 ++++-
 3 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 
meta/recipes-bsp/u-boot/u-boot-mkimage/0001-tools-Makefile-improve-cross_tools-target-usability.patch
 create mode 100644 
meta/recipes-bsp/u-boot/u-boot-mkimage/0002-tools-Makefile-add-override-statements-for-cross_too.patch

diff --git 
a/meta/recipes-bsp/u-boot/u-boot-mkimage/0001-tools-Makefile-improve-cross_tools-target-usability.patch
 
b/meta/recipes-bsp/u-boot/u-boot-mkimage/0001-tools-Makefile-improve-cross_tools-target-usability.patch
new file mode 100644
index 0000000..4b0d0e8
--- /dev/null
+++ 
b/meta/recipes-bsp/u-boot/u-boot-mkimage/0001-tools-Makefile-improve-cross_tools-target-usability.patch
@@ -0,0 +1,35 @@
+From ad129135402b38deeb37383c86781341cf239b6a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20M=C3=BCller-Klieser?= <s.mueller-klie...@phytec.de>
+Date: Mon, 31 Oct 2016 10:30:18 +0100
+Subject: [PATCH 1/2] tools: Makefile: improve cross_tools target usability
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When building the cross_tools target, HOSTCFLAGS and HOSTLDFLAGS will
+propagate to the target build. This should not happen and is easy to
+prevent.
+
+Upstream-Status: Submitted
+
+Signed-off-by: Stefan Müller-Klieser <s.mueller-klie...@phytec.de>
+---
+ tools/Makefile | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tools/Makefile b/tools/Makefile
+index 400588c..305336c 100644
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -263,6 +263,8 @@ subdir- += env
+ 
+ ifneq ($(CROSS_BUILD_TOOLS),)
+ HOSTCC = $(CC)
++HOSTCFLAGS = $(CFLAGS)
++HOSTLDFLAGS = $(LDFLAGS)
+ 
+ quiet_cmd_crosstools_strip = STRIP   $^
+       cmd_crosstools_strip = $(STRIP) $^; touch $@
+-- 
+1.9.1
+
diff --git 
a/meta/recipes-bsp/u-boot/u-boot-mkimage/0002-tools-Makefile-add-override-statements-for-cross_too.patch
 
b/meta/recipes-bsp/u-boot/u-boot-mkimage/0002-tools-Makefile-add-override-statements-for-cross_too.patch
new file mode 100644
index 0000000..4c7b6d0
--- /dev/null
+++ 
b/meta/recipes-bsp/u-boot/u-boot-mkimage/0002-tools-Makefile-add-override-statements-for-cross_too.patch
@@ -0,0 +1,41 @@
+From 2772e2ad0e097590e77fa338295d839d6ae6037c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20M=C3=BCller-Klieser?= <s.mueller-klie...@phytec.de>
+Date: Thu, 3 Nov 2016 08:48:02 +0100
+Subject: [PATCH 2/2] tools: Makefile: add override statements for cross_tools
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This fixes the use case where one needs to override the host compiler
+flags for building the target tools. Usually the Makefile will build the
+basic tools first using the hostcc. After that cc will be assigned to
+hostcc to build the target tools. So in this scenario overriding HOSTCC
+fails to build. Using the override statement is one possible fix.
+
+Upstream-Status: Pending
+
+Signed-off-by: Stefan Müller-Klieser <s.mueller-klie...@phytec.de>
+---
+ tools/Makefile | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/tools/Makefile b/tools/Makefile
+index 305336c..9cb1607 100644
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -262,9 +262,9 @@ $(LICENSE_H): $(obj)/bin2header 
$(srctree)/Licenses/gpl-2.0.txt
+ subdir- += env
+ 
+ ifneq ($(CROSS_BUILD_TOOLS),)
+-HOSTCC = $(CC)
+-HOSTCFLAGS = $(CFLAGS)
+-HOSTLDFLAGS = $(LDFLAGS)
++override HOSTCC = $(CC)
++override HOSTCFLAGS = $(CFLAGS)
++override HOSTLDFLAGS = $(LDFLAGS)
+ 
+ quiet_cmd_crosstools_strip = STRIP   $^
+       cmd_crosstools_strip = $(STRIP) $^; touch $@
+-- 
+1.9.1
+
diff --git a/meta/recipes-bsp/u-boot/u-boot-mkimage_2016.03.bb 
b/meta/recipes-bsp/u-boot/u-boot-mkimage_2016.03.bb
index 5025961..0749408 100644
--- a/meta/recipes-bsp/u-boot/u-boot-mkimage_2016.03.bb
+++ b/meta/recipes-bsp/u-boot/u-boot-mkimage_2016.03.bb
@@ -3,7 +3,13 @@ require u-boot-common_${PV}.inc
 SUMMARY = "U-Boot bootloader image creation tool"
 DEPENDS = "openssl"
 
-EXTRA_OEMAKE = 'CROSS_COMPILE="${TARGET_PREFIX}" CC="${CC} ${CFLAGS} 
${LDFLAGS}" STRIP=true V=1'
+SRC_URI += " \
+    file://0001-tools-Makefile-improve-cross_tools-target-usability.patch \
+    file://0002-tools-Makefile-add-override-statements-for-cross_too.patch \
+"
+
+EXTRA_OEMAKE = 'CROSS_COMPILE="${TARGET_PREFIX}" CC="${CC}" CFLAGS="${CFLAGS}" 
LDFLAGS="${LDFLAGS}" STRIP=true V=1'
+EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" 
HOSTLDFLAGS="${BUILD_LDFLAGS}"'
 
 do_compile () {
        oe_runmake sandbox_defconfig
-- 
1.9.1

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to