summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_link.c139
1 files changed, 110 insertions, 29 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index e6e6c2d..5a82b8c 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -870,7 +870,45 @@ int slbt_exec_link(
struct slbt_exec_ctx * actx;
bool fpic;
bool fstaticonly;
+ bool fnover;
+ bool fvernum;
+ int current;
+ int revision;
+ int age;
char soname[PATH_MAX];
+ char soxyz [PATH_MAX];
+ char solnk [PATH_MAX];
+ char arname[PATH_MAX];
+
+ /* libfoo.so.x.y.z */
+ if ((size_t)snprintf(soxyz,sizeof(soxyz),"%s%s%s.%d.%d.%d",
+ dctx->cctx->settings.dsoprefix,
+ dctx->cctx->libname,
+ dctx->cctx->settings.dsosuffix,
+ dctx->cctx->verinfo.major,
+ dctx->cctx->verinfo.minor,
+ dctx->cctx->verinfo.revision)
+ >= sizeof(soxyz))
+ return -1;
+
+ /* libfoo.so.x */
+ sprintf(soname,"%s%s%s.%d",
+ dctx->cctx->settings.dsoprefix,
+ dctx->cctx->libname,
+ dctx->cctx->settings.dsosuffix,
+ dctx->cctx->verinfo.major);
+
+ /* libfoo.so */
+ sprintf(solnk,"%s%s%s",
+ dctx->cctx->settings.dsoprefix,
+ dctx->cctx->libname,
+ dctx->cctx->settings.dsosuffix);
+
+ /* libfoo.a */
+ sprintf(arname,"%s%s%s",
+ dctx->cctx->settings.arprefix,
+ dctx->cctx->libname,
+ dctx->cctx->settings.arsuffix);
/* context */
if (ectx)
@@ -966,14 +1004,6 @@ int slbt_exec_link(
/* PE import libraries */
if (dctx->cctx->drvflags & SLBT_DRIVER_IMAGE_PE) {
/* libfoo.x.lib.a */
- if ((size_t)snprintf(soname,sizeof(soname),"%s%s%s.%d",
- dctx->cctx->settings.dsoprefix,
- dctx->cctx->libname,
- dctx->cctx->settings.dsosuffix,
- dctx->cctx->verinfo.major)
- >= sizeof(soname))
- return -1;
-
if (slbt_exec_link_create_import_library(
dctx,ectx,
ectx->pimpfilename,
@@ -991,21 +1021,11 @@ int slbt_exec_link(
return -1;
/* libfoo.x.y.z.lib.a */
- if ((size_t)snprintf(soname,sizeof(soname),"%s%s%s.%d.%d.%d",
- dctx->cctx->settings.dsoprefix,
- dctx->cctx->libname,
- dctx->cctx->settings.dsosuffix,
- dctx->cctx->verinfo.major,
- dctx->cctx->verinfo.minor,
- dctx->cctx->verinfo.revision)
- >= sizeof(soname))
- return -1;
-
if (slbt_exec_link_create_import_library(
dctx,ectx,
ectx->vimpfilename,
ectx->deffilename,
- soname,
+ soxyz,
false))
return -1;
}
@@ -1034,20 +1054,81 @@ int slbt_exec_link(
return -1;
}
+ /* compatible library wrapper */
+ current = 0;
+ age = 0;
+ revision = 0;
+
+ if (dctx->cctx->verinfo.verinfo)
+ sscanf(dctx->cctx->verinfo.verinfo,"%d:%d:%d",
+ &current,&revision,&age);
+
+ fnover = !!(dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION);
+ fvernum = !!(dctx->cctx->verinfo.vernumber);
+
+ ret = fprintf(fout,
+ "# libtool compatible library wrapper\n"
+ "# Generated by slibtool (pre-alpha)\n\n"
+
+ "dlname='%s'\n"
+ "library_names='%s %s %s'\n"
+ "old_library='%s'\n\n"
+
+ "inherited_linker_flags='%s'\n"
+ "dependency_libs='%s'\n"
+ "weak_library_names='%s'\n\n"
+
+ "current=%d\n"
+ "age=%d\n"
+ "revision=%d\n\n"
+
+ "installed=%s\n"
+ "shouldnotlink=%s\n\n"
+
+ "dlopen='%s'\n"
+ "dlpreopen='%s'\n\n"
+
+ "libdir='%s'\n",
+
+ /* dlname */
+ fnover ? solnk : soxyz,
+
+ /* library_names */
+ fnover ? solnk : soxyz,
+ fnover ? solnk : soname,
+ solnk,
+
+ /* old_library */
+ arname,
+
+ /* inherited_linker_flags, dependency_libs, weak_library_names */
+ "","","",
+
+ /* current, age, revision */
+ fvernum ? dctx->cctx->verinfo.major : current,
+ fvernum ? dctx->cctx->verinfo.minor : age,
+ fvernum ? dctx->cctx->verinfo.major : revision,
+
+ /* installed, shouldnotlink */
+ "no","no",
+
+ /* dlopen, dlpreopen */
+ "","",
+
+ /* libdir */
+ dctx->cctx->rpath);
+
/* wrapper symlink */
- if (slbt_create_symlink(
- dctx,ectx,
- output,
- ectx->lafilename,
- true))
- ret = -1;
- else
- ret = fprintf(fout,
- "# slibtool (pre-alpha) generated file\n\n");
+ if (ret > 0)
+ ret = (slbt_create_symlink(
+ dctx,ectx,
+ output,
+ ectx->lafilename,
+ true));
/* all done */
fclose(fout);
slbt_free_exec_ctx(actx);
- return (ret > 0) ? 0 : -1;
+ return ret;
}