[U-Boot] [PATCH] tools/env: fix cross-compilation

Grant Erickson marathon96 at gmail.com
Thu Dec 22 19:39:35 CET 2011


This patch fixes the make infrastructure for the fw_printenv tool such
that it is built, by default, as a cross-compilation for the target
board when so requested with TOOLSUBDIRS on the U-Boot make command
line.

Signed-off-by: Grant Erickson <marathon96 at gmail.com>
---
 tools/env/Makefile |   18 +++++++++---------
 tools/env/README   |   19 ++++++++++++++-----
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/tools/env/Makefile b/tools/env/Makefile
index 28b73da..705d5e8 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -23,24 +23,24 @@
 
 include $(TOPDIR)/config.mk
 
-HOSTSRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
+SRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
 HEADERS	:= fw_env.h
 
 # Compile for a hosted environment on the target
-HOSTCPPFLAGS  = -idirafter $(SRCTREE)/include \
-		-idirafter $(OBJTREE)/include2 \
-		-idirafter $(OBJTREE)/include \
-		-DUSE_HOSTCC
+CPPFLAGS = -Wall \
+	   -idirafter $(SRCTREE)/include \
+	   -idirafter $(OBJTREE)/include2 \
+	   -idirafter $(OBJTREE)/include \
+	   -DUSE_HOSTCC
 
 ifeq ($(MTD_VERSION),old)
-HOSTCPPFLAGS += -DMTD_OLD
+CPPFLAGS += -DMTD_OLD
 endif
 
 all:	$(obj)fw_printenv
 
-# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
-$(obj)fw_printenv:	$(HOSTSRCS) $(HEADERS)
-	$(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
+$(obj)fw_printenv:	$(SRCS) $(HEADERS)
+	$(CROSS_COMPILE)gcc $(CPPFLAGS) $(SRCS) -o $@
 
 clean:
 	rm -f $(obj)fw_printenv
diff --git a/tools/env/README b/tools/env/README
index 3f0d77e..5b02f7d 100644
--- a/tools/env/README
+++ b/tools/env/README
@@ -2,11 +2,20 @@
 This is a demo implementation of a Linux command line tool to access
 the U-Boot's environment variables.
 
-In the current version, there is an issue in cross-compilation.
-In order to cross-compile fw_printenv, run
-    make HOSTCC=<your CC cross-compiler> env
-in the root directory of the U-Boot distribution. For example,
-    make HOSTCC=arm-linux-gcc env
+To build it for your target board along with U-Boot itself, simply add:
+
+    TOOLSUBDIRS=env
+
+to your make invocation such as:
+
+    make -C u-boot/source \
+    O=$(CURDIR)/u-boot/build \
+    TOOLSUBDIRS=env \
+    all
+
+and you will find, for example:
+
+    $(CURDIR)/u-boot/build/tools/env/fw_printenv
 
 For the run-time utiltity configuration uncomment the line
 #define CONFIG_FILE  "/etc/fw_env.config"
-- 
1.7.7.3



More information about the U-Boot mailing list