From d55a465814bb3d7ec429f85b36c26d5862ba7e48 Mon Sep 17 00:00:00 2001
From: midipix <writeonce@midipix.org>
Date: Tue, 4 May 2021 13:56:44 +0000
Subject: link mode: static-only libfoo.la: account for non-default
 shared-object suffix.

---
 src/logic/slbt_exec_link.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

(limited to 'src')

diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index c8586c5..f61c5db 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -1935,6 +1935,36 @@ int slbt_exec_link(
 			return SLBT_NESTED_ERROR(dctx);
 		}
 
+	/* static-only libfoo.la */
+	if (fstaticonly && dot && !strcmp(dot,".la")) {
+		const struct slbt_flavor_settings * dflavor;
+
+		if (slbt_get_flavor_settings("default",&dflavor) < 0)
+			return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_LINK_FLOW);
+
+		if (strcmp(dctx->cctx->settings.dsosuffix,dflavor->dsosuffix)) {
+			strcpy(target,ectx->lafilename);
+			sprintf(lnkname,"%s.shrext%s",
+				ectx->lafilename,
+				dctx->cctx->settings.dsosuffix);
+
+			if (slbt_create_symlink(
+					dctx,ectx,
+					target,lnkname,
+					SLBT_SYMLINK_DEFAULT))
+				return SLBT_NESTED_ERROR(dctx);
+
+			strcpy(target,lnkname);
+			sprintf(lnkname,"%s.shrext",ectx->lafilename);
+
+			if (slbt_create_symlink(
+					dctx,ectx,
+					target,lnkname,
+					SLBT_SYMLINK_DEFAULT))
+				return SLBT_NESTED_ERROR(dctx);
+		}
+	}
+
 	/* -all-static library */
 	if (fstaticonly && dctx->cctx->libname)
 		if (slbt_create_symlink(
-- 
cgit v1.2.3