aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2022-12-25 14:40:47 -0500
committerMike Frysinger <vapier@gentoo.org>2023-01-10 01:15:23 -0500
commit437eeee95c10c613d992fc786350618bbafcdf57 (patch)
tree80eccebe64f76af4962276700a01830c5f2d7664
parent7dd38e31d67c2548b52bea313ab18e40824c05da (diff)
downloadgdb-437eeee95c10c613d992fc786350618bbafcdf57.zip
gdb-437eeee95c10c613d992fc786350618bbafcdf57.tar.gz
gdb-437eeee95c10c613d992fc786350618bbafcdf57.tar.bz2
sim: modules: trigger generation from top-level
Add rules for tracking generated subdir modules.c files. This doesn't actually generate the file from the top-level, but allows us to add rules that need to be ordered wrt it. Once those changes land, we can rework this to actually generate from the top-level. This currently builds off of the objects that go into the libsim.a as we don't build those from the top-level either. Once we migrate that up, we can switch this to the source files directly. It's a bit hacky overall, but makes it easier to migrate things in smaller chunks, and we aren't going to keep this logic long term.
-rw-r--r--sim/Makefile.in41
-rw-r--r--sim/bpf/local.mk1
-rw-r--r--sim/common/Make-common.in5
-rw-r--r--sim/common/local.mk16
-rw-r--r--sim/cr16/local.mk1
-rw-r--r--sim/cris/local.mk1
-rw-r--r--sim/d10v/local.mk1
-rw-r--r--sim/frv/local.mk1
-rw-r--r--sim/iq2000/local.mk1
-rw-r--r--sim/lm32/local.mk1
-rw-r--r--sim/m32c/local.mk1
-rw-r--r--sim/m32r/local.mk1
-rw-r--r--sim/m68hc11/local.mk1
-rw-r--r--sim/mips/local.mk1
-rw-r--r--sim/mn10300/local.mk1
-rw-r--r--sim/or1k/local.mk1
-rw-r--r--sim/sh/local.mk1
-rw-r--r--sim/v850/local.mk1
18 files changed, 67 insertions, 10 deletions
diff --git a/sim/Makefile.in b/sim/Makefile.in
index 96305a3..d04260f 100644
--- a/sim/Makefile.in
+++ b/sim/Makefile.in
@@ -1271,7 +1271,9 @@ CLEANFILES = common/version.c common/version.c-stamp \
testsuite/common/bits64m63.c
DISTCLEANFILES = $(am__append_76)
MOSTLYCLEANFILES = core $(common_HW_CONFIG_H_TARGETS) $(patsubst \
- %,%/stamp-hw,$(SIM_ENABLED_ARCHES)) $(am__append_7) \
+ %,%/stamp-hw,$(SIM_ENABLED_ARCHES)) \
+ $(common_GEN_MODULES_C_TARGETS) $(patsubst \
+ %,%/stamp-modules,$(SIM_ENABLED_ARCHES)) $(am__append_7) \
site-sim-config.exp testrun.log testrun.sum $(am__append_16) \
$(am__append_21) $(am__append_27) $(am__append_32) \
$(am__append_40) $(am__append_46) $(am__append_51) \
@@ -1287,12 +1289,13 @@ AM_CPPFLAGS_FOR_BUILD = -I$(srcroot)/include $(SIM_HW_CFLAGS) \
COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
LINK_FOR_BUILD = $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
SIM_ALL_RECURSIVE_DEPS = common/libcommon.a \
- $(common_HW_CONFIG_H_TARGETS) $(am__append_4) $(am__append_15) \
- $(am__append_19) $(am__append_26) $(am__append_30) \
- $(am__append_39) $(am__append_45) $(am__append_50) \
- $(am__append_53) $(am__append_59) $(am__append_63) \
- $(am__append_74) $(am__append_80) $(am__append_86) \
- $(am__append_95) $(am__append_100)
+ $(common_HW_CONFIG_H_TARGETS) $(common_GEN_MODULES_C_TARGETS) \
+ $(am__append_4) $(am__append_15) $(am__append_19) \
+ $(am__append_26) $(am__append_30) $(am__append_39) \
+ $(am__append_45) $(am__append_50) $(am__append_53) \
+ $(am__append_59) $(am__append_63) $(am__append_74) \
+ $(am__append_80) $(am__append_86) $(am__append_95) \
+ $(am__append_100)
SIM_INSTALL_DATA_LOCAL_DEPS =
SIM_INSTALL_EXEC_LOCAL_DEPS = $(am__append_34)
SIM_UNINSTALL_LOCAL_DEPS = $(am__append_35)
@@ -1328,6 +1331,13 @@ SIM_NEW_COMMON_OBJS = sim-arange.o sim-bits.o sim-close.o \
sim-watch.o $(am__append_2)
SIM_HW_DEVICES = cfi core pal glue
common_HW_CONFIG_H_TARGETS = $(patsubst %,%/hw-config.h,$(SIM_ENABLED_ARCHES))
+am_arch_d = $(subst -,_,$(@D))
+GEN_MODULES_C_SRCS = \
+ $(wildcard \
+ $(patsubst %.o,$(abs_srcdir)/%.c,$($(am_arch_d)_libsim_a_OBJECTS) $($(am_arch_d)_libsim_a_LIBADD)) \
+ $(filter-out %.o,$(patsubst $(@D)/%.o,$(abs_srcdir)/common/%.c,$($(am_arch_d)_libsim_a_LIBADD))))
+
+common_GEN_MODULES_C_TARGETS = $(patsubst %,%/modules.c,$(filter-out ppc,$(SIM_ENABLED_ARCHES)))
LIBIBERTY_LIB = ../libiberty/libiberty.a
BFD_LIB = ../bfd/libbfd.la
OPCODES_LIB = ../opcodes/libopcodes.la
@@ -3370,6 +3380,8 @@ common/version.c-stamp: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(src
$(SHELL) $(srcroot)/move-if-change $@.tmp $(@D)/hw-config.h; \
touch $@
.PRECIOUS: %/stamp-hw
+%/modules.c:
+ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) GEN_MODULES_C_SRCS="$(GEN_MODULES_C_SRCS)" -C $(@D) $(@F)
# Alias for developers.
@SIM_ENABLE_IGEN_TRUE@igen: $(IGEN)
@@ -3502,6 +3514,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_bfin_TRUE@ ) > $@.tmp
@SIM_ENABLE_ARCH_bfin_TRUE@ $(AM_V_at)$(SHELL) $(srcroot)/move-if-change $@.tmp $(srcdir)/bfin/linux-fixed-code.h
@SIM_ENABLE_ARCH_bfin_TRUE@ $(AM_V_at)touch $(srcdir)/bfin/linux-fixed-code.h
+@SIM_ENABLE_ARCH_bpf_TRUE@bpf/modules.c: | $(bpf_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_bpf_TRUE@bpf/mloop-le.c bpf/eng-le.h: bpf/stamp-mloop-le ; @true
@SIM_ENABLE_ARCH_bpf_TRUE@bpf/stamp-mloop-le: $(srccom)/genmloop.sh bpf/mloop.in
@@ -3549,6 +3562,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_bpf_TRUE@bpf/cgen-decode-be:
@SIM_ENABLE_ARCH_bpf_TRUE@ $(AM_V_GEN)isa=ebpfbe cpu=bpfbf mach=bpf FLAGS="with-scache" SUFFIX="-be" EXTRAFILES="$(CGEN_CPU_SEM)"; $(CGEN_GEN_DECODE)
@SIM_ENABLE_ARCH_bpf_TRUE@bpf/sem-be.c bpf/decode-be.c bpf/decode-be.h: @CGEN_MAINT@ bpf/cgen-decode-be
+@SIM_ENABLE_ARCH_cr16_TRUE@cr16/modules.c: | $(cr16_BUILD_OUTPUTS)
# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
@SIM_ENABLE_ARCH_cr16_TRUE@cr16/gencode$(EXEEXT): $(cr16_gencode_OBJECTS) $(cr16_gencode_DEPENDENCIES) cr16/$(am__dirstamp)
@@ -3565,6 +3579,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_cr16_TRUE@cr16/table.c: cr16/gencode$(EXEEXT)
@SIM_ENABLE_ARCH_cr16_TRUE@ $(AM_V_GEN)$< >$@
+@SIM_ENABLE_ARCH_cris_TRUE@cris/modules.c: | $(cris_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_cris_TRUE@cris/mloopv10f.c cris/engv10.h: cris/stamp-mloop-v10f ; @true
@SIM_ENABLE_ARCH_cris_TRUE@cris/stamp-mloop-v10f: $(srccom)/genmloop.sh cris/mloop.in
@@ -3601,6 +3616,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_cris_TRUE@ $(AM_V_GEN)cpu=crisv32f mach=crisv32 SUFFIX=v32 FLAGS="with-scache with-profile=fn" EXTRAFILES="$(CGEN_CPU_SEMSW)"; $(CGEN_GEN_CPU_DECODE)
@SIM_ENABLE_ARCH_cris_TRUE@ $(AM_V_at)$(SHELL) $(srcroot)/move-if-change $(srcdir)/cris/semv32-switch.c $(srcdir)/cris/semcrisv32f-switch.c
@SIM_ENABLE_ARCH_cris_TRUE@cris/cpuv32.h cris/cpuv32.c cris/semcrisv32f-switch.c cris/modelv32.c cris/decodev32.c cris/decodev32.h: @CGEN_MAINT@ cris/cgen-cpu-decode-v32f
+@SIM_ENABLE_ARCH_d10v_TRUE@d10v/modules.c: | $(d10v_BUILD_OUTPUTS)
# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
@SIM_ENABLE_ARCH_d10v_TRUE@d10v/gencode$(EXEEXT): $(d10v_gencode_OBJECTS) $(d10v_gencode_DEPENDENCIES) d10v/$(am__dirstamp)
@@ -3629,6 +3645,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_erc32_TRUE@ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) erc32/run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
@SIM_ENABLE_ARCH_erc32_TRUE@sim-erc32-uninstall-local:
@SIM_ENABLE_ARCH_erc32_TRUE@ rm -f $(DESTDIR)$(bindir)/sis
+@SIM_ENABLE_ARCH_frv_TRUE@frv/modules.c: | $(frv_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_frv_TRUE@frv/mloop.c frv/eng.h: frv/stamp-mloop ; @true
@SIM_ENABLE_ARCH_frv_TRUE@frv/stamp-mloop: $(srccom)/genmloop.sh frv/mloop.in
@@ -3649,6 +3666,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_frv_TRUE@frv/cgen-cpu-decode:
@SIM_ENABLE_ARCH_frv_TRUE@ $(AM_V_GEN)cpu=frvbf mach=frv,fr550,fr500,fr450,fr400,tomcat,simple FLAGS="with-scache with-profile=fn with-generic-write with-parallel-only" EXTRAFILES="$(CGEN_CPU_SEM)"; $(CGEN_GEN_CPU_DECODE)
@SIM_ENABLE_ARCH_frv_TRUE@frv/cpu.h frv/sem.c frv/model.c frv/decode.c frv/decode.h: @CGEN_MAINT@ frv/cgen-cpu-decode
+@SIM_ENABLE_ARCH_iq2000_TRUE@iq2000/modules.c: | $(iq2000_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_iq2000_TRUE@iq2000/mloop.c iq2000/eng.h: iq2000/stamp-mloop ; @true
@SIM_ENABLE_ARCH_iq2000_TRUE@iq2000/stamp-mloop: $(srccom)/genmloop.sh iq2000/mloop.in
@@ -3669,6 +3687,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_iq2000_TRUE@iq2000/cgen-cpu-decode:
@SIM_ENABLE_ARCH_iq2000_TRUE@ $(AM_V_GEN)cpu=iq2000bf mach=iq2000 FLAGS="with-scache with-profile=fn" EXTRAFILES="$(CGEN_CPU_SEM) $(CGEN_CPU_SEMSW)"; $(CGEN_GEN_CPU_DECODE)
@SIM_ENABLE_ARCH_iq2000_TRUE@iq2000/cpu.h iq2000/sem.c iq2000/sem-switch.c iq2000/model.c iq2000/decode.c iq2000/decode.h: @CGEN_MAINT@ iq2000/cgen-cpu-decode
+@SIM_ENABLE_ARCH_lm32_TRUE@lm32/modules.c: | $(lm32_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_lm32_TRUE@lm32/mloop.c lm32/eng.h: lm32/stamp-mloop ; @true
@SIM_ENABLE_ARCH_lm32_TRUE@lm32/stamp-mloop: $(srccom)/genmloop.sh lm32/mloop.in
@@ -3692,6 +3711,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_m32c_TRUE@m32c/%.o: m32c/%.c | m32c/libsim.a $(SIM_ALL_RECURSIVE_DEPS)
@SIM_ENABLE_ARCH_m32c_TRUE@ $(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
+@SIM_ENABLE_ARCH_m32c_TRUE@m32c/modules.c: | $(m32c_BUILD_OUTPUTS)
# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
@SIM_ENABLE_ARCH_m32c_TRUE@m32c/opc2c$(EXEEXT): $(m32c_opc2c_OBJECTS) $(m32c_opc2c_DEPENDENCIES) m32c/$(am__dirstamp)
@@ -3708,6 +3728,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_m32c_TRUE@m32c/r8c.c: m32c/r8c.opc m32c/opc2c$(EXEEXT)
@SIM_ENABLE_ARCH_m32c_TRUE@ $(AM_V_GEN)$(m32c_OPC2C_RUN) -l $@.log $< > $@.tmp
@SIM_ENABLE_ARCH_m32c_TRUE@ $(AM_V_at)mv $@.tmp $@
+@SIM_ENABLE_ARCH_m32r_TRUE@m32r/modules.c: | $(m32r_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_m32r_TRUE@m32r/mloop.c m32r/eng.h: m32r/stamp-mloop ; @true
@SIM_ENABLE_ARCH_m32r_TRUE@m32r/stamp-mloop: $(srccom)/genmloop.sh m32r/mloop.in
@@ -3756,6 +3777,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_m32r_TRUE@m32r/cgen-cpu-decode-2:
@SIM_ENABLE_ARCH_m32r_TRUE@ $(AM_V_GEN)cpu=m32r2f mach=m32r2 SUFFIX=2 FLAGS="with-scache with-profile=fn" EXTRAFILES="$(CGEN_CPU_SEMSW)"; $(CGEN_GEN_CPU_DECODE)
@SIM_ENABLE_ARCH_m32r_TRUE@m32r/cpu2.h m32r/sem2-switch.c m32r/model2.c m32r/decode2.c m32r/decode2.h: @CGEN_MAINT@ m32r/cgen-cpu-decode-2
+@SIM_ENABLE_ARCH_m68hc11_TRUE@m68hc11/modules.c: | $(m68hc11_BUILD_OUTPUTS)
# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
@SIM_ENABLE_ARCH_m68hc11_TRUE@m68hc11/gencode$(EXEEXT): $(m68hc11_gencode_OBJECTS) $(m68hc11_gencode_DEPENDENCIES) m68hc11/$(am__dirstamp)
@@ -3770,6 +3792,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_m68hc11_TRUE@m68hc11/m68hc12int.c: m68hc11/gencode$(EXEEXT)
@SIM_ENABLE_ARCH_m68hc11_TRUE@ $(AM_V_GEN)$< -m6812 >$@
+@SIM_ENABLE_ARCH_mips_TRUE@mips/modules.c: | $(mips_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_mips_TRUE@$(mips_BUILT_SRC_FROM_IGEN_ITABLE): mips/stamp-igen-itable
@SIM_ENABLE_ARCH_mips_TRUE@$(mips_BUILT_SRC_FROM_GEN_MODE_SINGLE): mips/stamp-gen-mode-single
@@ -3968,6 +3991,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_mips_TRUE@ esac \
@SIM_ENABLE_ARCH_mips_TRUE@ done
@SIM_ENABLE_ARCH_mips_TRUE@ $(AM_V_at)touch $@
+@SIM_ENABLE_ARCH_mn10300_TRUE@mn10300/modules.c: | $(mn10300_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_mn10300_TRUE@$(mn10300_BUILT_SRC_FROM_IGEN): mn10300/stamp-igen
@SIM_ENABLE_ARCH_mn10300_TRUE@mn10300/stamp-igen: $(mn10300_IGEN_INSN) $(mn10300_IGEN_INSN_INC) $(mn10300_IGEN_DC) $(IGEN)
@@ -4008,6 +4032,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_moxie_TRUE@ echo "tree compiler tool (dtc) is missing. Install the tool to "; \
@SIM_ENABLE_ARCH_moxie_TRUE@ echo "update the device tree blob."; \
@SIM_ENABLE_ARCH_moxie_TRUE@ fi
+@SIM_ENABLE_ARCH_or1k_TRUE@or1k/modules.c: | $(or1k_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_or1k_TRUE@or1k/mloop.c or1k/eng.h: or1k/stamp-mloop ; @true
@SIM_ENABLE_ARCH_or1k_TRUE@or1k/stamp-mloop: $(srccom)/genmloop.sh or1k/mloop.in
@@ -4050,6 +4075,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_rx_TRUE@rx/%.o: rx/%.c | rx/libsim.a $(SIM_ALL_RECURSIVE_DEPS)
@SIM_ENABLE_ARCH_rx_TRUE@ $(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
+@SIM_ENABLE_ARCH_sh_TRUE@sh/modules.c: | $(sh_BUILD_OUTPUTS)
# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
@SIM_ENABLE_ARCH_sh_TRUE@sh/gencode$(EXEEXT): $(sh_gencode_OBJECTS) $(sh_gencode_DEPENDENCIES) sh/$(am__dirstamp)
@@ -4067,6 +4093,7 @@ testsuite/common/bits64m63.c: testsuite/common/bits-gen$(EXEEXT) testsuite/commo
@SIM_ENABLE_ARCH_sh_TRUE@sh/table.c: sh/gencode$(EXEEXT)
@SIM_ENABLE_ARCH_sh_TRUE@ $(AM_V_GEN)$< -s >$@
+@SIM_ENABLE_ARCH_v850_TRUE@v850/modules.c: | $(v850_BUILD_OUTPUTS)
@SIM_ENABLE_ARCH_v850_TRUE@$(v850_BUILT_SRC_FROM_IGEN): v850/stamp-igen
@SIM_ENABLE_ARCH_v850_TRUE@v850/stamp-igen: $(v850_IGEN_INSN) $(v850_IGEN_DC) $(IGEN)
diff --git a/sim/bpf/local.mk b/sim/bpf/local.mk
index 4ba1f46..f86f330 100644
--- a/sim/bpf/local.mk
+++ b/sim/bpf/local.mk
@@ -35,6 +35,7 @@ BUILT_SOURCES += \
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%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
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 35477d9..b56a49a 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -186,8 +186,7 @@ endif
all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS)
generated_files = \
- $(SIM_EXTRA_DEPS) \
- modules.c
+ $(SIM_EXTRA_DEPS)
# Ensure that generated files are created early. Use order-only
# dependencies if available. They require GNU make 3.80 or newer,
@@ -212,7 +211,7 @@ stamp-modules: Makefile $(SIM_OBJS:.o=.c)
$(ECHO_STAMP) modules.c
$(SILENCE) LANG=C ; export LANG ; \
LC_ALL=C ; export LC_ALL ; \
- sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $^ | sort >$@.l-tmp
+ sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $^ $(GEN_MODULES_C_SRCS) | sort >$@.l-tmp
@set -e; (\
echo '/* Do not modify this file. */'; \
echo '/* It is created automatically by the Makefile. */'; \
diff --git a/sim/common/local.mk b/sim/common/local.mk
index dd6ed5f..128b770 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -130,6 +130,22 @@ endif
MOSTLYCLEANFILES += $(%C%_HW_CONFIG_H_TARGETS) $(patsubst %,%/stamp-hw,$(SIM_ENABLED_ARCHES))
SIM_ALL_RECURSIVE_DEPS += $(%C%_HW_CONFIG_H_TARGETS)
+## See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
+## TODO: Switch this to xxx_SOURCES once projects build objects in local.mk.
+am_arch_d = $(subst -,_,$(@D))
+GEN_MODULES_C_SRCS = \
+ $(wildcard \
+ $(patsubst %.o,$(abs_srcdir)/%.c,$($(am_arch_d)_libsim_a_OBJECTS) $($(am_arch_d)_libsim_a_LIBADD)) \
+ $(filter-out %.o,$(patsubst $(@D)/%.o,$(abs_srcdir)/common/%.c,$($(am_arch_d)_libsim_a_LIBADD))))
+%/modules.c:
+ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) GEN_MODULES_C_SRCS="$(GEN_MODULES_C_SRCS)" -C $(@D) $(@F)
+
+## NB: The ppc port doesn't currently utilize the modules API, so skip it.
+%C%_GEN_MODULES_C_TARGETS = $(patsubst %,%/modules.c,$(filter-out ppc,$(SIM_ENABLED_ARCHES)))
+MOSTLYCLEANFILES += $(%C%_GEN_MODULES_C_TARGETS) $(patsubst %,%/stamp-modules,$(SIM_ENABLED_ARCHES))
+## TODO: Drop this once each port's local.mk:libsim.a depends on it themself.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_GEN_MODULES_C_TARGETS)
+
LIBIBERTY_LIB = ../libiberty/libiberty.a
BFD_LIB = ../bfd/libbfd.la
OPCODES_LIB = ../opcodes/libopcodes.la
diff --git a/sim/cr16/local.mk b/sim/cr16/local.mk
index f5401f6..8e28cc3 100644
--- a/sim/cr16/local.mk
+++ b/sim/cr16/local.mk
@@ -32,6 +32,7 @@ BUILT_SOURCES += %D%/simops.h
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
%C%_gencode_SOURCES = %D%/gencode.c
%C%_gencode_LDADD = %D%/cr16-opc.o
diff --git a/sim/cris/local.mk b/sim/cris/local.mk
index 0e56fef..d55e7b8 100644
--- a/sim/cris/local.mk
+++ b/sim/cris/local.mk
@@ -46,6 +46,7 @@ BUILT_SOURCES += \
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%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)?
diff --git a/sim/d10v/local.mk b/sim/d10v/local.mk
index 38a3c92..2556845 100644
--- a/sim/d10v/local.mk
+++ b/sim/d10v/local.mk
@@ -32,6 +32,7 @@ BUILT_SOURCES += %D%/simops.h
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
%C%_gencode_SOURCES = %D%/gencode.c
%C%_gencode_LDADD = %D%/d10v-opc.o
diff --git a/sim/frv/local.mk b/sim/frv/local.mk
index 11db636..471b0ad 100644
--- a/sim/frv/local.mk
+++ b/sim/frv/local.mk
@@ -35,6 +35,7 @@ BUILT_SOURCES += %D%/eng.h
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
diff --git a/sim/iq2000/local.mk b/sim/iq2000/local.mk
index 881cf2c..4113b4b 100644
--- a/sim/iq2000/local.mk
+++ b/sim/iq2000/local.mk
@@ -32,6 +32,7 @@ BUILT_SOURCES += %D%/eng.h
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
diff --git a/sim/lm32/local.mk b/sim/lm32/local.mk
index 3f96064..311de7d 100644
--- a/sim/lm32/local.mk
+++ b/sim/lm32/local.mk
@@ -35,6 +35,7 @@ BUILT_SOURCES += %D%/eng.h
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
diff --git a/sim/m32c/local.mk b/sim/m32c/local.mk
index 1a542f1..7590907 100644
--- a/sim/m32c/local.mk
+++ b/sim/m32c/local.mk
@@ -35,6 +35,7 @@ noinst_PROGRAMS += %D%/run
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
%C%_opc2c_SOURCES = %D%/opc2c.c
diff --git a/sim/m32r/local.mk b/sim/m32r/local.mk
index 4f9f2bc..9814ae5 100644
--- a/sim/m32r/local.mk
+++ b/sim/m32r/local.mk
@@ -42,6 +42,7 @@ BUILT_SOURCES += \
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
diff --git a/sim/m68hc11/local.mk b/sim/m68hc11/local.mk
index 187bd38..d2e0457 100644
--- a/sim/m68hc11/local.mk
+++ b/sim/m68hc11/local.mk
@@ -34,6 +34,7 @@ AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
%C%_gencode_SOURCES = %D%/gencode.c
diff --git a/sim/mips/local.mk b/sim/mips/local.mk
index 9db960c..5a7b12c 100644
--- a/sim/mips/local.mk
+++ b/sim/mips/local.mk
@@ -96,6 +96,7 @@ endif
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
$(%C%_BUILT_SRC_FROM_IGEN_ITABLE): %D%/stamp-igen-itable
$(%C%_BUILT_SRC_FROM_GEN_MODE_SINGLE): %D%/stamp-gen-mode-single
diff --git a/sim/mn10300/local.mk b/sim/mn10300/local.mk
index afb1df7..d24e6b8 100644
--- a/sim/mn10300/local.mk
+++ b/sim/mn10300/local.mk
@@ -58,6 +58,7 @@ BUILT_SOURCES += \
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
$(%C%_BUILT_SRC_FROM_IGEN): %D%/stamp-igen
diff --git a/sim/or1k/local.mk b/sim/or1k/local.mk
index ef8ae2a..7d999f6 100644
--- a/sim/or1k/local.mk
+++ b/sim/or1k/local.mk
@@ -34,6 +34,7 @@ BUILT_SOURCES += %D%/eng.h
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
diff --git a/sim/sh/local.mk b/sim/sh/local.mk
index 8c2ce0d..c25ab53 100644
--- a/sim/sh/local.mk
+++ b/sim/sh/local.mk
@@ -36,6 +36,7 @@ BUILT_SOURCES += \
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
%C%_gencode_SOURCES = %D%/gencode.c
diff --git a/sim/v850/local.mk b/sim/v850/local.mk
index 4741e07..2c27d0c 100644
--- a/sim/v850/local.mk
+++ b/sim/v850/local.mk
@@ -55,6 +55,7 @@ BUILT_SOURCES += \
## This makes sure build tools are available before building the arch-subdirs.
SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+%D%/modules.c: | $(%C%_BUILD_OUTPUTS)
$(%C%_BUILT_SRC_FROM_IGEN): %D%/stamp-igen