sim: add support for build-time ar & ranlib

Message ID 20210501215350.27401-1-vapier@gentoo.org
State New
Headers show
Series
  • sim: add support for build-time ar & ranlib
Related show

Commit Message

Mike Frysinger via Gdb-patches May 1, 2021, 9:53 p.m.
This is needed when building for a target whose ar & ranlib are
incompatible with the current build system.  For example, building
for Windows on a Linux system.

Then manually import the automake rule for libigen.a, but tweak the
tool variables to use the FOR_BUILD variants.
---
 sim/Makefile.in               | 16 ++++++++++++----
 sim/aarch64/configure         | 12 ++++++++++--
 sim/arm/configure             | 12 ++++++++++--
 sim/avr/configure             | 12 ++++++++++--
 sim/bfin/configure            | 12 ++++++++++--
 sim/bpf/configure             | 12 ++++++++++--
 sim/configure                 |  8 ++++++++
 sim/cr16/configure            | 12 ++++++++++--
 sim/cris/configure            | 12 ++++++++++--
 sim/d10v/configure            | 12 ++++++++++--
 sim/erc32/configure           | 12 ++++++++++--
 sim/example-synacor/configure | 12 ++++++++++--
 sim/frv/configure             | 12 ++++++++++--
 sim/ft32/configure            | 12 ++++++++++--
 sim/h8300/configure           | 12 ++++++++++--
 sim/igen/local.mk             |  6 ++++++
 sim/iq2000/configure          | 12 ++++++++++--
 sim/lm32/configure            | 12 ++++++++++--
 sim/m32c/configure            | 12 ++++++++++--
 sim/m32r/configure            | 12 ++++++++++--
 sim/m4/sim_ac_toolchain.m4    |  6 ++++++
 sim/m68hc11/configure         | 12 ++++++++++--
 sim/mcore/configure           | 12 ++++++++++--
 sim/microblaze/configure      | 12 ++++++++++--
 sim/mips/configure            | 12 ++++++++++--
 sim/mn10300/configure         | 12 ++++++++++--
 sim/moxie/configure           | 12 ++++++++++--
 sim/msp430/configure          | 12 ++++++++++--
 sim/or1k/configure            | 12 ++++++++++--
 sim/pru/configure             | 12 ++++++++++--
 sim/riscv/configure           | 12 ++++++++++--
 sim/rl78/configure            | 12 ++++++++++--
 sim/rx/configure              | 12 ++++++++++--
 sim/sh/configure              | 12 ++++++++++--
 sim/v850/configure            | 12 ++++++++++--
 35 files changed, 342 insertions(+), 66 deletions(-)

-- 
2.31.1

Patch

diff --git a/sim/igen/local.mk b/sim/igen/local.mk
index 10f0f6d227da..f2245727a270 100644
--- a/sim/igen/local.mk
+++ b/sim/igen/local.mk
@@ -48,6 +48,12 @@  noinst_LIBRARIES += %D%/libigen.a
 %C%_igen_SOURCES = %D%/igen.c
 %C%_igen_LDADD = %D%/libigen.a
 
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+igen/libigen.a: $(igen_libigen_a_OBJECTS) $(igen_libigen_a_DEPENDENCIES) $(EXTRA_igen_libigen_a_DEPENDENCIES) igen/$(am__dirstamp)
+	$(AM_V_at)-rm -f $@
+	$(AM_V_AR)$(AR_FOR_BUILD) $(ARFLAGS) $@ $(igen_libigen_a_OBJECTS) $(igen_libigen_a_LIBADD)
+	$(AM_V_at)$(RANLIB_FOR_BUILD) $@
+
 %D%/igen$(EXEEXT): $(%C%_igen_OBJECTS) $(%C%_igen_DEPENDENCIES) %D%/$(am__dirstamp)
 	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_igen_OBJECTS) $(%C%_igen_LDADD)
 
diff --git a/sim/m4/sim_ac_toolchain.m4 b/sim/m4/sim_ac_toolchain.m4
index 9cf702715ef0..2f1a42868ca9 100644
--- a/sim/m4/sim_ac_toolchain.m4
+++ b/sim/m4/sim_ac_toolchain.m4
@@ -26,15 +26,21 @@  AC_PROG_INSTALL
 
 dnl Setup toolchain settings for build-time tools..
 if test "x$cross_compiling" = "xno"; then
+  : "${AR_FOR_BUILD:=\$(AR)}"
   : "${CC_FOR_BUILD:=\$(CC)}"
+  : "${RANLIB_FOR_BUILD:=\$(RANLIB)}"
   : "${CFLAGS_FOR_BUILD:=\$(CFLAGS)}"
   : "${LDFLAGS_FOR_BUILD:=\$(LDFLAGS)}"
 else
+  : "${AR_FOR_BUILD:=ar}"
   : "${CC_FOR_BUILD:=gcc}"
+  : "${RANLIB_FOR_BUILD:=ranlib}"
   : "${CFLAGS_FOR_BUILD:=-g -O}"
   : "${LDLFAGS_FOR_BUILD:=}"
 fi
+AC_SUBST(AR_FOR_BUILD)
 AC_SUBST(CC_FOR_BUILD)
+AC_SUBST(RANLIB_FOR_BUILD)
 AC_SUBST(CFLAGS_FOR_BUILD)
 AC_SUBST(LDFLAGS_FOR_BUILD)