diff mbox series

[v3,09/11] rules.mak: Add base-arch() rule

Message ID 20200521195911.19685-10-philmd@redhat.com
State New
Headers show
Series accel: Allow targets to use Kconfig, disable semihosting by default | expand

Commit Message

Philippe Mathieu-Daudé May 21, 2020, 7:59 p.m. UTC
Add a rule to return the base architecture for a QEMU target.

The current list of TARGET_BASE_ARCH is:

  $ git grep  TARGET_BASE_ARCH configure
  configure:7785:TARGET_BASE_ARCH=""
  configure:7795:    TARGET_BASE_ARCH=i386
  configure:7813:    TARGET_BASE_ARCH=arm
  configure:7846:    TARGET_BASE_ARCH=mips
  configure:7854:    TARGET_BASE_ARCH=mips
  configure:7864:    TARGET_BASE_ARCH=openrisc
  configure:7871:    TARGET_BASE_ARCH=ppc
  configure:7879:    TARGET_BASE_ARCH=ppc
  configure:7887:    TARGET_BASE_ARCH=ppc
  configure:7894:    TARGET_BASE_ARCH=riscv
  configure:7900:    TARGET_BASE_ARCH=riscv
  configure:7920:    TARGET_BASE_ARCH=sparc
  configure:7925:    TARGET_BASE_ARCH=sparc

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 rules.mak | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Richard Henderson May 22, 2020, 4:24 a.m. UTC | #1
On 5/21/20 12:59 PM, Philippe Mathieu-Daudé wrote:
> +		$(if $(findstring risc,$1),risc,\

Eh?  riscv{32,64} vs openrisc.

> +		$(if $(findstring x86,$1),i386,\

Do we really not need an exact match for x86_64?

> +		$(if $(findstring aarch64,$1),arm,$1)))))))

Exact match?


r~
Philippe Mathieu-Daudé May 22, 2020, 3:15 p.m. UTC | #2
On 5/22/20 6:24 AM, Richard Henderson wrote:
> On 5/21/20 12:59 PM, Philippe Mathieu-Daudé wrote:
>> +		$(if $(findstring risc,$1),risc,\
> 
> Eh?  riscv{32,64} vs openrisc.

Nice catch, because with this patch openrisc builds with a riscv
config-devices.h =)

> 
>> +		$(if $(findstring x86,$1),i386,\
> 
> Do we really not need an exact match for x86_64?

OK.

> 
>> +		$(if $(findstring aarch64,$1),arm,$1)))))))
> 
> Exact match?

OK.

> 
> 
> r~
>
diff mbox series

Patch

diff --git a/rules.mak b/rules.mak
index 694865b63e..55810d0cd6 100644
--- a/rules.mak
+++ b/rules.mak
@@ -438,3 +438,19 @@  atomic = $(eval $1: $(call sentinel,$1) ; @:) \
 
 print-%:
 	@echo '$*=$($*)'
+
+# base-arch
+# Usage: $(call base-arch, target)
+#
+# @target: the target architecture.
+#
+# This macro will return the base architecture for a target.
+#
+# As example, $(call base-arch, aarch64) returns 'arm'.
+base-arch = $(subst $(SPACE),,\
+		$(if $(findstring mips,$1),mips,\
+		$(if $(findstring ppc,$1),ppc,\
+		$(if $(findstring risc,$1),risc,\
+		$(if $(findstring sparc,$1),sparc,\
+		$(if $(findstring x86,$1),i386,\
+		$(if $(findstring aarch64,$1),arm,$1)))))))