public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] sim: build: hoist lists of common objects up
@ 2022-12-21  5:33 Mike Frysinger
  2022-12-21  5:33 ` [PATCH 2/3] sim: build: hoist lists of hw devices up Mike Frysinger
  2022-12-21  5:33 ` [PATCH 3/3] sim: hw-config.h: move generation to top-level Mike Frysinger
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Frysinger @ 2022-12-21  5:33 UTC (permalink / raw)
  To: gdb-patches

In order to create libsim.a in the common dir, we need the list of
objects for each target.  To avoid duplicating the list with the
recursive make in each port, pass it down as a variable.  This is
a temporary hack until the top-level creates libsim.a for ports.
---
 sim/Makefile.in           | 194 +++++++++++++++++++++-----------------
 sim/arch-subdir.mk.in     |   3 +-
 sim/common/Make-common.in |  47 +--------
 sim/common/local.mk       |  54 +++++++++++
 4 files changed, 167 insertions(+), 131 deletions(-)

diff --git a/sim/arch-subdir.mk.in b/sim/arch-subdir.mk.in
index 251a9b684d93..cfde3f3fb785 100644
--- a/sim/arch-subdir.mk.in
+++ b/sim/arch-subdir.mk.in
@@ -71,6 +71,5 @@ CGENDIR = @cgendir@
 SIM_INLINE = @SIM_INLINE@
 
 SIM_HW_CFLAGS = @SIM_HW_CFLAGS@
-SIM_HW_SOCKSER = @SIM_HW_SOCKSER@
-SIM_HW_OBJS = $(SIM_COMMON_HW_OBJS) $(SIM_HW_DEVICES:%=dv-%.o) $(SIM_HW_SOCKSER)
+SIM_HW_OBJS = $(SIM_HW_DEVICES:%=dv-%.o)
 @SIM_ENABLE_HW_FALSE@SIM_HW_OBJS =
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 8e27795438a9..684d7d847ab0 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -114,50 +114,6 @@ SIM_EXTRA_DISTCLEAN =
 # here.  Some files are used by all simulators (e.g. callback.o).
 # Those files are specified in LIB_OBJS below.
 
-SIM_COMMON_HW_OBJS = \
-	hw-alloc.o \
-	hw-base.o \
-	hw-device.o \
-	hw-events.o \
-	hw-handles.o \
-	hw-instances.o \
-	hw-ports.o \
-	hw-properties.o \
-	hw-tree.o \
-	sim-hw.o \
-
-SIM_NEW_COMMON_OBJS = \
-	sim-arange.o \
-	sim-bits.o \
-	sim-close.o \
-	sim-command.o \
-	sim-config.o \
-	sim-core.o \
-	sim-cpu.o \
-	sim-endian.o \
-	sim-engine.o \
-	sim-events.o \
-	sim-fpu.o \
-	sim-hload.o \
-	sim-hrw.o \
-	sim-io.o \
-	sim-info.o \
-	sim-memopt.o \
-	sim-model.o \
-	sim-module.o \
-	sim-options.o \
-	sim-profile.o \
-	sim-reason.o \
-	sim-reg.o \
-	sim-signal.o \
-	sim-stop.o \
-	sim-syscall.o \
-	sim-trace.o \
-	sim-utils.o \
-	sim-watch.o \
-	\
-	$(SIM_HW_OBJS) \
-
 ## End COMMON_PRE_CONFIG_FRAG
 
 ## COMMON_POST_CONFIG_FRAG
@@ -180,7 +136,8 @@ BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH)
 
 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS)
 
-SIM_HW_DEVICES = cfi core pal glue $(SIM_EXTRA_HW_DEVICES)
+SIM_HW_DEVICES = $(SIM_HW_DEVICES_) $(SIM_EXTRA_HW_DEVICES)
+SIM_NEW_COMMON_OBJS = $(SIM_NEW_COMMON_OBJS_) $(SIM_HW_OBJS)
 
 LIBIBERTY_LIB = ../../libiberty/libiberty.a
 BFD_LIB = ../../bfd/libbfd.la
diff --git a/sim/common/local.mk b/sim/common/local.mk
index c45af29d8c71..bf9b97d04d71 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -56,6 +56,60 @@ CLEANFILES += \
 ## For subdirs.
 ##
 
+SIM_COMMON_HW_OBJS = \
+	hw-alloc.o \
+	hw-base.o \
+	hw-device.o \
+	hw-events.o \
+	hw-handles.o \
+	hw-instances.o \
+	hw-ports.o \
+	hw-properties.o \
+	hw-tree.o \
+	sim-hw.o
+
+SIM_NEW_COMMON_OBJS = \
+	sim-arange.o \
+	sim-bits.o \
+	sim-close.o \
+	sim-command.o \
+	sim-config.o \
+	sim-core.o \
+	sim-cpu.o \
+	sim-endian.o \
+	sim-engine.o \
+	sim-events.o \
+	sim-fpu.o \
+	sim-hload.o \
+	sim-hrw.o \
+	sim-io.o \
+	sim-info.o \
+	sim-memopt.o \
+	sim-model.o \
+	sim-module.o \
+	sim-options.o \
+	sim-profile.o \
+	sim-reason.o \
+	sim-reg.o \
+	sim-signal.o \
+	sim-stop.o \
+	sim-syscall.o \
+	sim-trace.o \
+	sim-utils.o \
+	sim-watch.o
+
+AM_MAKEFLAGS += SIM_NEW_COMMON_OBJS_="$(SIM_NEW_COMMON_OBJS)"
+
+SIM_HW_DEVICES = cfi core pal glue
+
+if SIM_ENABLE_HW
+SIM_NEW_COMMON_OBJS += \
+	$(SIM_COMMON_HW_OBJS) \
+	$(SIM_HW_SOCKSER)
+
+AM_MAKEFLAGS += SIM_HW_DEVICES_="$(SIM_HW_DEVICES)"
+endif
+
 LIBIBERTY_LIB = ../libiberty/libiberty.a
 BFD_LIB = ../bfd/libbfd.la
 OPCODES_LIB = ../opcodes/libopcodes.la
-- 
2.39.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] sim: build: hoist lists of hw devices up
  2022-12-21  5:33 [PATCH 1/3] sim: build: hoist lists of common objects up Mike Frysinger
@ 2022-12-21  5:33 ` Mike Frysinger
  2022-12-21  5:33 ` [PATCH 3/3] sim: hw-config.h: move generation to top-level Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2022-12-21  5:33 UTC (permalink / raw)
  To: gdb-patches

We need these in the top-level to generate libsim.a, but also in the
subdirs to generate hw-config.h.  Move it to the local.mk, and pass
it down when running recursive make.  This avoids duplication, and
makes it available to both.  We can simplify this once we move the
various steps up to the top-level too.
---
 sim/Makefile.in           | 198 +++++++++++++++++++++++---------------
 sim/bfin/Makefile.in      |  35 +------
 sim/bfin/local.mk         |  34 +++++++
 sim/common/Make-common.in |   2 +-
 sim/cris/Makefile.in      |   6 +-
 sim/cris/local.mk         |   3 +
 sim/lm32/Makefile.in      |   6 +-
 sim/lm32/local.mk         |   3 +
 sim/m32r/Makefile.in      |   6 +-
 sim/m32r/local.mk         |   3 +
 sim/m68hc11/Makefile.in   |   4 +-
 sim/m68hc11/local.mk      |   3 +
 sim/mips/Makefile.in      |   4 +-
 sim/mips/local.mk         |   3 +
 sim/mn10300/Makefile.in   |   4 +-
 sim/mn10300/local.mk      |   3 +
 16 files changed, 190 insertions(+), 127 deletions(-)

diff --git a/sim/bfin/Makefile.in b/sim/bfin/Makefile.in
index 0655a06d5f2a..5d8a8a6386c5 100644
--- a/sim/bfin/Makefile.in
+++ b/sim/bfin/Makefile.in
@@ -17,6 +17,8 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
+arch = bfin
+
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
 	bfin-sim.o \
@@ -26,39 +28,6 @@ SIM_OBJS = \
 	machs.o \
 	sim-resume.o
 
-SIM_EXTRA_HW_DEVICES = \
-	bfin_cec \
-	bfin_ctimer \
-	bfin_dma \
-	bfin_dmac \
-	bfin_ebiu_amc \
-	bfin_ebiu_ddrc \
-	bfin_ebiu_sdc \
-	bfin_emac \
-	bfin_eppi \
-	bfin_evt \
-	bfin_gpio \
-	bfin_gpio2 \
-	bfin_gptimer \
-	bfin_jtag \
-	bfin_mmu \
-	bfin_nfc \
-	bfin_otp \
-	bfin_pfmon \
-	bfin_pint \
-	bfin_pll \
-	bfin_ppi \
-	bfin_rtc \
-	bfin_sic \
-	bfin_spi \
-	bfin_trace \
-	bfin_twi \
-	bfin_uart \
-	bfin_uart2 \
-	bfin_wdog \
-	bfin_wp \
-	eth_phy
-
 SIM_EXTRA_CFLAGS = $(SDL_CFLAGS)
 
 ## COMMON_POST_CONFIG_FRAG
diff --git a/sim/bfin/local.mk b/sim/bfin/local.mk
index 956b3aec30da..cab9e7966986 100644
--- a/sim/bfin/local.mk
+++ b/sim/bfin/local.mk
@@ -24,6 +24,40 @@
 
 noinst_PROGRAMS += %D%/run
 
+%C%_SIM_EXTRA_HW_DEVICES = \
+	bfin_cec \
+	bfin_ctimer \
+	bfin_dma \
+	bfin_dmac \
+	bfin_ebiu_amc \
+	bfin_ebiu_ddrc \
+	bfin_ebiu_sdc \
+	bfin_emac \
+	bfin_eppi \
+	bfin_evt \
+	bfin_gpio \
+	bfin_gpio2 \
+	bfin_gptimer \
+	bfin_jtag \
+	bfin_mmu \
+	bfin_nfc \
+	bfin_otp \
+	bfin_pfmon \
+	bfin_pint \
+	bfin_pll \
+	bfin_ppi \
+	bfin_rtc \
+	bfin_sic \
+	bfin_spi \
+	bfin_trace \
+	bfin_twi \
+	bfin_uart \
+	bfin_uart2 \
+	bfin_wdog \
+	bfin_wp \
+	eth_phy
+AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
+
 %D%/linux-fixed-code.h: @MAINT@ $(srcdir)/%D%/linux-fixed-code.s %D%/local.mk %D%/$(am__dirstamp)
 	$(AM_V_GEN)$(AS_FOR_TARGET_BFIN) $(srcdir)/%D%/linux-fixed-code.s -o %D%/linux-fixed-code.o
 	$(AM_V_at)(\
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 684d7d847ab0..ff4e17102024 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -136,7 +136,7 @@ BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH)
 
 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS)
 
-SIM_HW_DEVICES = $(SIM_HW_DEVICES_) $(SIM_EXTRA_HW_DEVICES)
+SIM_HW_DEVICES = $(SIM_HW_DEVICES_) $($(arch)_SIM_EXTRA_HW_DEVICES)
 SIM_NEW_COMMON_OBJS = $(SIM_NEW_COMMON_OBJS_) $(SIM_HW_OBJS)
 
 LIBIBERTY_LIB = ../../libiberty/libiberty.a
diff --git a/sim/cris/Makefile.in b/sim/cris/Makefile.in
index 3474eb9a827b..4242b17c756e 100644
--- a/sim/cris/Makefile.in
+++ b/sim/cris/Makefile.in
@@ -19,6 +19,8 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
+arch = cris
+
 CRISV10F_OBJS = crisv10f.o cpuv10.o decodev10.o modelv10.o mloopv10f.o
 CRISV32F_OBJS = crisv32f.o cpuv32.o decodev32.o modelv32.o mloopv32f.o
 
@@ -31,14 +33,10 @@ SIM_OBJS = \
 	$(CRISV32F_OBJS) \
 	traps.o
 
-SIM_EXTRA_HW_DEVICES = rv cris cris_900000xx
-
 SIM_EXTRA_CLEAN = cris-clean
 
 ## COMMON_POST_CONFIG_FRAG
 
-arch = cris
-
 cris-clean:
 	-rm -f stamp-arch
 	-rm -f tmp-*
diff --git a/sim/cris/local.mk b/sim/cris/local.mk
index 0a3423c33897..826d6de0be43 100644
--- a/sim/cris/local.mk
+++ b/sim/cris/local.mk
@@ -24,6 +24,9 @@
 
 noinst_PROGRAMS += %D%/run
 
+%C%_SIM_EXTRA_HW_DEVICES = rv cris cris_900000xx
+AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
+
 ## rvdummy is just used for testing -- it runs on the same host as `run`.
 ## It does nothing if --enable-sim-hardware isn't active.
 %C%_rvdummy_SOURCES = %D%/rvdummy.c
diff --git a/sim/lm32/Makefile.in b/sim/lm32/Makefile.in
index 5d78e36bf6bb..ea6601fab067 100644
--- a/sim/lm32/Makefile.in
+++ b/sim/lm32/Makefile.in
@@ -3,6 +3,8 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
+arch = lm32
+
 # List of object files, less common parts.
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -12,14 +14,10 @@ SIM_OBJS = \
         cpu.o decode.o sem.o model.o mloop.o \
         lm32.o traps.o user.o 
 
-SIM_EXTRA_HW_DEVICES = lm32cpu lm32timer lm32uart
-
 SIM_EXTRA_CLEAN = lm32-clean
 
 ## COMMON_POST_CONFIG_FRAG
 
-arch = lm32 
-
 lm32-clean:
 	rm -f stamp-arch stamp-cpu 
 	rm -f tmp-*
diff --git a/sim/lm32/local.mk b/sim/lm32/local.mk
index 7add85ac98b7..437ec094e9c4 100644
--- a/sim/lm32/local.mk
+++ b/sim/lm32/local.mk
@@ -24,6 +24,9 @@
 
 noinst_PROGRAMS += %D%/run
 
+%C%_SIM_EXTRA_HW_DEVICES = lm32cpu lm32timer lm32uart
+AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
+
 %C%_BUILD_OUTPUTS = \
 	%D%/eng.h \
 	%D%/mloop.c \
diff --git a/sim/m32r/Makefile.in b/sim/m32r/Makefile.in
index 6a0e2e5fcf5e..97afd6e03a37 100644
--- a/sim/m32r/Makefile.in
+++ b/sim/m32r/Makefile.in
@@ -19,6 +19,8 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
+arch = m32r
+
 M32R_OBJS = m32r.o cpu.o decode.o sem.o model.o mloop.o
 M32RX_OBJS = m32rx.o cpux.o decodex.o modelx.o mloopx.o
 M32R2_OBJS = m32r2.o cpu2.o decode2.o model2.o mloop2.o
@@ -33,8 +35,6 @@ SIM_OBJS = \
 	$(M32R2_OBJS) \
 	traps.o
 
-SIM_EXTRA_HW_DEVICES = m32r_cache m32r_uart
-
 SIM_EXTRA_CLEAN = m32r-clean
 
 # Some modules don't build cleanly yet.
@@ -42,8 +42,6 @@ cpu.o cpu2.o cpux.o m32r.o m32r2.o m32rx.o mloop.o mloop2.o mloopx.o sem.o sim-i
 
 ## COMMON_POST_CONFIG_FRAG
 
-arch = m32r
-
 m32r-clean:
 	rm -f stamp-arch stamp-cpu stamp-xcpu stamp-2cpu
 	rm -f tmp-*
diff --git a/sim/m32r/local.mk b/sim/m32r/local.mk
index 51d9d3413d6c..dff09fbf15cd 100644
--- a/sim/m32r/local.mk
+++ b/sim/m32r/local.mk
@@ -24,6 +24,9 @@
 
 noinst_PROGRAMS += %D%/run
 
+%C%_SIM_EXTRA_HW_DEVICES = m32r_cache m32r_uart
+AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
+
 %C%_BUILD_OUTPUTS = \
 	%D%/eng.h \
 	%D%/mloop.c \
diff --git a/sim/m68hc11/Makefile.in b/sim/m68hc11/Makefile.in
index 6b7fcfffb188..c16f5fce2856 100644
--- a/sim/m68hc11/Makefile.in
+++ b/sim/m68hc11/Makefile.in
@@ -17,6 +17,8 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
+arch = m68hc11
+
 M68HC11_OBJS = interp.o m68hc11int.o m68hc12int.o \
 		emulos.o interrupts.o m68hc11_sim.o
 
@@ -24,8 +26,6 @@ SIM_OBJS = $(M68HC11_OBJS) \
 	$(SIM_NEW_COMMON_OBJS) \
 	sim-resume.o
 
-SIM_EXTRA_HW_DEVICES = m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram
-
 # We must use 32-bit addresses to support memory bank switching.
 # The WORD_BITSIZE is normally 16 but must be switched (temporarily)
 # to 32 to avoid a bug in the sim-common which uses 'unsigned_word'
diff --git a/sim/m68hc11/local.mk b/sim/m68hc11/local.mk
index 3cc980bf036a..35555ed9868e 100644
--- a/sim/m68hc11/local.mk
+++ b/sim/m68hc11/local.mk
@@ -24,6 +24,9 @@
 
 noinst_PROGRAMS += %D%/run
 
+%C%_SIM_EXTRA_HW_DEVICES = m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram
+AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
+
 %C%_BUILD_OUTPUTS = \
 	%D%/gencode$(EXEEXT) \
 	%D%/m68hc11int.c \
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 75438be5a183..eadb34697c89 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -3,6 +3,8 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
+arch = mips
+
 # Object files created by various simulator generators.
 
 
@@ -64,8 +66,6 @@ SIM_OBJS = \
 	sim-main.o \
 	sim-resume.o \
 
-SIM_EXTRA_HW_DEVICES = tx3904cpu tx3904irc tx3904tmr tx3904sio
-
 # List of flags to always pass to $(CC).
 SIM_SUBTARGET=@SIM_SUBTARGET@
 SIM_EXTRA_CFLAGS = $(SIM_SUBTARGET)
diff --git a/sim/mips/local.mk b/sim/mips/local.mk
index 8e266e77b36f..159fd2947d47 100644
--- a/sim/mips/local.mk
+++ b/sim/mips/local.mk
@@ -23,3 +23,6 @@
 	$(SIM_COMMON_LIBS)
 
 noinst_PROGRAMS += %D%/run
+
+%C%_SIM_EXTRA_HW_DEVICES = tx3904cpu tx3904irc tx3904tmr tx3904sio
+AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
diff --git a/sim/mn10300/Makefile.in b/sim/mn10300/Makefile.in
index 521f86c644be..0b3ebd5b74e4 100644
--- a/sim/mn10300/Makefile.in
+++ b/sim/mn10300/Makefile.in
@@ -17,6 +17,8 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
+arch = mn10300
+
 MN10300_OBJS = \
 	itable.o semantics.o idecode.o icache.o engine.o irun.o support.o \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -25,8 +27,6 @@ MN10300_OBJS = \
 
 SIM_OBJS = $(MN10300_OBJS) interp.o
 
-SIM_EXTRA_HW_DEVICES = mn103cpu mn103int mn103tim mn103ser mn103iop
-
 # List of extra flags to always pass to $(CC).
 SIM_EXTRA_CFLAGS = \
 	-DPOLL_QUIT_INTERVAL=0x20 \
diff --git a/sim/mn10300/local.mk b/sim/mn10300/local.mk
index 08a3d4dedc47..70b442fe1a0d 100644
--- a/sim/mn10300/local.mk
+++ b/sim/mn10300/local.mk
@@ -24,6 +24,9 @@
 
 noinst_PROGRAMS += %D%/run
 
+%C%_SIM_EXTRA_HW_DEVICES = mn103cpu mn103int mn103tim mn103ser mn103iop
+AM_MAKEFLAGS += %C%_SIM_EXTRA_HW_DEVICES="$(%C%_SIM_EXTRA_HW_DEVICES)"
+
 %C%_BUILT_SRC_FROM_IGEN = \
 	%D%/icache.h \
 	%D%/icache.c \
-- 
2.39.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] sim: hw-config.h: move generation to top-level
  2022-12-21  5:33 [PATCH 1/3] sim: build: hoist lists of common objects up Mike Frysinger
  2022-12-21  5:33 ` [PATCH 2/3] sim: build: hoist lists of hw devices up Mike Frysinger
@ 2022-12-21  5:33 ` Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2022-12-21  5:33 UTC (permalink / raw)
  To: gdb-patches

In order to compile arch objects from the top-level, we need to
generate the hw-config.h header, so move that logic up to the top
level first.
---
 sim/Makefile.in           | 45 ++++++++++++++++++++++++++++-----------
 sim/common/Make-common.in | 18 ----------------
 sim/common/local.mk       | 21 ++++++++++++++++++
 3 files changed, 54 insertions(+), 30 deletions(-)

diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index ff4e17102024..52cc3c926f7f 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -197,7 +197,6 @@ endif
 all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS)
 generated_files = \
 	$(SIM_EXTRA_DEPS) \
-	hw-config.h \
 	modules.c
 
 # Ensure that generated files are created early.  Use order-only
@@ -212,22 +211,6 @@ endif
 # Dependencies.
 -include $(patsubst %.o, $(DEPDIR)/%.Po, $(all_object_files))
 
-# FIXME This is one very simple-minded way of generating the file hw-config.h
-hw-config.h: stamp-hw ; @true
-stamp-hw: Makefile.in $(srccom)/Make-common.in $(config.status) Makefile
-	$(ECHO_STAMP) hw-config.h
-	$(SILENCE) ( \
-	sim_hw="$(SIM_HW_DEVICES)" ; \
-	echo "/* generated by Makefile */" ; \
-	printf "extern const struct hw_descriptor dv_%s_descriptor[];\n" $$sim_hw ; \
-	echo "const struct hw_descriptor * const hw_descriptors[] = {" ; \
-	printf "  dv_%s_descriptor,\n" $$sim_hw ; \
-	echo "  NULL," ; \
-	echo "};" \
-	) > tmp-hw.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-hw.h hw-config.h
-	$(SILENCE) touch $@
-
 test-hw-events: $(srccom)/hw-events.c libsim.a
 	$(ECHO_CCLD) $(LIBTOOL) $(AM_V_lt) --tag=CC --mode=link \
 		$(CC) $(ALL_CFLAGS) -DMAIN -o test-hw-events$(EXEEXT) \
@@ -290,7 +273,6 @@ TAGS: force
 mostlyclean clean: $(SIM_EXTRA_CLEAN)
 	rm -f *.[oa] *~ core \
 		run$(EXEEXT) libsim.a \
-		hw-config.h stamp-hw \
 		modules.c stamp-modules \
 		tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c
 
diff --git a/sim/common/local.mk b/sim/common/local.mk
index bf9b97d04d71..caffca9b02d3 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -110,6 +110,27 @@ SIM_NEW_COMMON_OBJS += \
 AM_MAKEFLAGS += SIM_HW_DEVICES_="$(SIM_HW_DEVICES)"
 endif
 
+# FIXME This is one very simple-minded way of generating the file hw-config.h.
+%/hw-config.h: %/stamp-hw ; @true
+%/stamp-hw: Makefile
+	$(AM_V_GEN)set -e; \
+	( \
+	sim_hw="$(SIM_HW_DEVICES) $($(@D)_SIM_EXTRA_HW_DEVICES)" ; \
+	echo "/* generated by Makefile */" ; \
+	printf "extern const struct hw_descriptor dv_%s_descriptor[];\n" $$sim_hw ; \
+	echo "const struct hw_descriptor * const hw_descriptors[] = {" ; \
+	printf "  dv_%s_descriptor,\n" $$sim_hw ; \
+	echo "  NULL," ; \
+	echo "};" \
+	) > $@.tmp; \
+	$(SHELL) $(srcroot)/move-if-change $@.tmp $(@D)/hw-config.h; \
+	touch $@
+.PRECIOUS: %/stamp-hw
+
+%C%_HW_CONFIG_H_TARGETS = $(patsubst %,%/hw-config.h,$(SIM_ENABLED_ARCHES))
+MOSTLYCLEANFILES += $(%C%_HW_CONFIG_H_TARGETS) $(patsubst %,%/stamp-hw,$(SIM_ENABLED_ARCHES))
+SIM_ALL_RECURSIVE_DEPS += $(%C%_HW_CONFIG_H_TARGETS)
+
 LIBIBERTY_LIB = ../libiberty/libiberty.a
 BFD_LIB = ../bfd/libbfd.la
 OPCODES_LIB = ../opcodes/libopcodes.la
-- 
2.39.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-21  5:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21  5:33 [PATCH 1/3] sim: build: hoist lists of common objects up Mike Frysinger
2022-12-21  5:33 ` [PATCH 2/3] sim: build: hoist lists of hw devices up Mike Frysinger
2022-12-21  5:33 ` [PATCH 3/3] sim: hw-config.h: move generation to top-level Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).