sim: build: add a proper var for enabled arches

Message ID 20221107145154.20302-1-vapier@gentoo.org
State Committed
Headers
Series sim: build: add a proper var for enabled arches |

Commit Message

Mike Frysinger Nov. 7, 2022, 2:51 p.m. UTC
  The install code was using $SUBDIRS to track all enabled arches.  This
works, but isn't great if we want to add a subdir that isn't an arch
port, or as we merge the subdirs into the top-level.  Create a new var
explicitly to track the list of enabled arches instead.
---
 sim/Makefile.am  |  26 +++++-------
 sim/Makefile.in  |  27 ++++++-------
 sim/configure    | 102 ++++++++++++++++++++++++++++++++---------------
 sim/configure.ac |   6 +++
 4 files changed, 98 insertions(+), 63 deletions(-)
  

Patch

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 7cdcc6013077..7197590035f6 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -198,29 +198,25 @@  all-recursive: $(SIM_ALL_RECURSIVE_DEPS)
 install-data-local: installdirs $(SIM_INSTALL_DATA_LOCAL_DEPS)
 	$(AM_V_at)$(MKDIR_P) $(DESTDIR)$(libdir)
 	lib=`echo sim | sed '$(program_transform_name)'`; \
-	for d in $(SUBDIRS); do \
-		if [ -e $$d/run$(EXEEXT) ]; then \
-			n="$$lib"; \
-			[ "$(SIM_PRIMARY_TARGET)" = "$$d" ] || n="$$n-$$d"; \
-			n="lib$$n.a"; \
-			$(INSTALL_DATA) $$d/libsim.a $(DESTDIR)$(libdir)/$$n || exit 1; \
-		fi; \
+	for d in $(SIM_ENABLED_ARCHES); do \
+		n="$$lib"; \
+		[ "$(SIM_PRIMARY_TARGET)" = "$$d" ] || n="$$n-$$d"; \
+		n="lib$$n.a"; \
+		$(INSTALL_DATA) $$d/libsim.a $(DESTDIR)$(libdir)/$$n || exit 1; \
 	done
 
 install-exec-local: installdirs $(SIM_INSTALL_EXEC_LOCAL_DEPS)
 	$(AM_V_at)$(MKDIR_P) $(DESTDIR)$(bindir)
 	run=`echo run | sed '$(program_transform_name)'`; \
-	for d in $(SUBDIRS); do \
-		if [ -e $$d/run$(EXEEXT) ]; then \
-			n="$$run"; \
-			[ "$(SIM_PRIMARY_TARGET)" = "$$d" ] || n="$$n-$$d"; \
-			$(LIBTOOL) --mode=install \
-				$(INSTALL_PROGRAM) $$d/run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT) || exit 1; \
-		fi; \
+	for d in $(SIM_ENABLED_ARCHES); do \
+		n="$$run"; \
+		[ "$(SIM_PRIMARY_TARGET)" = "$$d" ] || n="$$n-$$d"; \
+		$(LIBTOOL) --mode=install \
+			$(INSTALL_PROGRAM) $$d/run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT) || exit 1; \
 	done
 
 uninstall-local: $(SIM_UNINSTALL_LOCAL_DEPS)
 	rm -f $(DESTDIR)$(bindir)/run $(DESTDIR)$(libdir)/libsim.a
-	for d in $(SUBDIRS); do \
+	for d in $(SIM_ENABLED_ARCHES); do \
 		rm -f $(DESTDIR)$(bindir)/run-$$d $(DESTDIR)$(libdir)/libsim-$$d.a; \
 	done
diff --git a/sim/configure.ac b/sim/configure.ac
index 135aa2198cfd..3c3743779229 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -48,9 +48,14 @@  dnl used when installing files to see if they need to be suffixed.
 SIM_PRIMARY_TARGET=
 AC_SUBST(SIM_PRIMARY_TARGET)
 
+dnl Directories that we need to recurse into (i.e. add to $SUBDIRS).
 SIM_SUBDIRS=
 AC_SUBST(SIM_SUBDIRS)
 
+dnl List of enabled arch backends.
+SIM_ENABLED_ARCHES=
+AC_SUBST(SIM_ENABLED_ARCHES)
+
 dnl Used by common/Make-common.in to see which configure script created it.
 SIM_COMMON_BUILD_TRUE=
 SIM_COMMON_BUILD_FALSE='#'
@@ -62,6 +67,7 @@  dnl Build a particular arch subdir.
 dnl arg[1] is the arch subdir name.
 dnl arg[2] is whether the arch has a dedicated configure script.
 m4_define([SIM_BUILD_TARGET], [dnl
+  AS_VAR_APPEND([SIM_ENABLED_ARCHES], [" $1"])
   m4_if($2, [true], [dnl
     AC_CONFIG_SUBDIRS($1)
   ], [dnl