From 112a2bc026f48bf9453c2bb8766f730e8c0d1bc9 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 24 Apr 2016 09:14:59 -0400 Subject: execution context: link mode: install mode: added -release semantics support. --- src/logic/slbt_exec_ctx.c | 12 +++++++++++ src/logic/slbt_exec_install.c | 12 ++++++++++- src/logic/slbt_exec_link.c | 49 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 64 insertions(+), 9 deletions(-) (limited to 'src/logic') diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c index 23cae68..17c6cd8 100644 --- a/src/logic/slbt_exec_ctx.c +++ b/src/logic/slbt_exec_ctx.c @@ -357,6 +357,18 @@ int slbt_get_exec_ctx( dctx->cctx->verinfo.revision, dctx->cctx->settings.impsuffix); ch++; + + /* relfilename */ + if (dctx->cctx->release) { + ictx->ctx.relfilename = ch; + ch += sprintf(ch,"%s%s%s-%s%s", + ictx->ctx.ldirname, + dsoprefix, + dctx->cctx->libname, + dctx->cctx->release, + dctx->cctx->settings.dsosuffix); + ch++; + } } /* linking: exefilename */ diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c index a595774..0eddd6d 100644 --- a/src/logic/slbt_exec_install.c +++ b/src/logic/slbt_exec_install.c @@ -233,6 +233,7 @@ static int slbt_exec_install_entry( char lasource[PATH_MAX]; bool fexe = false; bool fpe; + bool frelease; struct stat st; /* executable wrapper? */ @@ -297,9 +298,15 @@ static int slbt_exec_install_entry( dest ? (char *)dest->arg : (char *)last->arg)) return -1; - /* libfoo.a --> libfoo.so */ + /* dot/suffix */ strcpy(slnkname,srcfile); dot = strrchr(slnkname,'.'); + + /* libfoo.a --> libfoo.so.release */ + sprintf(dot,"%s.release",dctx->cctx->settings.dsosuffix); + frelease = stat(slnkname,&st) ? false : true; + + /* libfoo.a --> libfoo.so */ strcpy(dot,dctx->cctx->settings.dsosuffix); /* PE support: does .libs/libfoo.so.def exist? */ @@ -377,6 +384,9 @@ static int slbt_exec_install_entry( false)) return -1; + if (frelease) + return 0; + /* libfoo.so.x.y.z --> libfoo.so.x */ strcpy(slnkname,target); diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 72e9880..0386941 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -588,7 +588,8 @@ static int slbt_exec_link_create_archive( static int slbt_exec_link_create_library( const struct slbt_driver_ctx * dctx, struct slbt_exec_ctx * ectx, - const char * dsofilename) + const char * dsofilename, + const char * relfilename) { char ** parg; char cwd [PATH_MAX]; @@ -630,6 +631,17 @@ static int slbt_exec_link_create_library( >= sizeof(soname)) return -1; + *ectx->soname = "-Wl,-soname"; + *ectx->lsoname = soname; + } else if (relfilename) { + if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s%s-%s%s", + dctx->cctx->settings.dsoprefix, + dctx->cctx->libname, + dctx->cctx->release, + dctx->cctx->settings.dsosuffix) + >= sizeof(soname)) + return -1; + *ectx->soname = "-Wl,-soname"; *ectx->lsoname = soname; } @@ -654,7 +666,9 @@ static int slbt_exec_link_create_library( } /* output */ - if (dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION) { + if (relfilename) { + strcpy(output,relfilename); + } else if (dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION) { strcpy(output,dsofilename); } else { if ((size_t)snprintf(output,sizeof(output),"%s.%d.%d.%d", @@ -841,11 +855,21 @@ static int slbt_exec_link_create_library_symlink( char target[PATH_MAX]; char lnkname[PATH_MAX]; - sprintf(target,"%s.%d.%d.%d", - ectx->dsofilename, - dctx->cctx->verinfo.major, - dctx->cctx->verinfo.minor, - dctx->cctx->verinfo.revision); + if (ectx->relfilename) { + strcpy(target,ectx->relfilename); + sprintf(lnkname,"%s.release",ectx->dsofilename); + + if (slbt_create_symlink( + dctx,ectx, + target,lnkname, + false)) + return -1; + } else + sprintf(target,"%s.%d.%d.%d", + ectx->dsofilename, + dctx->cctx->verinfo.major, + dctx->cctx->verinfo.minor, + dctx->cctx->verinfo.revision); if (fmajor) sprintf(lnkname,"%s.%d", @@ -986,7 +1010,8 @@ int slbt_exec_link( /* linking: libfoo.so.x.y.z */ if (slbt_exec_link_create_library( dctx,ectx, - ectx->dsofilename)) { + ectx->dsofilename, + ectx->relfilename)) { slbt_free_exec_ctx(actx); return -1; } @@ -1007,6 +1032,14 @@ int slbt_exec_link( slbt_free_exec_ctx(actx); return -1; } + } else if (ectx->relfilename) { + /* symlink: libfoo.so --> libfoo-x.y.z.so */ + if (slbt_exec_link_create_library_symlink( + dctx,ectx, + false)) { + slbt_free_exec_ctx(actx); + return -1; + } } /* PE import libraries */ -- cgit v1.2.3