+# 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 Generating $@
+ @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 __attribute__((__weak__)) 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 modules.c
+ @rm -f $@.l-tmp $@.tmp
+ touch $@
+