<div class="gmail_quote">On Tue, Jun 28, 2011 at 7:26 PM, Carl-Daniel Hailfinger <span dir="ltr"><<a href="mailto:c-d.hailfinger.devel.2006@gmx.net">c-d.hailfinger.devel.2006@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Autodetect target processor architecture.<br>
Enable architecture dependent compilation of individual sub-drivers for<br>
the internal programmer.<br>
<br>
With this patch, you no longer have to edit the Makefile to compile the<br>
internal driver on MIPS/ARM/...<br>
<br>
TODO: arch.h is not suitable for inclusion in a .c/.h file because of<br>
its last line. Any ideas how to change that (move arch.h as "here<br>
document" into the Makefile, use other trickery like more #ifdefs)?<br>
<br>
Signed-off-by: Carl-Daniel Hailfinger <<a href="mailto:c-d.hailfinger.devel.2006@gmx.net">c-d.hailfinger.devel.2006@gmx.net</a>><br>
<br>
Index: flashrom-target_arch/Makefile<br>
===================================================================<br>
--- flashrom-target_arch/Makefile       (Revision 1357)<br>
+++ flashrom-target_arch/Makefile       (Arbeitskopie)<br>
@@ -37,7 +37,10 @@<br>
 CFLAGS += -Werror<br>
 endif<br>
<br>
-# FIXME We have to differentiate between host and target arch.<br>
+# Determine the destination processor architecture<br>
+ARCH = $(strip $(shell LC_ALL=C gcc -E arch.h|grep -v '^\#'))<br></blockquote><div><br></div><div>Use $(CC) instead of "gcc" so stuff like "armv7a-cros-linux-gnueabi-gcc" gets handled properly. I still think assigning ARCH conditionally is wise since package managers should set it when cross-compiling, though using $(CC) should yield the same result.</div>

<div><br></div><div>Aside from that, I was able to cross-compile successfully for ARM (using the same CONFIG_* settings as before) after adding this minor patch on top of yours:</div><div><br></div><div><div>diff -Nru a/Makefile b/Makefile</div>

<div>--- a/Makefile  2011-06-30 19:35:53.410049173 -0700</div><div>+++ b/Makefile  2011-06-30 19:35:39.140049283 -0700</div><div>@@ -38,7 +38,7 @@</div><div> endif</div><div> </div><div> # Determine the destination processor architecture</div>

<div>-ARCH = $(strip $(shell LC_ALL=C gcc -E arch.h|grep -v '^\#'))</div><div>+ARCH = $(strip $(shell LC_ALL=C $(CC) -E arch.h|grep -v '^\#'))</div><div> </div><div> # FIXME We have to differentiate between host and target OS architecture.</div>

<div> OS_ARCH        ?= $(shell uname)</div><div>@@ -228,6 +228,10 @@</div><div> ifeq ($(ARCH),"x86")</div><div> PROGRAMMER_OBJS += it87spi.o it85spi.o ichspi.o sb600spi.o wbsio_spi.o mcp6x_spi.o</div><div> else</div>

<div>+ifeq ($(ARCH),"arm")</div><div>+PROGRAMMER_OBJS += tegra2_spi.o</div><div>+else</div><div>+endif</div><div> endif</div><div> NEED_PCI := yes</div><div> endif</div><div>diff -Nru a/arch.h b/arch.h</div><div>

--- a/arch.h    2011-06-30 19:35:50.190944388 -0700</div><div>+++ b/arch.h    2011-06-30 19:35:35.280103884 -0700</div><div>@@ -27,5 +27,7 @@</div><div> #define __FLASHROM_ARCH__ "mips"</div><div> #elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__)</div>

<div> #define __FLASHROM_ARCH__ "ppc"</div><div>+#elif defined(__arm__)</div><div>+#define __FLASHROM_ARCH__ "arm"</div><div> #endif</div><div> __FLASHROM_ARCH__</div></div><div><br></div></div>-- <br>

David Hendricks (dhendrix)<br>Systems Software Engineer, Google Inc.<br>