diff --git a/require-ess/tools/driver.makefile b/require-ess/tools/driver.makefile
index 08c12c1ab20b5f3a08f20da88830c24e37f519f4..b27ae8fa17fa7da2e3d8990a1cc68ad9a010b2ab 100644
--- a/require-ess/tools/driver.makefile
+++ b/require-ess/tools/driver.makefile
@@ -424,6 +424,11 @@ ifeq ($(filter O.%,$(notdir ${CURDIR})),)
 # Target architecture defined.
 # Still in source directory, third run.
 
+# Add sources for specific epics types or architectures.
+ARCH_PARTS = ${T_A} $(subst -, ,${T_A}) ${OS_CLASS}
+VAR_EXTENSIONS = ${EPICSVERSION} ${ARCH_PARTS} ${ARCH_PARTS:%=${EPICSVERSION}_%}
+export VAR_EXTENSIONS
+
 # First, sort out all of the dependencies. This is done recursively using tools from https://github.com/markpiffer/gmtt.git
 space := $(strip) $(strip)#
 comma := ,#
@@ -452,7 +457,9 @@ define fetch_module_versions
   endif
 endef
 $(foreach m,$(patsubst %_DEP_VERSION,%,$(filter %_DEP_VERSION,$(.VARIABLES))),$(eval $(call fetch_module_versions,$m)))
-$(foreach m,$(patsubst %_DEP_VERSION_$(T_A),%,$(filter %_DEP_VERSION_$(T_A),$(.VARIABLES))),$(eval $(call fetch_module_versions,$m,_$(T_A))))
+$(foreach x,$(VAR_EXTENSIONS),\
+  $(foreach m,$(patsubst %_DEP_VERSION_$(x),%,$(filter %_DEP_VERSION_$(x),$(.VARIABLES))),$(eval $(call fetch_module_versions,$m,_$(x))))\
+)
 
 # Fetches the data from .dep files to be parsed by the above
 define fetch_deps
@@ -512,11 +519,6 @@ install build debug:: O.${EPICSVERSION}_${T_A}
 
 endif
 
-# Add sources for specific epics types or architectures.
-ARCH_PARTS = ${T_A} $(subst -, ,${T_A}) ${OS_CLASS}
-VAR_EXTENSIONS = ${EPICSVERSION} ${ARCH_PARTS} ${ARCH_PARTS:%=${EPICSVERSION}_%}
-export VAR_EXTENSIONS
-
 REQ += ${REQUIRED} $(foreach x, ${VAR_EXTENSIONS}, ${REQUIRED_$x})
 export REQ