public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] tools/env: fix cross-compilation
@ 2011-12-22 18:39 Grant Erickson
  2012-01-05 23:18 ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Grant Erickson @ 2011-12-22 18:39 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] tools/env: fix cross-compilation
  2011-12-22 18:39 [U-Boot] [PATCH] tools/env: fix cross-compilation Grant Erickson
@ 2012-01-05 23:18 ` Mike Frysinger
  2012-01-05 23:25   ` Grant Erickson
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2012-01-05 23:18 UTC (permalink / raw)
  To: u-boot

On Thursday 22 December 2011 13:39:35 Grant Erickson wrote:
> 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.

how is this any simpler than the existing method ?
	make tools HOSTCC=some-random-target-gcc

the current tools/ subdir is consistent in its handling.  this patch would 
break that.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120105/75abcd3b/attachment.pgp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] tools/env: fix cross-compilation
  2012-01-05 23:18 ` Mike Frysinger
@ 2012-01-05 23:25   ` Grant Erickson
  2012-01-08  6:54     ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Grant Erickson @ 2012-01-05 23:25 UTC (permalink / raw)
  To: u-boot

On Jan 5, 2012, at 3:18 PM, Mike Frysinger wrote:
> On Thursday 22 December 2011 13:39:35 Grant Erickson wrote:
>> 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.
> 
> how is this any simpler than the existing method ?
> 	make tools HOSTCC=some-random-target-gcc
> 
> the current tools/ subdir is consistent in its handling.  this patch would 
> break that.

Mike,

Because it's broken with respect to how the rest of U-Boot is built. I already specify the cross-compiler via CROSS_COMPILE when I build u-boot.bin and u-boot.img, that I need to specify the same compiler in two different ways to build executables for the same target platform is broken and, it sounds like, as are the rest of the tools subdirectories.

If fw_setenv were a build host-based tool or if it made sense as a build host-based tool, then using HOSTCC would be sensible.

Best,

Grant

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] tools/env: fix cross-compilation
  2012-01-05 23:25   ` Grant Erickson
@ 2012-01-08  6:54     ` Mike Frysinger
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2012-01-08  6:54 UTC (permalink / raw)
  To: u-boot

On Thursday 05 January 2012 18:25:52 Grant Erickson wrote:
> On Jan 5, 2012, at 3:18 PM, Mike Frysinger wrote:
> > On Thursday 22 December 2011 13:39:35 Grant Erickson wrote:
> >> 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.
> > 
> > how is this any simpler than the existing method ?
> > 
> > 	make tools HOSTCC=some-random-target-gcc
> > 
> > the current tools/ subdir is consistent in its handling.  this patch
> > would break that.
> 
> Because it's broken with respect to how the rest of U-Boot is built. I
> already specify the cross-compiler via CROSS_COMPILE when I build
> u-boot.bin and u-boot.img, that I need to specify the same compiler in two
> different ways to build executables for the same target platform is broken
> and, it sounds like, as are the rest of the tools subdirectories.

no, you specified the toolchain that is appropriate for building bare metal 
code.  it is often times not the same as the toolchain used to build userspace 
applications for running under Linux.  this is not broken behavior.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120108/ac613bb7/attachment.pgp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-08  6:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-22 18:39 [U-Boot] [PATCH] tools/env: fix cross-compilation Grant Erickson
2012-01-05 23:18 ` Mike Frysinger
2012-01-05 23:25   ` Grant Erickson
2012-01-08  6:54     ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox