sim: switch modules.c & version.c to stamp files

Message ID 20210615003949.6507-1-vapier@gentoo.org
State New
Headers show
Series
  • sim: switch modules.c & version.c to stamp files
Related show

Commit Message

Eli Zaretskii via Gdb-patches June 15, 2021, 12:39 a.m.
This fixes remaking of these files and avoids unnecessary rebuilds.
---
 sim/Makefile.in           | 5 +++--
 sim/common/Make-common.in | 5 +++--
 sim/common/local.mk       | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

-- 
2.31.1

Comments

Tom Tromey June 15, 2021, 8:08 p.m. | #1
>>>>> "Mike" == Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> writes:


Mike> This fixes remaking of these files and avoids unnecessary rebuilds.
 
Mike>  # See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
Mike> -modules.c: Makefile $(SIM_OBJS:.o=.c)
Mike> +modules.c: stamp-modules ; @true
Mike> +stamp-modules: Makefile $(SIM_OBJS:.o=.c)

I didn't look at how the .c file is handled, but if 'make clean' removes
it, then it ought to remove the stamp file as well.

Tom
Eli Zaretskii via Gdb-patches June 15, 2021, 9:01 p.m. | #2
On 15 Jun 2021 14:08, Tom Tromey wrote:
> >>>>> "Mike" == Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> writes:

> 

> Mike> This fixes remaking of these files and avoids unnecessary rebuilds.

>  

> Mike>  # See sim_pre_argv_init and sim_module_install in sim-module.c for more details.

> Mike> -modules.c: Makefile $(SIM_OBJS:.o=.c)

> Mike> +modules.c: stamp-modules ; @true

> Mike> +stamp-modules: Makefile $(SIM_OBJS:.o=.c)

> 

> I didn't look at how the .c file is handled, but if 'make clean' removes

> it, then it ought to remove the stamp file as well.


neither are in the clean target atm.  going by the standards page, it sounds
like they should.
https://www.gnu.org/prep/standards/standards.html#Standard-Targets
-mike

Patch

diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 3dab9ca1fd14..cd50ad03e7e6 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -465,7 +465,8 @@  test-hw-events: $(srccom)/hw-events.c libsim.a
 		$(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: Makefile $(SIM_OBJS:.o=.c)
+modules.c: stamp-modules ; @true
+stamp-modules: Makefile $(SIM_OBJS:.o=.c)
 	@echo Generating $@
 	@LANG=C ; export LANG ; \
 	LC_ALL=C ; export LC_ALL ; \
@@ -481,7 +482,7 @@  modules.c: Makefile $(SIM_OBJS:.o=.c)
 	echo '};'; \
 	echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \
 	) >$@.tmp
-	$(SHELL) $(srcroot)/move-if-change $@.tmp $@
+	$(SHELL) $(srcroot)/move-if-change $@.tmp modules.c
 	@rm -f $@.l-tmp $@.tmp
 	touch $@
 
diff --git a/sim/common/local.mk b/sim/common/local.mk
index fc1149789a3c..01fb02750e89 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -38,7 +38,8 @@  noinst_LIBRARIES += %D%/libcommon.a
 	%D%/sim-load.c \
 	%D%/version.c
 
-%D%/version.c: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(srcdir)/%D%/create-version.sh
+%D%/version.c: %D%/version.c-stamp ; @true
+%D%/version.c-stamp: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(srcdir)/%D%/create-version.sh
 	$(AM_V_GEN)$(SHELL) $(srcdir)/%D%/create-version.sh $(srcroot)/gdb $@.tmp
-	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change $@.tmp $@
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change $@.tmp $(@:-stamp=)
 	$(AM_V_at)touch $@