%D%/%.o: common/%.c | $(SIM_ALL_RECURSIVE_DEPS)
$(AM_V_CC)$(COMPILE) -c -o $@ $<
-# See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
-#%D%/modules.c: %D%/stamp-modules ; @true
-#%D%/stamp-modules: Makefile $(%C%_libsim_a_SOURCES) ; $(DO_MODULES_C)
+%D%/modules.c: %D%/stamp-modules ; @true
+%D%/stamp-modules: Makefile $(%C%_libsim_a_SOURCES) ; $(GEN_MODULES_C)
endif
all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS)
-generated_files = \
- $(SIM_EXTRA_DEPS) \
- modules.c
+generated_files = $(SIM_EXTRA_DEPS)
# Ensure that generated files are created early. Use order-only
# dependencies if available. They require GNU make 3.80 or newer,
$(CC) $(ALL_CFLAGS) -DMAIN -o test-hw-events$(EXEEXT) \
$(srccom)/hw-events.c libsim.a $(EXTRA_LIBS)
-# See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
-modules.c: stamp-modules ; @true
-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
- @set -e; (\
- echo '/* Do not modify this file. */'; \
- echo '/* It is created automatically by the Makefile. */'; \
- echo '#include "libiberty.h"'; \
- echo '#include "sim-module.h"'; \
- sed -e 's:\(.*\):extern MODULE_INIT_FN \1;:' $@.l-tmp; \
- echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \
- sed -e 's:\(.*\): \1,:' $@.l-tmp; \
- echo '};'; \
- echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \
- ) >$@.tmp
- $(SILENCE) $(SHELL) $(srcroot)/move-if-change $@.tmp modules.c
- $(SILENCE) rm -f $@.l-tmp $@.tmp
- $(SILENCE) touch $@
-
# Support targets.
install:
mostlyclean clean: $(SIM_EXTRA_CLEAN)
rm -f *.[oa] *~ core \
run$(EXEEXT) libsim.a \
- modules.c stamp-modules \
tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c
distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
CLEANFILES += \
%D%/version.c %D%/version.c-stamp
-%/modules.c:
- $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
-
##
## For subdirs.
##
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.
+GEN_MODULES_C_SRCS = \
+ $(wildcard \
+ $(patsubst %.o,$(srcdir)/%.c,$($(@D)_libsim_a_OBJECTS) $($(@D)_libsim_a_LIBADD)) \
+ $(patsubst $(@D)/%.o,$(srcdir)/common/%.c,$($(@D)_libsim_a_LIBADD)))
+GEN_MODULES_C = \
+ $(AM_V_GEN)set -e; \
+ 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}' $(GEN_MODULES_C_SRCS) | sort >$@.l-tmp; \
+ ( \
+ echo '/* Do not modify this file. */'; \
+ echo '/* It is created automatically by the Makefile. */'; \
+ echo '\#include "libiberty.h"'; \
+ echo '\#include "sim-module.h"'; \
+ sed -e 's:\(.*\):extern MODULE_INIT_FN \1;:' $@.l-tmp; \
+ echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \
+ sed -e 's:\(.*\): \1,:' $@.l-tmp; \
+ echo '};'; \
+ echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \
+ ) >$@.tmp; \
+ $(SHELL) $(srcroot)/move-if-change $@.tmp $(@D)/modules.c; \
+ rm -f $@.l-tmp; \
+ touch $@
+GEN_MODULES_C_TARGETS = $(patsubst %,%/modules.c,$(SIM_SUBDIRS))
+MOSTLYCLEANFILES += $(GEN_MODULES_C_TARGETS) $(patsubst %,%/stamp-moules,$(SIM_SUBDIRS))
+SIM_ALL_RECURSIVE_DEPS += $(GEN_MODULES_C_TARGETS)
+
LIBIBERTY_LIB = ../libiberty/libiberty.a
BFD_LIB = ../bfd/libbfd.la
OPCODES_LIB = ../opcodes/libopcodes.la