diff options
author | midipix <writeonce@midipix.org> | 2016-09-13 19:20:44 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-09-13 19:20:44 -0400 |
commit | 7f35de9733d3c82eadd5eb17028803a602c3c1d8 (patch) | |
tree | fc5a3166a943e44723213fa4a01965d5432718e9 | |
parent | 1ed71a9b2fff4dfc73432b94e3049b92d16d1717 (diff) | |
download | slibtool-7f35de9733d3c82eadd5eb17028803a602c3c1d8.tar.bz2 slibtool-7f35de9733d3c82eadd5eb17028803a602c3c1d8.tar.xz |
link mode: account for directory depth when generating .deps for .la wrapper.
-rw-r--r-- | include/slibtool/slibtool.h | 1 | ||||
-rw-r--r-- | src/logic/slbt_exec_ctx.c | 23 | ||||
-rw-r--r-- | src/logic/slbt_exec_link.c | 16 |
3 files changed, 38 insertions, 2 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index c476cda..c57494c 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -132,6 +132,7 @@ struct slbt_exec_ctx { FILE * fwrapper; FILE * fdeps; char * csrc; + int ldirdepth; char * ldirname; char * lbasename; char * lobjname; diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c index f1b6b75..6b66f12 100644 --- a/src/logic/slbt_exec_ctx.c +++ b/src/logic/slbt_exec_ctx.c @@ -147,6 +147,7 @@ int slbt_get_exec_ctx( char ** parg; char * ch; char * mark; + const char * dmark; char * slash; const char * arprefix; const char * dsoprefix; @@ -172,6 +173,28 @@ int slbt_get_exec_ctx( : ictx->ctx.csrc; if (ref && !ictx->ctx.csrc && (mark = strrchr(ref,'/'))) { + if (!(strncmp(ref,"../",3))) + dmark = 0; + else if (!(strncmp(ref,"./",2))) + dmark = &ref[1]; + else + dmark = strchr(ref,'/'); + + for (; dmark; ) { + if (!(strncmp(dmark,"/./",3))) { + dmark = strchr(&dmark[2],'/'); + } else if (!(strncmp(dmark,"/../",4))) { + ictx->ctx.ldirdepth = -1; + dmark = 0; + } else { + for (; *dmark=='/'; ) + dmark++; + + ictx->ctx.ldirdepth++; + dmark = strchr(dmark,'/'); + } + } + ictx->ctx.ldirname = ch; strcpy(ch,ref); ch += mark - ref; diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index cde7136..be46fab 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -522,6 +522,7 @@ static int slbt_exec_link_create_dep_file( char deplibs[PATH_MAX]; char depfile[PATH_MAX]; struct stat st; + int ldepth; (void)dctx; @@ -578,8 +579,19 @@ static int slbt_exec_link_create_dep_file( } /* [-L... as needed] */ - if (base > *parg) { - if (fprintf(ectx->fdeps,"-L%s/.libs\n",reladir) < 0) { + if ((base > *parg) && (ectx->ldirdepth >= 0)) { + if (fputs("-L",ectx->fdeps) < 0) { + fclose(fdeps); + return SLBT_SYSTEM_ERROR(dctx); + } + + for (ldepth=ectx->ldirdepth; ldepth; ldepth--) + if (fputs("../",ectx->fdeps) < 0) { + fclose(fdeps); + return SLBT_SYSTEM_ERROR(dctx); + } + + if (fprintf(ectx->fdeps,"%s/.libs\n",reladir) < 0) { fclose(fdeps); return SLBT_SYSTEM_ERROR(dctx); } |