diff options
author | midipix <writeonce@midipix.org> | 2016-09-27 23:42:06 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-09-27 23:42:06 -0400 |
commit | 1a80187272e31b04b09f663bd837b7c584442925 (patch) | |
tree | aa28f338953eb34cbc7f46fd801aa035049ecd07 /src/logic | |
parent | e3d03d442aad186e5d00e278fb7d80fcaba42c97 (diff) | |
download | slibtool-1a80187272e31b04b09f663bd837b7c584442925.tar.bz2 slibtool-1a80187272e31b04b09f663bd837b7c584442925.tar.xz |
link mode: properly handle indirect dependencies of .a archives.
Diffstat (limited to 'src/logic')
-rw-r--r-- | src/logic/slbt_exec_link.c | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 0f35272..bd29ee0 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -556,8 +556,6 @@ static int slbt_exec_link_create_dep_file( plib = popt + 10; } else if (!strncmp(*parg,"-f",2)) { (void)0; - } else if (farchive) { - (void)0; } else if ((popt = strrchr(*parg,'.')) && !strcmp(popt,".la")) { /* import dependency list */ if ((base = strrchr(*parg,'/'))) @@ -582,7 +580,7 @@ static int slbt_exec_link_create_dep_file( } /* [-L... as needed] */ - if ((base > *parg) && (ectx->ldirdepth >= 0)) { + if (!farchive && (base > *parg) && (ectx->ldirdepth >= 0)) { if (fputs("-L",ectx->fdeps) < 0) { fclose(fdeps); return SLBT_SYSTEM_ERROR(dctx); @@ -601,16 +599,18 @@ static int slbt_exec_link_create_dep_file( } /* -ldeplib */ - *popt = 0; - mark = base; - mark += strlen(dctx->cctx->settings.dsoprefix); + if (!farchive) { + *popt = 0; + mark = base; + mark += strlen(dctx->cctx->settings.dsoprefix); - if (fprintf(ectx->fdeps,"-l%s\n",mark) < 0) { - fclose(fdeps); - return SLBT_SYSTEM_ERROR(dctx); - } + if (fprintf(ectx->fdeps,"-l%s\n",mark) < 0) { + fclose(fdeps); + return SLBT_SYSTEM_ERROR(dctx); + } - *popt = '.'; + *popt = '.'; + } /* [open dependency list] */ strcpy(depfile,*parg); @@ -624,15 +624,36 @@ static int slbt_exec_link_create_dep_file( mark = strrchr(mark,'.'); size = sizeof(depfile) - (mark - depfile); - if ((size_t)snprintf(mark,size,".a.slibtool.deps") - >= size) - return SLBT_BUFFER_ERROR(dctx); + if (!farchive) { + if ((size_t)snprintf( + mark,size, + ".%s.slibtool.deps", + dctx->cctx->settings.dsoprefix) + >= size) + return SLBT_BUFFER_ERROR(dctx); + + if (stat(depfile,&st)) { + if (errno == ENOENT) + fdeps = 0; + else + return SLBT_SYSTEM_ERROR(dctx); + } else { + if (!(fdeps = fopen(depfile,"r"))) + return SLBT_SYSTEM_ERROR(dctx); + } + } - if (stat(depfile,&st)) - return SLBT_SYSTEM_ERROR(dctx); + if (farchive || !fdeps) { + if ((size_t)snprintf(mark,size,".a.slibtool.deps") + >= size) + return SLBT_BUFFER_ERROR(dctx); - if (!(fdeps = fopen(depfile,"r"))) - return SLBT_SYSTEM_ERROR(dctx); + if (stat(depfile,&st)) + return SLBT_SYSTEM_ERROR(dctx); + + if (!(fdeps = fopen(depfile,"r"))) + return SLBT_SYSTEM_ERROR(dctx); + } /* [-l... as needed] */ deplib = st.st_size |