From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 1CA413847C72 for ; Tue, 3 Jan 2023 07:57:29 +0000 (GMT) Received: by smtp.gentoo.org (Postfix, from userid 559) id C1C14335D79; Tue, 3 Jan 2023 07:57:28 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 37/83] sim: modules.c: move generation to top-level Date: Tue, 3 Jan 2023 02:55:19 -0500 Message-Id: <20230103075605.13606-38-vapier@gentoo.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103075605.13606-1-vapier@gentoo.org> References: <20230103075605.13606-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Now that all arches create libsim.a from the top-level, we have full access to their inputs, and can move the actual generation from the subdir up to the top-level. This avoids recursive makes and will help simplify state passing between the two. --- sim/Makefile.in | 28 ++++++++++++++++++++++++---- sim/common/Make-common.in | 25 +------------------------ sim/common/local.mk | 28 ++++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index f9f6ed1984c4..15242c612647 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -159,28 +159,6 @@ test-hw-events: $(srccom)/hw-events.c libsim.a $(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 - $(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}' $^ $(GEN_MODULES_C_SRCS) | 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: @@ -214,8 +192,7 @@ TAGS: force *.[ch] ../common/*.[ch] mostlyclean clean: $(SIM_EXTRA_CLEAN) - rm -f *.[oa] *~ core \ - modules.c stamp-modules + rm -f *.[oa] *~ core distclean maintainer-clean realclean: clean rm -f TAGS Makefile diff --git a/sim/common/local.mk b/sim/common/local.mk index 128b770dbe10..debb55da933b 100644 --- a/sim/common/local.mk +++ b/sim/common/local.mk @@ -135,10 +135,30 @@ SIM_ALL_RECURSIVE_DEPS += $(%C%_HW_CONFIG_H_TARGETS) 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) + $(patsubst %,$(srcdir)/%,$($(am_arch_d)_libsim_a_SOURCES)) \ + $(patsubst %.o,$(srcdir)/%.c,$($(am_arch_d)_libsim_a_OBJECTS) $($(am_arch_d)_libsim_a_LIBADD)) \ + $(filter-out %.o,$(patsubst $(@D)/%.o,$(srcdir)/common/%.c,$($(am_arch_d)_libsim_a_LIBADD)))) +%/modules.c: %/stamp-modules ; @true +%/stamp-modules: Makefile + $(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 $@ +.PRECIOUS: %/stamp-modules ## 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))) -- 2.39.0