aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/Make-common.in5
-rw-r--r--sim/common/local.mk16
2 files changed, 18 insertions, 3 deletions
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