From 9b0aed8c4dbbe32556dbea5611bffff0f904b067 Mon Sep 17 00:00:00 2001
From: Ben Avison <bavison@riscosopen.org>
Date: Thu, 10 Dec 2020 15:01:29 +0000
Subject: [PATCH] Support links for extension-less files in subdirectories

This only applies to cross-compilation builds. The `make links` rules don't
know a pre-determined list of subdirectories that need to be converted into
filename extensions. Instead, files that should have no filename extension
are usually simply identified by the absence of a `/` in their specification
in `SOURCES_TO_SYMLINK`. However, this is insufficient to handle some rarer
cases, such as a `Makefile` within a `Test` subdirectory.

To handle this, we introduce explicit support for specifying such files in
`SOURCES_TO_SYMLINK`, using a double slash where there would otherwise be a
filetype subdirectory name, such as `Test//Makefile`. (Conveniently, this is
also valid Posix filename syntax anyway.) The way this is achieved is to
tweak the regular expressions to require the directory and leafnames between
slashes to be at least one character long.

Version 7.58. Tagged as 'BuildSys-7_58'
---
 GNUmakefiles/AAsmModule |  8 ++++----
 GNUmakefiles/CApp       |  6 +++---
 GNUmakefiles/CLibrary   |  6 +++---
 GNUmakefiles/CModule    |  6 +++---
 VersionNum              | 20 ++++++++++----------
 5 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/GNUmakefiles/AAsmModule b/GNUmakefiles/AAsmModule
index 4f554f1..08ebca4 100644
--- a/GNUmakefiles/AAsmModule
+++ b/GNUmakefiles/AAsmModule
@@ -151,16 +151,16 @@ clean::
 	@echo ${COMPONENT}: cleaned
 else
 ifneq (,${SYMLINK_EXT_FIRST})
-SYMLINK_SED_PATTERN = 's,^\([^/]*\)/\(.*\),\2.\1,'
+SYMLINK_SED_PATTERN = 's,^\([^/]\+\)/\(.\+\),\2.\1,'
 else
-SYMLINK_SED_PATTERN = 's,\([^/]*\)/\([^/]*\)$$,\2.\1,'
+SYMLINK_SED_PATTERN = 's,\([^/]\+\)/\([^/]\+\)$$,\2.\1,'
 endif
 all debug export export_hdrs export_libs gpa_debug install install_rom rom_link links resources rom standalone: ${SYMLINK_DEPEND}
 	$(foreach linksource,${SOURCES_TO_SYMLINK}, \
 		$(shell \
 			linkdest=`echo ${linksource} | sed -e ${SYMLINK_SED_PATTERN} -e 's,^,objs/,'`; \
-			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
-			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
+			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]\+$$,,'`; \
+			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]\+,..,g'`; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || mkdir -p $$linkdestdir; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || ln -s $$linkbackpath/${linksource} $$linkdest; \
 		 ) \
diff --git a/GNUmakefiles/CApp b/GNUmakefiles/CApp
index 070e6f9..7527cbb 100644
--- a/GNUmakefiles/CApp
+++ b/GNUmakefiles/CApp
@@ -139,9 +139,9 @@ else
 all install debug resources rom rom_link links: ${SYMLINK_DEPEND}
 	$(foreach linksource,${SOURCES_TO_SYMLINK}, \
 		$(shell \
-			linkdest=`echo ${linksource} | sed -e 's,\([^/]*\)/\([^/]*\)$$,\2.\1,' -e 's,^,objs/,'`; \
-			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
-			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
+			linkdest=`echo ${linksource} | sed -e 's,\([^/]\+\)/\([^/]\+\)$$,\2.\1,' -e 's,^,objs/,'`; \
+			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]\+$$,,'`; \
+			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]\+,..,g'`; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || mkdir -p $$linkdestdir; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || ln -s $$linkbackpath/${linksource} $$linkdest; \
 		 ) \
diff --git a/GNUmakefiles/CLibrary b/GNUmakefiles/CLibrary
index a980b9c..c22be4d 100644
--- a/GNUmakefiles/CLibrary
+++ b/GNUmakefiles/CLibrary
@@ -135,9 +135,9 @@ else
 all_libs export export_hdrs export_libs links: ${SYMLINK_DEPEND}
 	$(foreach linksource,${SOURCES_TO_SYMLINK}, \
 		$(shell \
-			linkdest=`echo ${linksource} | sed -e 's,\([^/]*\)/\([^/]*\)$$,\2.\1,' -e 's,^,objs/,'`; \
-			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
-			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
+			linkdest=`echo ${linksource} | sed -e 's,\([^/]\+\)/\([^/]\+\)$$,\2.\1,' -e 's,^,objs/,'`; \
+			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]\+$$,,'`; \
+			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]\+,..,g'`; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || mkdir -p $$linkdestdir; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || ln -s $$linkbackpath/${linksource} $$linkdest; \
 		 ) \
diff --git a/GNUmakefiles/CModule b/GNUmakefiles/CModule
index e1852a4..302a564 100644
--- a/GNUmakefiles/CModule
+++ b/GNUmakefiles/CModule
@@ -234,9 +234,9 @@ else
 all export export_hdrs export_libs resources rom rom_link standalone install debug gpa_debug prepro links: ${SYMLINK_DEPEND}
 	$(foreach linksource,${SOURCES_TO_SYMLINK}, \
 		$(shell \
-			linkdest=`echo ${linksource} | sed -e 's,\([^/]*\)/\([^/]*\)$$,\2.\1,' -e 's,^,objs/,'`; \
-			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
-			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
+			linkdest=`echo ${linksource} | sed -e 's,\([^/]\+\)/\([^/]\+\)$$,\2.\1,' -e 's,^,objs/,'`; \
+			linkdestdir=`echo $$linkdest | sed -e 's,/[^/]\+$$,,'`; \
+			linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]\+,..,g'`; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || mkdir -p $$linkdestdir; \
 			[ -d ${linksource} ] || [ -L $$linkdest ] || ln -s $$linkbackpath/${linksource} $$linkdest; \
 		 ) \
diff --git a/VersionNum b/VersionNum
index 0333ad5..96edb4a 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,21 +1,21 @@
-/* (7.57)
+/* (7.58)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  *
  */
-#define Module_MajorVersion_CMHG        7.57
+#define Module_MajorVersion_CMHG        7.58
 #define Module_MinorVersion_CMHG
-#define Module_Date_CMHG                19 Apr 2021
+#define Module_Date_CMHG                15 May 2021
 
-#define Module_MajorVersion             "7.57"
-#define Module_Version                  757
+#define Module_MajorVersion             "7.58"
+#define Module_Version                  758
 #define Module_MinorVersion             ""
-#define Module_Date                     "19 Apr 2021"
+#define Module_Date                     "15 May 2021"
 
-#define Module_ApplicationDate          "19-Apr-21"
+#define Module_ApplicationDate          "15-May-21"
 
 #define Module_ComponentName            "BuildSys"
 
-#define Module_FullVersion              "7.57"
-#define Module_HelpVersion              "7.57 (19 Apr 2021)"
-#define Module_LibraryVersionInfo       "7:57"
+#define Module_FullVersion              "7.58"
+#define Module_HelpVersion              "7.58 (15 May 2021)"
+#define Module_LibraryVersionInfo       "7:58"
-- 
GitLab