[PATCH/submitted,2/3] sim: ppc: hoist hw.[ch] creation to top-level

Message ID 20240102072508.10504-2-vapier@gentoo.org
State New
Headers
Series [PATCH/submitted,1/3] sim: ppc: hoist igen execution to top-level |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Mike Frysinger Jan. 2, 2024, 7:25 a.m. UTC
  ---
 sim/Makefile.in     | 52 ++++++++++++++++++++++++++++++++++-----------
 sim/ppc/Makefile.in | 37 ++------------------------------
 sim/ppc/local.mk    | 43 +++++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+), 47 deletions(-)
  

Patch

diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in
index 5717ddc885ed..ed3185f399d4 100644
--- a/sim/ppc/Makefile.in
+++ b/sim/ppc/Makefile.in
@@ -362,8 +362,7 @@  INLINE = \
 	inline.c
 
 BUILT_SRC_WO_CONFIG = \
-	pk.h \
-	hw.h hw.c
+	pk.h
 
 BUILT_SRC = \
 	$(BUILT_SRC_WO_CONFIG)
@@ -456,7 +455,7 @@  PACKAGE_SRC = pk_disklabel.c
 PACKAGE_OBJ = $(PACKAGE_SRC:.c=.o)
 
 
-$(TARGETLIB): tmp-hw defines.h $(LIB_OBJ) $(GDB_OBJ)
+$(TARGETLIB): defines.h $(LIB_OBJ) $(GDB_OBJ)
 	$(ECHO_AR) $(AR) $(AR_FLAGS) $(TARGETLIB) $(LIB_OBJ) $(GDB_OBJ)
 	$(ECHO_RANLIB) $(RANLIB) $(TARGETLIB)
 
@@ -529,38 +528,6 @@  sim-fpu.o: $(srcdir)/../common/sim-fpu.c
 options.o: options.c $(CPU_H) $(OPTIONS_H) $(DEFINES_H) $(BASICS_H) $(IDECODE_H) $(INLINE) $(LIB_SRC) $(BUILT_SRC) ../config.status Makefile
 	$(ECHO_CC) $(CC) -c $(STD_CFLAGS) '-DOPCODE_RULES="@sim_ppc_opcode@"' '-DIGEN_FLAGS="$(ppc_IGEN_FLAGS)"' $(srcdir)/options.c
 
-# real hardware
-hw.c hw.h: tmp-hw; @true
-tmp-hw: Makefile $(HW_SRC) $(srcroot)/move-if-change
-	$(ECHO_GEN)# The first for loop is to remove duplicates.
-	$(SILENCE) f=""; \
-	for i in $(HW_SRC) ; do \
-	  case " $$f " in \
-	    *" $$i "*) ;; \
-	    *) f="$$f $$i" ;; \
-	  esac ; \
-	done ; \
-	for hw in $$f ; do echo $$hw ; done \
-	| sed -e 's/^.*\(hw_.*\)\.c/\1/' \
-		-e 's/^/extern const device_descriptor /' \
-		-e 's/$$/_device_descriptor\[\];/' \
-		> tmp-hw.h
-	$(SILENCE) f=""; \
-	for i in $(HW_SRC) ; do \
-	  case " $$f " in \
-	    *" $$i "*) ;; \
-	    *) f="$$f $$i" ;; \
-	  esac ; \
-	done ; \
-	for hw in $$f ; do echo $$hw ; done \
-	| sed -e 's/^.*\(hw_.*\)\.c/\1/' \
-		-e 's/^/    /' \
-		-e 's/$$/_device_descriptor,/' \
-		> tmp-hw.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-hw.h hw.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-hw.c hw.c
-	$(SILENCE) touch $@
-
 hw_cpu.o: hw_cpu.c $(DEVICE_TABLE_H) $(HW_CPU_H) $(INTERRUPTS_H) $(CPU_H)
 hw_com.o: hw_com.c $(DEVICE_TABLE_H)
 hw_core.o: hw_core.c $(DEVICE_TABLE_H) $(COREFILE_H)
diff --git a/sim/ppc/local.mk b/sim/ppc/local.mk
index 8b5a16567fe7..7d4ea357c30d 100644
--- a/sim/ppc/local.mk
+++ b/sim/ppc/local.mk
@@ -177,5 +177,48 @@  MOSTLYCLEANFILES += $(%C%_IGEN_TOOLS) %D%/libigen.a
 
 IGEN_OPCODE_RULES = @sim_ppc_opcode@
 
+## Real hardware.
+## NB: The first for loop is to remove duplicates.
+%C%_HW_SRC = $(sim_ppc_hw_src:%=%D%/%)
+%D%/hw.c %D%/hw.h: %D%/stamp-hw ; @true
+%D%/stamp-hw: Makefile $(%C%_HW_SRC) $(srcroot)/move-if-change
+	$(AM_V_GEN)\
+	f=""; \
+	for i in $(%C%_HW_SRC) ; do \
+	  case " $$f " in \
+	    *" $$i "*) ;; \
+	    *) f="$$f $$i" ;; \
+	  esac ; \
+	done ; \
+	for hw in $$f ; do echo $$hw ; done \
+	| sed -e 's/^.*\(hw_.*\)\.c/\1/' \
+		-e 's/^/extern const device_descriptor /' \
+		-e 's/$$/_device_descriptor\[\];/' \
+		> %D%/hw.hin; \
+	f=""; \
+	for i in $(%C%_HW_SRC) ; do \
+	  case " $$f " in \
+	    *" $$i "*) ;; \
+	    *) f="$$f $$i" ;; \
+	  esac ; \
+	done ; \
+	for hw in $$f ; do echo $$hw ; done \
+	| sed -e 's/^.*\(hw_.*\)\.c/\1/' \
+		-e 's/^/    /' \
+		-e 's/$$/_device_descriptor,/' \
+		> %D%/hw.cin
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/hw.hin %D%/hw.h
+	$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/hw.cin %D%/hw.c
+	$(AM_V_at)touch $@
+
+BUILT_SOURCES += \
+	%D%/hw.h
+%C%_BUILD_OUTPUTS += \
+	%D%/hw.c \
+	%D%/hw.h \
+	%D%/stamp-hw
+SIM_ALL_RECURSIVE_DEPS += %D%/stamp-hw
+%D%/hw.c %D%/hw.h: %D%/stamp-igen
+
 %C%docdir = $(docdir)/%C%
 %C%doc_DATA = %D%/BUGS %D%/INSTALL %D%/README %D%/RUN