summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-12-03 02:37:16 -0500
committermidipix <writeonce@midipix.org>2016-12-03 11:59:06 -0500
commit39f31e5c1db03fdd506e40ee02b76539ad5493c1 (patch)
tree65bdee42ce78cf7e9d4dcd0f7cdbb47597289ac3 /src
parentfce0180d06c1338ff3a21f55c51a9e655090c9f3 (diff)
downloadslibtool-39f31e5c1db03fdd506e40ee02b76539ad5493c1.tar.bz2
slibtool-39f31e5c1db03fdd506e40ee02b76539ad5493c1.tar.xz
link mode: properly determine whether -L and -ldeplib are needed.
Diffstat (limited to 'src')
-rw-r--r--src/logic/slbt_exec_link.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 553780f..3aa9d2f 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -524,6 +524,7 @@ static int slbt_exec_link_create_dep_file(
char depfile[PATH_MAX];
struct stat st;
int ldepth;
+ int fdyndep;
(void)dctx;
@@ -579,8 +580,23 @@ static int slbt_exec_link_create_dep_file(
reladir[1] = 0;
}
+
+ /* dynamic library dependency? */
+ strcpy(depfile,*parg);
+ mark = depfile + (base - *parg);
+ size = sizeof(depfile) - (base - *parg);
+
+ if ((size_t)snprintf(mark,size,".libs/%s",base)
+ >= size)
+ return SLBT_BUFFER_ERROR(dctx);
+
+ mark = strrchr(mark,'.');
+ strcpy(mark,dctx->cctx->settings.dsoprefix);
+
+ fdyndep = !stat(depfile,&st);
+
/* [-L... as needed] */
- if (!farchive && (base > *parg) && (ectx->ldirdepth >= 0)) {
+ if (fdyndep && (base > *parg) && (ectx->ldirdepth >= 0)) {
if (fputs("-L",ectx->fdeps) < 0) {
fclose(fdeps);
return SLBT_SYSTEM_ERROR(dctx);
@@ -599,7 +615,7 @@ static int slbt_exec_link_create_dep_file(
}
/* -ldeplib */
- if (!farchive) {
+ if (fdyndep) {
*popt = 0;
mark = base;
mark += strlen(dctx->cctx->settings.dsoprefix);