From bc599d93401f9cbe377ce43a497a73c65516633f Mon Sep 17 00:00:00 2001
From: Simon Rose <simon.rose@ess.eu>
Date: Wed, 5 Apr 2023 16:20:20 +0200
Subject: [PATCH] Reverse .substitutions/.templates priority

---
 CHANGELOG.md                      |  2 ++
 require-ess/tools/driver.makefile | 10 +++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3581d885..e4e276d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Bugfixes
 
+* Fixed an issue where .template and .substitutions files with the same name would build incorrectly
+
 ### Other changes
 
 * Replaced `tclx` script to expand .dbd files with a python script
diff --git a/require-ess/tools/driver.makefile b/require-ess/tools/driver.makefile
index d650d0f5..25bd11ee 100644
--- a/require-ess/tools/driver.makefile
+++ b/require-ess/tools/driver.makefile
@@ -269,16 +269,16 @@ db_internal: $(COMMON_DIR)
 VPATH += $(dir $(TMPS))
 VPATH += $(dir $(SUBS))
 
-$(COMMON_DIR)/%.db: %.template
-	@printf "Inflating database ... %44s >>> %40s \n" "$^" "$@"
-	$(QUIET)$(MSI) -D $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^ > $(COMMON_DIR)/$(notdir $(basename $@).db).d
-	$(QUIET)$(MSI)    $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^
-
 $(COMMON_DIR)/%.db: %.substitutions
 	@printf "Inflating database ... %44s >>> %40s \n" "$^" "$@"
 	$(QUIET)$(MSI) -D $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) -S $^ > $(COMMON_DIR)/$(notdir $(basename $@).db).d
 	$(QUIET)$(MSI)    $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) -S $^
 
+$(COMMON_DIR)/%.db: %.template
+	@printf "Inflating database ... %44s >>> %40s \n" "$^" "$@"
+	$(QUIET)$(MSI) -D $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^ > $(COMMON_DIR)/$(notdir $(basename $@).db).d
+	$(QUIET)$(MSI)    $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^
+
 
 install build debug::
 	@echo "MAKING EPICS VERSION ${EPICSVERSION}"
-- 
GitLab