From 9c5ba5eba6c7c5274d7e9e6203ee5aad2fb438fb Mon Sep 17 00:00:00 2001
From: midipix <writeonce@midipix.org>
Date: Fri, 16 Apr 2021 09:32:49 +0000
Subject: link mode: legacy libtool compatibility: support linking against
 -module libs.

---
 src/logic/slbt_exec_link.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 3836f14..ea5dccf 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -583,15 +583,23 @@ static int slbt_exec_link_adjust_argument_vector(
 					return ret;
 				}
 
-				*aarg++ = *carg++;
-				*aarg++ = ++mark;
+				dlen = strlen(dctx->cctx->settings.dsoprefix);
+
+				/* -module? (todo: non-portable usage, display warning) */
+				if (strncmp(++slash,dctx->cctx->settings.dsoprefix,dlen)) {
+					*--slash = '/';
+					strcpy(*carg,arg);
+					*aarg++ = *carg++;
+				} else {
+					*aarg++ = *carg++;
+					*aarg++ = ++mark;
 
-				++slash;
-				slash += strlen(dctx->cctx->settings.dsoprefix);
+					slash += dlen;
 
-				sprintf(mark,"-l%s",slash);
-				dot  = strrchr(mark,'.');
-				*dot = 0;
+					sprintf(mark,"-l%s",slash);
+					dot  = strrchr(mark,'.');
+					*dot = 0;
+				}
 			} else {
 				*aarg++ = *carg++;
 			}
-- 
cgit v1.2.3