Patchwork Autodetect target processor architecture

login
register
about
Submitter David Hendricks
Date 2011-07-01 02:45:37
Message ID <CAKOoyUfs7J6GyivzqVWyDoustNedVcspMMsZ8XdeBVKF5CoLJQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/3241/
State Superseded
Headers show

Comments

David Hendricks - 2011-07-01 02:45:37
On Tue, Jun 28, 2011 at 7:26 PM, Carl-Daniel Hailfinger <
c-d.hailfinger.devel.2006@gmx.net> wrote:

> Autodetect target processor architecture.
> Enable architecture dependent compilation of individual sub-drivers for
> the internal programmer.
>
> With this patch, you no longer have to edit the Makefile to compile the
> internal driver on MIPS/ARM/...
>
> TODO: arch.h is not suitable for inclusion in a .c/.h file because of
> its last line. Any ideas how to change that (move arch.h as "here
> document" into the Makefile, use other trickery like more #ifdefs)?
>
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
>
> Index: flashrom-target_arch/Makefile
> ===================================================================
> --- flashrom-target_arch/Makefile       (Revision 1357)
> +++ flashrom-target_arch/Makefile       (Arbeitskopie)
> @@ -37,7 +37,10 @@
>  CFLAGS += -Werror
>  endif
>
> -# FIXME We have to differentiate between host and target arch.
> +# Determine the destination processor architecture
> +ARCH = $(strip $(shell LC_ALL=C gcc -E arch.h|grep -v '^\#'))
>

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.

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:

 __FLASHROM_ARCH__
Carl-Daniel Hailfinger - 2011-07-01 05:42:57
Am 01.07.2011 04:45 schrieb David Hendricks:
> On Tue, Jun 28, 2011 at 7:26 PM, Carl-Daniel Hailfinger <
> c-d.hailfinger.devel.2006@gmx.net> wrote:
>
>   
>> Autodetect target processor architecture.
>> Enable architecture dependent compilation of individual sub-drivers for
>> the internal programmer.
>>
>> With this patch, you no longer have to edit the Makefile to compile the
>> internal driver on MIPS/ARM/...
>>
>> TODO: arch.h is not suitable for inclusion in a .c/.h file because of
>> its last line. Any ideas how to change that (move arch.h as "here
>> document" into the Makefile, use other trickery like more #ifdefs)?
>>
>> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
>>
>> Index: flashrom-target_arch/Makefile
>> ===================================================================
>> --- flashrom-target_arch/Makefile       (Revision 1357)
>> +++ flashrom-target_arch/Makefile       (Arbeitskopie)
>> @@ -37,7 +37,10 @@
>>  CFLAGS += -Werror
>>  endif
>>
>> -# FIXME We have to differentiate between host and target arch.
>> +# Determine the destination processor architecture
>> +ARCH = $(strip $(shell LC_ALL=C gcc -E arch.h|grep -v '^\#'))
>>
>>     
> Use $(CC) instead of "gcc" so stuff like "armv7a-cros-linux-gnueabi-gcc"
>   

Ouch, yes! This was a cut-n-paste error. Thanks for spotting it.


> 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.
>
> 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:
>
> diff -Nru a/Makefile b/Makefile
> --- a/Makefile  2011-06-30 19:35:53.410049173 -0700
> +++ b/Makefile  2011-06-30 19:35:39.140049283 -0700
> @@ -38,7 +38,7 @@
>  endif
>
>  # Determine the destination processor architecture
> -ARCH = $(strip $(shell LC_ALL=C gcc -E arch.h|grep -v '^\#'))
> +ARCH = $(strip $(shell LC_ALL=C $(CC) -E arch.h|grep -v '^\#'))
>   

Right.


>  # FIXME We have to differentiate between host and target OS architecture.
>  OS_ARCH        ?= $(shell uname)
> @@ -228,6 +228,10 @@
>  ifeq ($(ARCH),"x86")
>  PROGRAMMER_OBJS += it87spi.o it85spi.o ichspi.o sb600spi.o wbsio_spi.o
> mcp6x_spi.o
>  else
> +ifeq ($(ARCH),"arm")
> +PROGRAMMER_OBJS += tegra2_spi.o
> +else
> +endif
>  endif
>  NEED_PCI := yes
>  endif
> diff -Nru a/arch.h b/arch.h
> --- a/arch.h    2011-06-30 19:35:50.190944388 -0700
> +++ b/arch.h    2011-06-30 19:35:35.280103884 -0700
> @@ -27,5 +27,7 @@
>  #define __FLASHROM_ARCH__ "mips"
>  #elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) ||
> defined(__ppc64__)
>  #define __FLASHROM_ARCH__ "ppc"
> +#elif defined(__arm__)
> +#define __FLASHROM_ARCH__ "arm"
>  #endif
>  __FLASHROM_ARCH__
>   

Should I extend my patch to cover ARM as well, or should we perform all
AR related changes in your big ARM suppport patch?

Regards,
Carl-Daniel
David Hendricks - 2011-07-01 17:50:23
On Thu, Jun 30, 2011 at 10:42 PM, Carl-Daniel Hailfinger <
c-d.hailfinger.devel.2006@gmx.net> wrote:

> Should I extend my patch to cover ARM as well, or should we perform all
> AR related changes in your big ARM suppport patch?


I'll add ARM support in the other patches. I only used it here since it's
the only non-x86 platform I have set up for testing at the moment.

Patch

diff -Nru a/Makefile b/Makefile
--- a/Makefile  2011-06-30 19:35:53.410049173 -0700
+++ b/Makefile  2011-06-30 19:35:39.140049283 -0700
@@ -38,7 +38,7 @@ 
 endif

 # Determine the destination processor architecture
-ARCH = $(strip $(shell LC_ALL=C gcc -E arch.h|grep -v '^\#'))
+ARCH = $(strip $(shell LC_ALL=C $(CC) -E arch.h|grep -v '^\#'))

 # FIXME We have to differentiate between host and target OS architecture.
 OS_ARCH        ?= $(shell uname)
@@ -228,6 +228,10 @@ 
 ifeq ($(ARCH),"x86")
 PROGRAMMER_OBJS += it87spi.o it85spi.o ichspi.o sb600spi.o wbsio_spi.o
mcp6x_spi.o
 else
+ifeq ($(ARCH),"arm")
+PROGRAMMER_OBJS += tegra2_spi.o
+else
+endif
 endif
 NEED_PCI := yes
 endif
diff -Nru a/arch.h b/arch.h
--- a/arch.h    2011-06-30 19:35:50.190944388 -0700
+++ b/arch.h    2011-06-30 19:35:35.280103884 -0700
@@ -27,5 +27,7 @@ 
 #define __FLASHROM_ARCH__ "mips"
 #elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) ||
defined(__ppc64__)
 #define __FLASHROM_ARCH__ "ppc"
+#elif defined(__arm__)
+#define __FLASHROM_ARCH__ "arm"
 #endif