public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] sim: hoist gencode & opc2c build rules up to common builds
@ 2021-11-03  3:37 Mike Frysinger
  2021-11-03  3:37 ` [PATCH 2/3] sim: hoist mn10300 & v850 igen " Mike Frysinger
  2021-11-03  3:37 ` [PATCH 3/3] sim: hoist cgen mloop " Mike Frysinger
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Frysinger @ 2021-11-03  3:37 UTC (permalink / raw)
  To: gdb-patches

These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.
---
 sim/Makefile.am         |  16 ++
 sim/Makefile.in         | 387 ++++++++++++++++++++++++++++++++++++++--
 sim/cr16/Makefile.in    |  22 ---
 sim/cr16/local.mk       |  47 +++++
 sim/d10v/Makefile.in    |  19 --
 sim/d10v/local.mk       |  47 +++++
 sim/m32c/Makefile.in    |  23 ---
 sim/m32c/local.mk       |  53 ++++++
 sim/m68hc11/Makefile.in |  17 --
 sim/m68hc11/local.mk    |  44 +++++
 sim/sh/Makefile.in      |  21 ---
 sim/sh/local.mk         |  48 +++++
 12 files changed, 625 insertions(+), 119 deletions(-)
 create mode 100644 sim/cr16/local.mk
 create mode 100644 sim/d10v/local.mk
 create mode 100644 sim/m32c/local.mk
 create mode 100644 sim/m68hc11/local.mk
 create mode 100644 sim/sh/local.mk

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 8f53aa80da75..6fa3b62de224 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -67,4 +67,20 @@ include igen/local.mk
 endif
 include testsuite/local.mk
 
+if SIM_ENABLE_ARCH_cr16
+include cr16/local.mk
+endif
+if SIM_ENABLE_ARCH_d10v
+include d10v/local.mk
+endif
+if SIM_ENABLE_ARCH_m32c
+include m32c/local.mk
+endif
+if SIM_ENABLE_ARCH_m68hc11
+include m68hc11/local.mk
+endif
+if SIM_ENABLE_ARCH_sh
+include sh/local.mk
+endif
+
 all-recursive: $(SIM_ALL_RECURSIVE_DEPS)
diff --git a/sim/cr16/Makefile.in b/sim/cr16/Makefile.in
index 99b2becf792b..4d7345a6b516 100644
--- a/sim/cr16/Makefile.in
+++ b/sim/cr16/Makefile.in
@@ -23,32 +23,10 @@ SIM_OBJS = \
 	interp.o \
 	table.o \
 	simops.o
-SIM_EXTRA_CLEAN = clean-extra
 
 SIM_EXTRA_DEPS = simops.h
 
-INCLUDE = cr16_sim.h $(srcroot)/include/sim/callback.h targ-vals.h \
-	$(srcroot)/include/gdb/sim-cr16.h
-
 # This selects the cr16 newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_cr16
 
 ## COMMON_POST_CONFIG_FRAG
-
-simops.h: gencode
-	$(ECHO_GEN) ./gencode -h >$@
-
-table.c: gencode simops.h
-	$(ECHO_GEN) ./gencode >$@
-
-gencode.o: gencode.c $(INCLUDE)
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/gencode.c
-
-cr16-opc.o: $(srcdir)/../../opcodes/cr16-opc.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/../../opcodes/cr16-opc.c
-
-gencode: gencode.o cr16-opc.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) gencode.o cr16-opc.o
-
-clean-extra:
-	rm -f table.c simops.h gencode
diff --git a/sim/cr16/local.mk b/sim/cr16/local.mk
new file mode 100644
index 000000000000..77866c2b2a31
--- /dev/null
+++ b/sim/cr16/local.mk
@@ -0,0 +1,47 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2008-2021 Free Software Foundation, Inc.
+# Contributed by M Ranga Swami Reddy <MR.Swami.Reddy@nsc.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/simops.h \
+	%D%/table.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+%C%_gencode_LDADD = %D%/cr16-opc.o
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+%D%/cr16-opc.o: ../opcodes/cr16-opc.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/simops.h: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -h >$@
+
+%D%/table.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/d10v/Makefile.in b/sim/d10v/Makefile.in
index 4f8759b3deac..51fb9eb72d1a 100644
--- a/sim/d10v/Makefile.in
+++ b/sim/d10v/Makefile.in
@@ -24,7 +24,6 @@ SIM_OBJS = \
 	table.o \
 	simops.o \
 	endian.o
-SIM_EXTRA_CLEAN = clean-extra
 
 SIM_EXTRA_DEPS = simops.h
 
@@ -35,21 +34,3 @@ INCLUDE = d10v_sim.h $(srcroot)/include/sim/callback.h targ-vals.h endian.c \
 NL_TARGET = -DNL_TARGET_d10v
 
 ## COMMON_POST_CONFIG_FRAG
-
-simops.h: gencode
-	$(ECHO_GEN) ./gencode -h >$@
-
-table.c: gencode simops.h
-	$(ECHO_GEN) ./gencode >$@
-
-gencode.o: gencode.c $(INCLUDE)
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/gencode.c
-
-d10v-opc.o: $(srcdir)/../../opcodes/d10v-opc.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/../../opcodes/d10v-opc.c
-
-gencode: gencode.o d10v-opc.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) gencode.o d10v-opc.o
-
-clean-extra:
-	rm -f table.c simops.h gencode
diff --git a/sim/d10v/local.mk b/sim/d10v/local.mk
new file mode 100644
index 000000000000..1f19eab8ded1
--- /dev/null
+++ b/sim/d10v/local.mk
@@ -0,0 +1,47 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/simops.h \
+	%D%/table.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+%C%_gencode_LDADD = %D%/d10v-opc.o
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+%D%/d10v-opc.o: ../opcodes/d10v-opc.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/simops.h: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -h >$@
+
+%D%/table.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/m32c/Makefile.in b/sim/m32c/Makefile.in
index cfdadd041048..c5b1495c7059 100644
--- a/sim/m32c/Makefile.in
+++ b/sim/m32c/Makefile.in
@@ -41,26 +41,3 @@ SIM_OBJS = \
 	$(ENDLIST)
 
 ## COMMON_POST_CONFIG_FRAG
-
-arch = m32c
-
-# opc2c leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
-# leak detection while running it.
-OPC2C = ASAN_OPTIONS=detect_leaks=0 ./opc2c
-
-r8c.c : r8c.opc opc2c
-	$(ECHO_GEN) $(OPC2C) -l r8c.out $(srcdir)/r8c.opc > r8c.c.tmp
-	$(SILENCE) mv r8c.c.tmp r8c.c
-
-m32c.c : m32c.opc opc2c
-	$(ECHO_GEN) $(OPC2C) -l m32c.out $(srcdir)/m32c.opc > m32c.c.tmp
-	$(SILENCE) mv m32c.c.tmp m32c.c
-
-opc2c : opc2c.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) $^
-
-encodings:
-	grep '/\* [01]' $(srcdir)/r8c.opc | sort
-
-opc2c.o : opc2c.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/opc2c.c
diff --git a/sim/m32c/local.mk b/sim/m32c/local.mk
new file mode 100644
index 000000000000..f1e86e6304b0
--- /dev/null
+++ b/sim/m32c/local.mk
@@ -0,0 +1,53 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2005-2021 Free Software Foundation, Inc.
+# Contributed by Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/opc2c$(EXEEXT) \
+	%D%/m32c.c \
+	%D%/r8c.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_opc2c_SOURCES = %D%/opc2c.c
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/opc2c$(EXEEXT): $(%C%_opc2c_OBJECTS) $(%C%_opc2c_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_opc2c_OBJECTS) $(%C%_opc2c_LDADD)
+
+# opc2c is a build-time only tool.  Override the default rules for it.
+%D%/opc2c.o: %D%/opc2c.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+# opc2c leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
+# leak detection while running it.
+%C%_OPC2C_RUN = ASAN_OPTIONS=detect_leaks=0 %D%/opc2c$(EXEEXT)
+
+%D%/m32c.c: %D%/m32c.opc %D%/opc2c$(EXEEXT)
+	$(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp
+	$(AM_V_at)mv $@.tmp $@
+
+%D%/r8c.c: %D%/r8c.opc %D%/opc2c$(EXEEXT)
+	$(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp
+	$(AM_V_at)mv $@.tmp $@
+
+EXTRA_PROGRAMS += %D%/opc2c
+MOSTLYCLEANFILES += \
+	$(%C%_BUILD_OUTPUTS) \
+	%D%/m32c.c.log \
+	%D%/r8c.c.log
diff --git a/sim/m68hc11/Makefile.in b/sim/m68hc11/Makefile.in
index f906a7c2bb67..0b2c4f1ea6b2 100644
--- a/sim/m68hc11/Makefile.in
+++ b/sim/m68hc11/Makefile.in
@@ -36,22 +36,5 @@ SIM_EXTRA_CFLAGS = -DWITH_TARGET_WORD_BITSIZE=32 \
 		   -DWITH_TARGET_CELL_BITSIZE=32 \
 		   -DWITH_TARGET_ADDRESS_BITSIZE=32 \
 		   -DWITH_TARGET_WORD_MSB=31
-SIM_EXTRA_CLEAN = clean-extra
-
 
 ## COMMON_POST_CONFIG_FRAG
-
-m68hc11int.c: gencode
-	$(ECHO_GEN) ./gencode -m6811 > $@
-
-m68hc12int.c: gencode
-	$(ECHO_GEN) ./gencode -m6812 > $@
-
-gencode.o: gencode.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $< -o $@
-
-gencode: gencode.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) $^
-
-clean-extra:
-	rm -f gencode m68hc11int.c
diff --git a/sim/m68hc11/local.mk b/sim/m68hc11/local.mk
new file mode 100644
index 000000000000..7596e1466080
--- /dev/null
+++ b/sim/m68hc11/local.mk
@@ -0,0 +1,44 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/m68hc11int.c \
+	%D%/m68hc12int.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/m68hc11int.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -m6811 >$@
+
+%D%/m68hc12int.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -m6812 >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index e79efd1ff5e2..4c5b9ad9a0af 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -25,30 +25,9 @@ SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
 	table.o
 SIM_EXTRA_LIBS = -lm
-SIM_EXTRA_CLEAN = sh-clean
 SIM_EXTRA_DEPS = table.c code.c ppi.c
 
 # Some modules don't build cleanly yet.
 interp.o: SIM_WERROR_CFLAGS =
 
 ## COMMON_POST_CONFIG_FRAG
-
-code.c: gencode
-	$(ECHO_GEN) ./gencode -x >code.c
-#	indent code.c
-
-table.c: gencode
-	$(ECHO_GEN) ./gencode -s >table.c
-#	indent table.c
-
-ppi.c: gencode
-	$(ECHO_GEN) ./gencode -p >ppi.c
-
-gencode.o: gencode.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $< -o $@
-
-gencode: gencode.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) $^
-
-sh-clean:
-	rm -f gencode code.c table.c
diff --git a/sim/sh/local.mk b/sim/sh/local.mk
new file mode 100644
index 000000000000..583899c33944
--- /dev/null
+++ b/sim/sh/local.mk
@@ -0,0 +1,48 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1990-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/code.c \
+	%D%/ppi.c \
+	%D%/table.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/code.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -x >$@
+
+%D%/ppi.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -p >$@
+
+%D%/table.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -s >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
-- 
2.33.0


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

* [PATCH 2/3] sim: hoist mn10300 & v850 igen rules up to common builds
  2021-11-03  3:37 [PATCH 1/3] sim: hoist gencode & opc2c build rules up to common builds Mike Frysinger
@ 2021-11-03  3:37 ` Mike Frysinger
  2021-11-03  3:37 ` [PATCH 3/3] sim: hoist cgen mloop " Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2021-11-03  3:37 UTC (permalink / raw)
  To: gdb-patches

These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.

We leave the mips rules in place as they depend on complicated
arch-specific configure logic that needs to be untangled first.
---
 sim/Makefile.am         |   6 ++
 sim/Makefile.in         | 207 +++++++++++++++++++++++++++++++++++++---
 sim/igen/local.mk       |  11 ++-
 sim/mn10300/Makefile.in |  71 --------------
 sim/mn10300/local.mk    |  90 +++++++++++++++++
 sim/v850/Makefile.in    |  67 -------------
 sim/v850/local.mk       |  87 +++++++++++++++++
 7 files changed, 386 insertions(+), 153 deletions(-)
 create mode 100644 sim/mn10300/local.mk
 create mode 100644 sim/v850/local.mk

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 6fa3b62de224..c04f94817e4f 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -79,8 +79,14 @@ endif
 if SIM_ENABLE_ARCH_m68hc11
 include m68hc11/local.mk
 endif
+if SIM_ENABLE_ARCH_mn10300
+include mn10300/local.mk
+endif
 if SIM_ENABLE_ARCH_sh
 include sh/local.mk
 endif
+if SIM_ENABLE_ARCH_v850
+include v850/local.mk
+endif
 
 all-recursive: $(SIM_ALL_RECURSIVE_DEPS)
diff --git a/sim/igen/local.mk b/sim/igen/local.mk
index a7e278661b7b..3e3219cdfa91 100644
--- a/sim/igen/local.mk
+++ b/sim/igen/local.mk
@@ -19,12 +19,17 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+# igen leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
+# leak detection while running it.
+IGEN = %D%/igen$(EXEEXT)
+IGEN_RUN = ASAN_OPTIONS=detect_leaks=0 $(IGEN)
+
 # This makes sure igen is available before building the arch-subdirs which
 # need to run the igen tool.
-SIM_ALL_RECURSIVE_DEPS += igen/igen$(EXEEXT)
+SIM_ALL_RECURSIVE_DEPS += $(IGEN)
 
 # Alias for developers.
-igen: %D%/igen$(EXEEXT)
+igen: $(IGEN)
 
 noinst_LIBRARIES += %D%/libigen.a
 %C%_libigen_a_SOURCES = \
@@ -84,7 +89,7 @@ igen/libigen.a: $(igen_libigen_a_OBJECTS) $(igen_libigen_a_DEPENDENCIES) $(EXTRA
 %C%_table_LDADD = %D%/table-main.o %D%/libigen.a
 
 %C%_IGEN_TOOLS = \
-	%D%/igen \
+	$(IGEN) \
 	%D%/filter \
 	%D%/gen \
 	%D%/ld-cache \
diff --git a/sim/mn10300/Makefile.in b/sim/mn10300/Makefile.in
index a68dd43f1a69..e9df3ef46407 100644
--- a/sim/mn10300/Makefile.in
+++ b/sim/mn10300/Makefile.in
@@ -27,7 +27,6 @@ SIM_OBJS = $(MN10300_OBJS) interp.o
 
 SIM_EXTRA_HW_DEVICES = mn103cpu mn103int mn103tim mn103ser mn103iop
 
-SIM_EXTRA_CLEAN = clean-igen
 # Extra dependencies for "sim-main.h"
 SIM_EXTRA_DEPS = mn10300_sim.h itable.h idecode.h
 
@@ -35,73 +34,3 @@ SIM_EXTRA_DEPS = mn10300_sim.h itable.h idecode.h
 SIM_EXTRA_CFLAGS = -DPOLL_QUIT_INTERVAL=0x20
 
 ## COMMON_POST_CONFIG_FRAG
-
-BUILT_SRC_FROM_IGEN = \
-	icache.h \
-	icache.c \
-	idecode.h \
-	idecode.c \
-	semantics.h \
-	semantics.c \
-	model.h \
-	model.c \
-	support.h \
-	support.c \
-	itable.h \
-	itable.c \
-	engine.h \
-	engine.c \
-	irun.c
-$(BUILT_SRC_FROM_IGEN): tmp-igen
-
-
-.PHONY: clean-igen
-clean-igen:
-	rm -f $(BUILT_SRC_FROM_IGEN)
-	rm -f tmp-igen tmp-insns
-
-IGEN_TRACE= # -G omit-line-numbers # -G trace-rule-selection -G trace-rule-rejection -G trace-entries
-IGEN_INSN=$(srcdir)/mn10300.igen
-IGEN_INSN_INC=$(srcdir)/am33.igen $(srcdir)/am33-2.igen
-IGEN_DC=$(srcdir)/mn10300.dc
-tmp-igen: $(IGEN_INSN) $(IGEN_INSN_INC) $(IGEN_DC) $(IGEN)
-	$(ECHO_IGEN) $(IGEN_RUN) \
-		$(IGEN_TRACE) \
-		-G gen-direct-access \
-                -M mn10300,am33 -G gen-multi-sim=am33 \
-		-M am33_2 \
-		-I $(srcdir) \
-		-i $(IGEN_INSN) \
-		-o $(IGEN_DC) \
-		-x \
-		-n icache.h    -hc tmp-icache.h \
-		-n icache.c    -c  tmp-icache.c \
-		-n semantics.h -hs tmp-semantics.h \
-		-n semantics.c -s  tmp-semantics.c \
-		-n idecode.h   -hd tmp-idecode.h \
-		-n idecode.c   -d  tmp-idecode.c \
-		-n model.h     -hm tmp-model.h \
-		-n model.c     -m  tmp-model.c \
-		-n support.h   -hf tmp-support.h \
-		-n support.c   -f  tmp-support.c \
-		-n itable.h    -ht tmp-itable.h \
-		-n itable.c    -t  tmp-itable.c \
-		-n engine.h    -he tmp-engine.h \
-		-n engine.c    -e  tmp-engine.c \
-		-n irun.c      -r  tmp-irun.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-icache.h icache.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-icache.c icache.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-idecode.h idecode.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-idecode.c idecode.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-semantics.h semantics.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-semantics.c semantics.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-model.h model.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-model.c model.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-support.h support.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-support.c support.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-itable.h itable.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-itable.c itable.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-engine.h engine.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-engine.c engine.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-irun.c irun.c
-	$(SILENCE) touch $@
diff --git a/sim/mn10300/local.mk b/sim/mn10300/local.mk
new file mode 100644
index 000000000000..6c70ffe27b11
--- /dev/null
+++ b/sim/mn10300/local.mk
@@ -0,0 +1,90 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILT_SRC_FROM_IGEN = \
+	%D%/icache.h \
+	%D%/icache.c \
+	%D%/idecode.h \
+	%D%/idecode.c \
+	%D%/semantics.h \
+	%D%/semantics.c \
+	%D%/model.h \
+	%D%/model.c \
+	%D%/support.h \
+	%D%/support.c \
+	%D%/itable.h \
+	%D%/itable.c \
+	%D%/engine.h \
+	%D%/engine.c \
+	%D%/irun.c
+%C%_BUILD_OUTPUTS = \
+	$(%C%_BUILT_SRC_FROM_IGEN) \
+	%D%/stamp-igen
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+$(%C%_BUILT_SRC_FROM_IGEN): %D%/stamp-igen
+
+%C%_IGEN_TRACE = # -G omit-line-numbers # -G trace-rule-selection -G trace-rule-rejection -G trace-entries
+%C%_IGEN_INSN = $(srcdir)/%D%/mn10300.igen
+%C%_IGEN_INSN_INC = %D%/am33.igen %D%/am33-2.igen
+%C%_IGEN_DC = $(srcdir)/%D%/mn10300.dc
+%D%/stamp-igen: $(%C%_IGEN_INSN) $(%C%_IGEN_INSN_INC) $(%C%_IGEN_DC) $(IGEN)
+	$(AM_V_GEN)$(IGEN_RUN) \
+		$(%C%_IGEN_TRACE) \
+		-G gen-direct-access \
+		-M mn10300,am33 -G gen-multi-sim=am33 \
+		-M am33_2 \
+		-I $(srcdir)/%D% \
+		-i $(%C%_IGEN_INSN) \
+		-o $(%C%_IGEN_DC) \
+		-x \
+		-n icache.h    -hc %D%/tmp-icache.h \
+		-n icache.c    -c  %D%/tmp-icache.c \
+		-n semantics.h -hs %D%/tmp-semantics.h \
+		-n semantics.c -s  %D%/tmp-semantics.c \
+		-n idecode.h   -hd %D%/tmp-idecode.h \
+		-n idecode.c   -d  %D%/tmp-idecode.c \
+		-n model.h     -hm %D%/tmp-model.h \
+		-n model.c     -m  %D%/tmp-model.c \
+		-n support.h   -hf %D%/tmp-support.h \
+		-n support.c   -f  %D%/tmp-support.c \
+		-n itable.h    -ht %D%/tmp-itable.h \
+		-n itable.c    -t  %D%/tmp-itable.c \
+		-n engine.h    -he %D%/tmp-engine.h \
+		-n engine.c    -e  %D%/tmp-engine.c \
+		-n irun.c      -r  %D%/tmp-irun.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-icache.h %D%/icache.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-icache.c %D%/icache.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-idecode.h %D%/idecode.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-idecode.c %D%/idecode.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-semantics.h %D%/semantics.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-semantics.c %D%/semantics.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-model.h %D%/model.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-model.c %D%/model.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-support.h %D%/support.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-support.c %D%/support.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-itable.h %D%/itable.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-itable.c %D%/itable.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-engine.h %D%/engine.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-engine.c %D%/engine.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-irun.c %D%/irun.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/v850/Makefile.in b/sim/v850/Makefile.in
index 072c75027885..07014b8afb8c 100644
--- a/sim/v850/Makefile.in
+++ b/sim/v850/Makefile.in
@@ -34,70 +34,3 @@ SIM_EXTRA_CFLAGS = \
 NL_TARGET = -DNL_TARGET_v850
 
 ## COMMON_POST_CONFIG_FRAG
-
-BUILT_SRC_FROM_IGEN = \
-	icache.h \
-	icache.c \
-	idecode.h \
-	idecode.c \
-	semantics.h \
-	semantics.c \
-	model.h \
-	model.c \
-	support.h \
-	support.c \
-	itable.h \
-	itable.c \
-	engine.h \
-	engine.c \
-	irun.c
-$(BUILT_SRC_FROM_IGEN): tmp-igen
-#
-
-.PHONY: clean-igen
-clean-igen:
-	rm -f $(BUILT_SRC_FROM_IGEN)
-	rm -f tmp-igen tmp-insns
-
-IGEN_TRACE= # -G omit-line-numbers # -G trace-rule-selection -G trace-rule-rejection -G trace-entries
-IGEN_INSN=$(srcdir)/v850.igen
-IGEN_DC=$(srcdir)/v850-dc
-tmp-igen: $(IGEN_INSN) $(IGEN_DC) $(IGEN)
-	$(ECHO_IGEN) $(IGEN_RUN) \
-		$(IGEN_TRACE) \
-		-G gen-direct-access \
-		-G gen-zero-r0 \
-		-i $(IGEN_INSN) \
-		-o $(IGEN_DC) \
-		-x \
-		-n icache.h    -hc tmp-icache.h \
-		-n icache.c    -c  tmp-icache.c \
-		-n semantics.h -hs tmp-semantics.h \
-		-n semantics.c -s  tmp-semantics.c \
-		-n idecode.h   -hd tmp-idecode.h \
-		-n idecode.c   -d  tmp-idecode.c \
-		-n model.h     -hm tmp-model.h \
-		-n model.c     -m  tmp-model.c \
-		-n support.h   -hf tmp-support.h \
-		-n support.c   -f  tmp-support.c \
-		-n itable.h    -ht tmp-itable.h \
-		-n itable.c    -t  tmp-itable.c \
-		-n engine.h    -he tmp-engine.h \
-		-n engine.c    -e  tmp-engine.c \
-		-n irun.c      -r  tmp-irun.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-icache.h icache.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-icache.c icache.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-idecode.h idecode.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-idecode.c idecode.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-semantics.h semantics.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-semantics.c semantics.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-model.h model.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-model.c model.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-support.h support.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-support.c support.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-itable.h itable.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-itable.c itable.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-engine.h engine.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-engine.c engine.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-irun.c irun.c
-	$(SILENCE) touch $@
diff --git a/sim/v850/local.mk b/sim/v850/local.mk
new file mode 100644
index 000000000000..17adeabbf2fc
--- /dev/null
+++ b/sim/v850/local.mk
@@ -0,0 +1,87 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILT_SRC_FROM_IGEN = \
+	%D%/icache.h \
+	%D%/icache.c \
+	%D%/idecode.h \
+	%D%/idecode.c \
+	%D%/semantics.h \
+	%D%/semantics.c \
+	%D%/model.h \
+	%D%/model.c \
+	%D%/support.h \
+	%D%/support.c \
+	%D%/itable.h \
+	%D%/itable.c \
+	%D%/engine.h \
+	%D%/engine.c \
+	%D%/irun.c
+%C%_BUILD_OUTPUTS = \
+	$(%C%_BUILT_SRC_FROM_IGEN) \
+	%D%/stamp-igen
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+$(%C%_BUILT_SRC_FROM_IGEN): %D%/stamp-igen
+
+%C%_IGEN_TRACE = # -G omit-line-numbers # -G trace-rule-selection -G trace-rule-rejection -G trace-entries
+%C%_IGEN_INSN = $(srcdir)/%D%/v850.igen
+%C%_IGEN_DC = $(srcdir)/%D%/v850-dc
+%D%/stamp-igen: $(%C%_IGEN_INSN) $(%C%_IGEN_DC) $(IGEN)
+	$(AM_V_GEN)$(IGEN_RUN) \
+		$(%C%_IGEN_TRACE) \
+		-G gen-direct-access \
+		-G gen-zero-r0 \
+		-i $(%C%_IGEN_INSN) \
+		-o $(%C%_IGEN_DC) \
+		-x \
+		-n icache.h    -hc %D%/tmp-icache.h \
+		-n icache.c    -c  %D%/tmp-icache.c \
+		-n semantics.h -hs %D%/tmp-semantics.h \
+		-n semantics.c -s  %D%/tmp-semantics.c \
+		-n idecode.h   -hd %D%/tmp-idecode.h \
+		-n idecode.c   -d  %D%/tmp-idecode.c \
+		-n model.h     -hm %D%/tmp-model.h \
+		-n model.c     -m  %D%/tmp-model.c \
+		-n support.h   -hf %D%/tmp-support.h \
+		-n support.c   -f  %D%/tmp-support.c \
+		-n itable.h    -ht %D%/tmp-itable.h \
+		-n itable.c    -t  %D%/tmp-itable.c \
+		-n engine.h    -he %D%/tmp-engine.h \
+		-n engine.c    -e  %D%/tmp-engine.c \
+		-n irun.c      -r  %D%/tmp-irun.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-icache.h %D%/icache.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-icache.c %D%/icache.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-idecode.h %D%/idecode.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-idecode.c %D%/idecode.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-semantics.h %D%/semantics.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-semantics.c %D%/semantics.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-model.h %D%/model.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-model.c %D%/model.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-support.h %D%/support.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-support.c %D%/support.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-itable.h %D%/itable.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-itable.c %D%/itable.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-engine.h %D%/engine.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-engine.c %D%/engine.c
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/tmp-irun.c %D%/irun.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
-- 
2.33.0


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

* [PATCH 3/3] sim: hoist cgen mloop rules up to common builds
  2021-11-03  3:37 [PATCH 1/3] sim: hoist gencode & opc2c build rules up to common builds Mike Frysinger
  2021-11-03  3:37 ` [PATCH 2/3] sim: hoist mn10300 & v850 igen " Mike Frysinger
@ 2021-11-03  3:37 ` Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2021-11-03  3:37 UTC (permalink / raw)
  To: gdb-patches

These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.

We have to extend the genmloop.sh logic a bit to allow outputting
to a subdir since it always assumed cwd was the right place.

We leave the cgen maintainer rules in the subdirs for now as they
aren't normally run, and they rely on cgen logic that has not yet
been generalized.
---
 sim/Makefile.am        |  24 ++-
 sim/Makefile.in        | 379 ++++++++++++++++++++++++++++++++++++++---
 sim/bpf/Makefile.in    |  28 +--
 sim/bpf/local.mk       |  49 ++++++
 sim/common/genmloop.sh |  15 +-
 sim/cris/Makefile.in   |  32 +---
 sim/cris/local.mk      |  54 ++++++
 sim/frv/Makefile.in    |  12 --
 sim/frv/local.mk       |  38 +++++
 sim/iq2000/Makefile.in |  12 --
 sim/iq2000/local.mk    |  38 +++++
 sim/lm32/Makefile.in   |  12 --
 sim/lm32/local.mk      |  38 +++++
 sim/m32r/Makefile.in   |  56 ------
 sim/m32r/local.mk      |  66 +++++++
 sim/or1k/Makefile.in   |  16 +-
 sim/or1k/local.mk      |  37 ++++
 17 files changed, 707 insertions(+), 199 deletions(-)
 create mode 100644 sim/bpf/local.mk
 create mode 100644 sim/cris/local.mk
 create mode 100644 sim/frv/local.mk
 create mode 100644 sim/iq2000/local.mk
 create mode 100644 sim/lm32/local.mk
 create mode 100644 sim/m32r/local.mk
 create mode 100644 sim/or1k/local.mk

diff --git a/sim/Makefile.am b/sim/Makefile.am
index c04f94817e4f..fd4b76877434 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -18,6 +18,7 @@
 AUTOMAKE_OPTIONS = dejagnu foreign no-dist subdir-objects
 ACLOCAL_AMFLAGS = -Im4 -I.. -I../config
 
+srccom = $(srcdir)/common
 srcroot = $(srcdir)/..
 
 SUBDIRS = @subdirs@ $(SIM_SUBDIRS)
@@ -55,7 +56,7 @@ SIM_ALL_RECURSIVE_DEPS =
 # An alternative is to slurp in the tables at runtime.
 .PHONY: nltvals
 nltvals:
-	$(srcdir)/common/gennltvals.py --cpp "$(CPP)"
+	$(srccom)/gennltvals.py --cpp "$(CPP)"
 
 pkginclude_HEADERS = \
 	$(srcroot)/include/sim/callback.h \
@@ -67,21 +68,42 @@ include igen/local.mk
 endif
 include testsuite/local.mk
 
+if SIM_ENABLE_ARCH_bpf
+include bpf/local.mk
+endif
 if SIM_ENABLE_ARCH_cr16
 include cr16/local.mk
 endif
+if SIM_ENABLE_ARCH_cris
+include cris/local.mk
+endif
 if SIM_ENABLE_ARCH_d10v
 include d10v/local.mk
 endif
+if SIM_ENABLE_ARCH_frv
+include frv/local.mk
+endif
+if SIM_ENABLE_ARCH_iq2000
+include iq2000/local.mk
+endif
+if SIM_ENABLE_ARCH_lm32
+include lm32/local.mk
+endif
 if SIM_ENABLE_ARCH_m32c
 include m32c/local.mk
 endif
+if SIM_ENABLE_ARCH_m32r
+include m32r/local.mk
+endif
 if SIM_ENABLE_ARCH_m68hc11
 include m68hc11/local.mk
 endif
 if SIM_ENABLE_ARCH_mn10300
 include mn10300/local.mk
 endif
+if SIM_ENABLE_ARCH_or1k
+include or1k/local.mk
+endif
 if SIM_ENABLE_ARCH_sh
 include sh/local.mk
 endif
diff --git a/sim/bpf/Makefile.in b/sim/bpf/Makefile.in
index 05a246e670ac..b12c18d6520b 100644
--- a/sim/bpf/Makefile.in
+++ b/sim/bpf/Makefile.in
@@ -161,33 +161,7 @@ $(srcdir)/sem-be.c $(srcdir)/decode-be.c $(srcdir)/decode-be.h: \
               $(CGEN_MAINT) stamp-decode-be
 	@true
 
-# Note the following files are generated in objdir, not srcdir.
-
-stamp-mloop: stamp-mloop-le stamp-mloop-be
-
-stamp-mloop-le: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloop-le.c eng-le.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -scache -prefix bpfbf_ebpfle -cpu bpfbf \
-                -infile $(srcdir)/mloop.in -outfile-suffix -le
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng-le.hin eng-le.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop-le.cin mloop-le.c
-	$(SILENCE) touch $@
-mloop-le.c eng-le.h: stamp-mloop-le
-	@true
-
-stamp-mloop-be: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloop-be.c eng-be.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -scache -prefix bpfbf_ebpfbe -cpu bpfbf \
-                -infile $(srcdir)/mloop.in -outfile-suffix -be
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng-be.hin eng-be.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop-be.cin mloop-be.c
-	$(SILENCE) touch $@
-mloop-be.c eng-be.h: stamp-mloop-be
-	@true
-
 .PHONY = bpf-clean
 
 bpf-clean:
-	rm -f stamp-arch stamp-cpu stamp-decode stamp-defs stamp-mloop
+	rm -f stamp-arch stamp-cpu stamp-decode stamp-defs
diff --git a/sim/bpf/local.mk b/sim/bpf/local.mk
new file mode 100644
index 000000000000..ebca133d392a
--- /dev/null
+++ b/sim/bpf/local.mk
@@ -0,0 +1,49 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2020-2021 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/eng-le.h \
+	%D%/mloop-le.c \
+	%D%/stamp-mloop-le \
+	%D%/eng-be.h \
+	%D%/mloop-be.c \
+	%D%/stamp-mloop-be
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%D%/mloop-le.c %D%/eng-le.h: %D%/stamp-mloop-le ; @true
+%D%/stamp-mloop-le: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -scache -prefix bpfbf_ebpfle -cpu bpfbf \
+		-infile $(srcdir)/%D%/mloop.in \
+		-outfile-prefix %D%/ -outfile-suffix -le
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-le.hin %D%/eng-le.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-le.cin %D%/mloop-le.c
+	$(AM_V_at)touch $@
+
+%D%/mloop-be.c %D%/eng-be.h: %D%/stamp-mloop-be ; @true
+%D%/stamp-mloop-be: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -scache -prefix bpfbf_ebpfbe -cpu bpfbf \
+		-infile $(srcdir)/%D%/mloop.in \
+		-outfile-prefix %D%/ -outfile-suffix -be
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-be.hin %D%/eng-be.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-be.cin %D%/mloop-be.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/common/genmloop.sh b/sim/common/genmloop.sh
index fa4e7b90a516..572dc8a9ed4b 100755
--- a/sim/common/genmloop.sh
+++ b/sim/common/genmloop.sh
@@ -140,6 +140,7 @@ switch=
 cpu="unknown"
 infile=""
 prefix="unknown"
+outprefix=""
 outsuffix=""
 
 while test $# -gt 0
@@ -154,6 +155,7 @@ do
 	-scache) scache=yes ;;
 	-pbb) pbb=yes ;;
 	-no-parallel) ;;
+	-outfile-prefix) shift ; outprefix=$1 ;;
 	-outfile-suffix) shift ; outsuffix=$1 ;;
 	-parallel-read) parallel=read ;;
 	-parallel-write) parallel=write ;;
@@ -197,8 +199,8 @@ PREFIX=`echo ${prefix} | tr "${lowercase}" "${uppercase}"`
 
 ##########################################################################
 
-rm -f eng${outsuffix}.hin
-exec 1>eng${outsuffix}.hin
+rm -f ${outprefix}eng${outsuffix}.hin
+exec 1>${outprefix}eng${outsuffix}.hin
 
 echo "/* engine configuration for ${cpu} */"
 echo ""
@@ -291,8 +293,8 @@ fi
 
 ##########################################################################
 
-rm -f tmp-mloop-$$.cin mloop${outsuffix}.cin
-exec 1>tmp-mloop-$$.cin
+rm -f ${outprefix}tmp-mloop-$$.cin ${outprefix}mloop${outsuffix}.cin
+exec 1>${outprefix}tmp-mloop-$$.cin
 
 # We use @cpu@ instead of ${cpu} because we still need to run sed to handle
 # transformation of @cpu@ for mainloop.in, so there's no need to use ${cpu}
@@ -1334,8 +1336,9 @@ fi # -pbb
 # Expand @..@ macros appearing in tmp-mloop-{pid}.cin.
 sed \
   -e "s/@cpu@/$cpu/g" -e "s/@CPU@/$CPU/g" \
-  -e "s/@prefix@/$prefix/g" -e "s/@PREFIX@/$PREFIX/g" < tmp-mloop-$$.cin > mloop${outsuffix}.cin
+  -e "s/@prefix@/$prefix/g" -e "s/@PREFIX@/$PREFIX/g" \
+  < ${outprefix}tmp-mloop-$$.cin > ${outprefix}mloop${outsuffix}.cin
 rc=$?
-rm -f tmp-mloop-$$.cin
+rm -f ${outprefix}tmp-mloop-$$.cin
 
 exit $rc
diff --git a/sim/cris/Makefile.in b/sim/cris/Makefile.in
index 18dd2f451b55..8e6bb2ec79bd 100644
--- a/sim/cris/Makefile.in
+++ b/sim/cris/Makefile.in
@@ -66,48 +66,18 @@ CRISV10F_INCLUDE_DEPS = \
 	$(CGEN_MAIN_CPU_DEPS) \
 	cpuv10.h decodev10.h engv10.h
 
-# FIXME: What is mono and what does "Use of `mono' is wip" mean (other
-# than the apparent; some "mono" feature is work in progress)?
-mloopv10f.c engv10.h: stamp-v10fmloop
-stamp-v10fmloop: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloopv10f.c engv10.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -no-fast -pbb -switch semcrisv10f-switch.c \
-		-cpu crisv10f -infile $(srcdir)/mloop.in
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng.hin engv10.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop.cin mloopv10f.c
-	$(SILENCE) touch $@
-
 # CRISV32 objs
 
 CRISV32F_INCLUDE_DEPS = \
 	$(CGEN_MAIN_CPU_DEPS) \
 	cpuv32.h decodev32.h engv32.h
 
-# FIXME: What is mono and what does "Use of `mono' is wip" mean (other
-# than the apparent; some "mono" feature is work in progress)?
-mloopv32f.c engv32.h: stamp-v32fmloop
-# We depend on stamp-v10fmloop to get serialization to avoid
-# racing with it for the same temporary file-names when "make -j".
-stamp-v32fmloop: stamp-v10fmloop $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloopv32f.c engv32.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -no-fast -pbb -switch semcrisv32f-switch.c \
-		-cpu crisv32f -infile $(srcdir)/mloop.in
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng.hin engv32.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop.cin mloopv32f.c
-	$(SILENCE) touch $@
-
 cris-clean:
-	for v in 10 32; do \
-	  rm -f mloopv$${v}f.c engv$${v}.h stamp-v$${v}fmloop; \
-	  rm -f stamp-v$${v}fcpu; \
-	done
 	-rm -f stamp-arch
 	-rm -f tmp-*
 
 # Useful when making CGEN-generated files manually, without --enable-cgen-maint.
-stamps: stamp-v10fmloop stamp-v32fmloop stamp-arch stamp-v10fcpu stamp-v32fcpu
+stamps: stamp-arch stamp-v10fcpu stamp-v32fcpu
 
 stamp-arch: $(CGEN_READ_SCM) $(CGEN_ARCH_SCM) $(CPU_DIR)/cris.cpu Makefile
 	$(MAKE) cgen-arch $(CGEN_FLAGS_TO_PASS) mach=crisv10,crisv32 \
diff --git a/sim/cris/local.mk b/sim/cris/local.mk
new file mode 100644
index 000000000000..c810bcdc4446
--- /dev/null
+++ b/sim/cris/local.mk
@@ -0,0 +1,54 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2004-2021 Free Software Foundation, Inc.
+# Contributed by Axis Communications.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/engv10.h \
+	%D%/mloopv10f.c \
+	%D%/stamp-mloop-v10f \
+	%D%/engv32.h \
+	%D%/mloopv32f.c \
+	%D%/stamp-mloop-v32f
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+# FIXME: What is mono and what does "Use of `mono' is wip" mean (other
+# than the apparent; some "mono" feature is work in progress)?
+%D%/mloopv10f.c %D%/engv10.h: %D%/stamp-mloop-v10f ; @true
+%D%/stamp-mloop-v10f: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -no-fast -pbb -switch semcrisv10f-switch.c \
+		-cpu crisv10f \
+		-infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/ -outfile-suffix -v10f
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-v10f.hin %D%/engv10.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-v10f.cin %D%/mloopv10f.c
+	$(AM_V_at)touch $@
+
+# FIXME: What is mono and what does "Use of `mono' is wip" mean (other
+# than the apparent; some "mono" feature is work in progress)?
+%D%/mloopv32f.c %D%/engv32.h: %D%/stamp-mloop-v32f ; @true
+%D%/stamp-mloop-v32f: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -no-fast -pbb -switch semcrisv32f-switch.c \
+		-cpu crisv32f \
+		-infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/ -outfile-suffix -v32f
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-v32f.hin %D%/engv32.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-v32f.cin %D%/mloopv32f.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/frv/Makefile.in b/sim/frv/Makefile.in
index 2c17075432c6..1159f638c329 100644
--- a/sim/frv/Makefile.in
+++ b/sim/frv/Makefile.in
@@ -54,19 +54,7 @@ FRVBF_INCLUDE_DEPS = \
 	$(SIM_EXTRA_DEPS) \
 	cpu.h decode.h eng.h
 
-# FIXME: Use of `mono' is wip.
-mloop.c eng.h: stamp-mloop
-stamp-mloop: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloop.c eng.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -scache -parallel-generic-write -parallel-only \
-		-cpu frvbf -infile $(srcdir)/mloop.in
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng.hin eng.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop.cin mloop.c
-	$(SILENCE) touch $@
-
 frv-clean:
-	rm -f mloop.c eng.h stamp-mloop
 	rm -f tmp-*
 	rm -f stamp-arch stamp-cpu
 
diff --git a/sim/frv/local.mk b/sim/frv/local.mk
new file mode 100644
index 000000000000..378120c613c5
--- /dev/null
+++ b/sim/frv/local.mk
@@ -0,0 +1,38 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1998-2021 Free Software Foundation, Inc.
+# Contributed by Red Hat.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/eng.h \
+	%D%/mloop.c \
+	%D%/stamp-mloop
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+# FIXME: Use of `mono' is wip.
+%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
+%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -scache -parallel-generic-write -parallel-only \
+		-cpu frvbf \
+		-infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/iq2000/Makefile.in b/sim/iq2000/Makefile.in
index b47d15ac4772..c98fb78e7ff5 100644
--- a/sim/iq2000/Makefile.in
+++ b/sim/iq2000/Makefile.in
@@ -54,19 +54,7 @@ IQ2000BF_INCLUDE_DEPS = \
 	$(CGEN_MAIN_CPU_DEPS) \
 	cpu.h decode.h eng.h
 
-# FIXME: Use of `mono' is wip.
-mloop.c eng.h: stamp-mloop
-stamp-mloop: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloop.c eng.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -fast -pbb -switch sem-switch.c \
-		-cpu iq2000bf -infile $(srcdir)/mloop.in
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng.hin eng.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop.cin mloop.c
-	$(SILENCE) touch $@
-
 iq2000-clean:
-	rm -f mloop.c eng.h stamp-mloop
 	rm -f tmp-*
 	rm -f stamp-arch stamp-cpu
 
diff --git a/sim/iq2000/local.mk b/sim/iq2000/local.mk
new file mode 100644
index 000000000000..00b2af15c23e
--- /dev/null
+++ b/sim/iq2000/local.mk
@@ -0,0 +1,38 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1998-2021 Free Software Foundation, Inc.
+# Contributed by Red Hat.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/eng.h \
+	%D%/mloop.c \
+	%D%/stamp-mloop
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+# FIXME: Use of `mono' is wip.
+%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
+%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -fast -pbb -switch sem-switch.c \
+		-cpu iq2000bf \
+		-infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/lm32/Makefile.in b/sim/lm32/Makefile.in
index 642c483acd26..d827b711d45e 100644
--- a/sim/lm32/Makefile.in
+++ b/sim/lm32/Makefile.in
@@ -35,19 +35,7 @@ LM32BF_INCLUDE_DEPS = \
 	$(CGEN_MAIN_CPU_DEPS) \
 	cpu.h decode.h eng.h
 
-# FIXME: Use of `mono' is wip.
-mloop.c eng.h: stamp-mloop
-stamp-mloop: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloop.c eng.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -fast -pbb -switch sem-switch.c \
-		-cpu lm32bf -infile $(srcdir)/mloop.in
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng.hin eng.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop.cin mloop.c
-	$(SILENCE) touch $@
-
 lm32-clean:
-	rm -f mloop.c eng.h stamp-mloop
 	rm -f stamp-arch stamp-cpu 
 	rm -f tmp-*
 
diff --git a/sim/lm32/local.mk b/sim/lm32/local.mk
new file mode 100644
index 000000000000..2d7ebc208970
--- /dev/null
+++ b/sim/lm32/local.mk
@@ -0,0 +1,38 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2009-2021 Free Software Foundation, Inc.
+# Contributed by Jon Beniston <jon@beniston.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/eng.h \
+	%D%/mloop.c \
+	%D%/stamp-mloop
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+# FIXME: Use of `mono' is wip.
+%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
+%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -fast -pbb -switch sem-switch.c \
+		-cpu lm32bf \
+		-infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/m32r/Makefile.in b/sim/m32r/Makefile.in
index d9d8acfc30fd..df4f5bf0209f 100644
--- a/sim/m32r/Makefile.in
+++ b/sim/m32r/Makefile.in
@@ -50,63 +50,7 @@ cpu.o cpu2.o cpux.o m32r.o m32r2.o m32rx.o mloop.o mloop2.o mloopx.o sem.o sim-i
 
 arch = m32r
 
-# M32R objs
-
-M32RBF_INCLUDE_DEPS = \
-	$(CGEN_MAIN_CPU_DEPS) \
-	cpu.h decode.h eng.h
-
-# FIXME: Use of `mono' is wip.
-mloop.c eng.h: stamp-mloop ; @true
-stamp-mloop: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloop.c eng.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -fast -pbb -switch sem-switch.c \
-		-cpu m32rbf -infile $(srcdir)/mloop.in
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng.hin eng.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop.cin mloop.c
-	$(SILENCE) touch $@
-
-# M32RX objs
-
-M32RXF_INCLUDE_DEPS = \
-	$(CGEN_MAIN_CPU_DEPS) \
-	cpux.h decodex.h engx.h
-
-# FIXME: Use of `mono' is wip.
-mloopx.c engx.h: stamp-xmloop ; @true
-stamp-xmloop: $(srcdir)/../common/genmloop.sh mloopx.in Makefile
-	$(ECHO_STAMP) mloopx.c engx.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -no-fast -pbb -parallel-write -switch semx-switch.c \
-		-cpu m32rxf -infile $(srcdir)/mloopx.in \
-		-outfile-suffix x
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change engx.hin engx.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloopx.cin mloopx.c
-	$(SILENCE) touch $@
-
-# M32R2 objs
-
-M32R2F_INCLUDE_DEPS = \
-	$(CGEN_MAIN_CPU_DEPS) \
-	cpu2.h decode2.h eng2.h
-
-# FIXME: Use of `mono' is wip.
-mloop2.c eng2.h: stamp-2mloop ; @true
-stamp-2mloop: $(srcdir)/../common/genmloop.sh mloop2.in Makefile
-	$(ECHO_STAMP) mloop2.c eng2.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -no-fast -pbb -parallel-write -switch sem2-switch.c \
-		-cpu m32r2f -infile $(srcdir)/mloop2.in \
-		-outfile-suffix 2
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng2.hin eng2.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop2.cin mloop2.c
-	$(SILENCE) touch $@
-
 m32r-clean:
-	rm -f mloop.c eng.h stamp-mloop
-	rm -f mloopx.c engx.h stamp-xmloop
-	rm -f mloop2.c eng2.h stamp-2mloop
 	rm -f stamp-arch stamp-cpu stamp-xcpu stamp-2cpu
 	rm -f tmp-*
 
diff --git a/sim/m32r/local.mk b/sim/m32r/local.mk
new file mode 100644
index 000000000000..ab4abb79bb6d
--- /dev/null
+++ b/sim/m32r/local.mk
@@ -0,0 +1,66 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Contributed by Cygnus Support.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/eng.h \
+	%D%/mloop.c \
+	%D%/stamp-mloop \
+	%D%/engx.h \
+	%D%/mloopx.c \
+	%D%/stamp-mloop-x \
+	%D%/eng2.h \
+	%D%/mloop2.c \
+	%D%/stamp-mloop-2
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+# FIXME: Use of `mono' is wip.
+%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
+%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -fast -pbb -switch sem-switch.c \
+		-cpu m32rbf \
+		-infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
+	$(AM_V_at)touch $@
+
+# FIXME: Use of `mono' is wip.
+%D%/mloopx.c %D%/engx.h: %D%/stamp-mloop ; @true
+%D%/stamp-mloop-x: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -no-fast -pbb -parallel-write -switch semx-switch.c \
+		-cpu m32rxf \
+		-infile $(srcdir)/%D%/mloopx.in -outfile-prefix %D%/ -outfile-suffix x
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/engx.hin %D%/engx.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloopx.cin %D%/mloopx.c
+	$(AM_V_at)touch $@
+
+# FIXME: Use of `mono' is wip.
+%D%/mloop2.c %D%/eng2.h: %D%/stamp-mloop ; @true
+%D%/stamp-mloop-2: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -no-fast -pbb -parallel-write -switch sem2-switch.c \
+		-cpu m32r2f \
+		-infile $(srcdir)/%D%/mloop2.in -outfile-prefix %D%/ -outfile-suffix 2
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng2.hin %D%/eng2.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop2.cin %D%/mloop2.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/or1k/Makefile.in b/sim/or1k/Makefile.in
index c6bd03b756cd..3f1c432c3720 100644
--- a/sim/or1k/Makefile.in
+++ b/sim/or1k/Makefile.in
@@ -53,8 +53,6 @@ SIM_EXTRA_CFLAGS =
 
 SIM_EXTRA_LIBS = -lm
 
-SIM_EXTRA_CLEAN = or1k-clean
-
 ## COMMON_POST_CONFIG_FRAG
 
 arch = or1k
@@ -67,15 +65,6 @@ OR1K32BF_INCLUDE_DEPS = \
 	decode.h \
 	eng.h
 
-mloop.c eng.h: stamp-mloop ; @true
-stamp-mloop: $(srcdir)/../common/genmloop.sh mloop.in Makefile
-	$(ECHO_STAMP) mloop.c eng.h
-	$(SILENCE) $(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
-		-mono -fast -pbb -switch sem-switch.c \
-		-cpu or1k32bf -infile $(srcdir)/mloop.in
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change eng.hin eng.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change mloop.cin mloop.c
-	$(SILENCE) touch $@
 or1k.o: or1k.c $(OR1K32BF_INCLUDE_DEPS)
 	$(COMPILE) $<
 	$(POSTCOMPILE)
@@ -88,10 +77,7 @@ traps.o: traps.c $(SIM_MAIN_DEPS) eng.h
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-or1k-clean:
-	rm -f mloop.c eng.h stamp-mloop
-
-stamps: stamp-arch stamp-cpu stamp-mloop
+stamps: stamp-arch stamp-cpu
 
 # NOTE: Generated source files are specified as full paths,
 # e.g. $(srcdir)/arch.c, because make may decide the files live
diff --git a/sim/or1k/local.mk b/sim/or1k/local.mk
new file mode 100644
index 000000000000..ab1f07df0ea1
--- /dev/null
+++ b/sim/or1k/local.mk
@@ -0,0 +1,37 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2017-2021 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/eng.h \
+	%D%/mloop.c \
+	%D%/stamp-mloop
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+# FIXME: Use of `mono' is wip.
+%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
+%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
+	$(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+		-mono -fast -pbb -switch sem-switch.c \
+		-cpu or1k32bf \
+		-infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
+	$(AM_V_at)touch $@
+
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
-- 
2.33.0


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

end of thread, other threads:[~2021-11-03  3:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03  3:37 [PATCH 1/3] sim: hoist gencode & opc2c build rules up to common builds Mike Frysinger
2021-11-03  3:37 ` [PATCH 2/3] sim: hoist mn10300 & v850 igen " Mike Frysinger
2021-11-03  3:37 ` [PATCH 3/3] sim: hoist cgen mloop " Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).