summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorSebastian Wiedenroth <wiedi@frubar.net>2016-09-29 01:16:08 +0200
committermidipix <writeonce@midipix.org>2016-09-30 20:12:58 -0400
commitec296aac58b0c9afd185951427d75da1229b9f19 (patch)
tree4a70d2ab8d9be2bc98657f49fc3e654a816d3396 /src
parent1a80187272e31b04b09f663bd837b7c584442925 (diff)
downloadslibtool-ec296aac58b0c9afd185951427d75da1229b9f19.tar.bz2
slibtool-ec296aac58b0c9afd185951427d75da1229b9f19.tar.xz
library: helper functions: implemented compatible library and objects wrappers.
+ based on work by jperkin (as well as slibtool's default wrapper functions). + generate verbose .la/.lo wrappers that match gnu libtool's output. + dependency_libs string is currently empty, to be added in a separate patch. + ordering of library_names is different, should (probably) not matter.
Diffstat (limited to 'src')
-rw-r--r--src/internal/slibtool_libmeta_impl.c129
-rw-r--r--src/internal/slibtool_objmeta_impl.c40
2 files changed, 164 insertions, 5 deletions
diff --git a/src/internal/slibtool_libmeta_impl.c b/src/internal/slibtool_libmeta_impl.c
index e815983..4a5fa71 100644
--- a/src/internal/slibtool_libmeta_impl.c
+++ b/src/internal/slibtool_libmeta_impl.c
@@ -5,6 +5,7 @@
/*******************************************************************/
#include <stdio.h>
+#include <string.h>
#include <stdbool.h>
#include <slibtool/slibtool.h>
#include "slibtool_errinfo_impl.h"
@@ -127,9 +128,131 @@ static int slbt_create_compatible_library_wrapper(
char * soxyz,
char * solnk)
{
- /* awaiting submission */
- return slbt_create_default_library_wrapper(
- dctx,ectx,arname,soxyz,soname,solnk);
+ int ret;
+ FILE * fout;
+ const char * base;
+ bool fnover;
+ bool fvernum;
+ int current;
+ int revision;
+ int age;
+ const struct slbt_source_version * verinfo;
+
+ (void)ectx;
+
+ /* create */
+ if (!(fout = fopen(dctx->cctx->output,"w")))
+ return SLBT_SYSTEM_ERROR(dctx);
+
+ /* version info */
+ current = 0;
+ age = 0;
+ revision = 0;
+
+ /* wrapper header */
+ if ((base = strrchr(dctx->cctx->output,'/'))) {
+ base++;
+ } else {
+ base = dctx->cctx->output;
+ }
+
+ 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);
+ verinfo = slbt_source_version();
+
+ /* wrapper content */
+ ret = fprintf(fout,
+ "# %s - a libtool library file\n"
+ "# Generated by %s (slibtool %d.%d.%d)\n"
+ "# [commit reference: %s]\n"
+ "#\n"
+ "# Please DO NOT delete this file!\n"
+ "# It is necessary for linking the library.\n\n"
+
+ "# The name that we can dlopen(3).\n"
+ "dlname='%s'\n\n"
+
+ "# Names of this library.\n"
+ "library_names='%s %s %s'\n\n"
+
+ "# The name of the static archive.\n"
+ "old_library='%s'\n\n"
+
+ "# Linker flags that can not go in dependency_libs.\n"
+ "inherited_linker_flags='%s'\n\n"
+
+ "# Libraries that this one depends upon.\n"
+ "dependency_libs='%s'\n\n"
+
+ "# Names of additional weak libraries provided by this library\n"
+ "weak_library_names='%s'\n\n"
+
+ "# Version information for %s%s.\n"
+ "current=%d\n"
+ "age=%d\n"
+ "revision=%d\n\n"
+
+ "# Is this an already installed library?\n"
+ "installed=%s\n\n"
+
+ "# Should we warn about portability when linking against -modules?\n"
+ "shouldnotlink=%s\n\n"
+
+ "# Files to dlopen/dlpreopen\n"
+ "dlopen='%s'\n"
+ "dlpreopen='%s'\n\n"
+
+ "# Directory that this library needs to be installed in:\n"
+ "libdir='%s'\n",
+
+ /* wrapper header */
+ base,
+
+ /* nickname, verinfo */
+ dctx->program,
+ verinfo->major,verinfo->minor,verinfo->revision,
+ verinfo->commit,
+
+ /* dlname */
+ fnover ? solnk : soxyz,
+
+ /* library_names */
+ fnover ? solnk : soxyz,
+ fnover ? solnk : soname,
+ solnk,
+
+ /* old_library */
+ arname,
+
+ /* inherited_linker_flags, dependency_libs, weak_library_names */
+ "","","",
+
+ /* version information for */
+ (dctx->cctx->drvflags & SLBT_DRIVER_MODULE)
+ ? "" : dctx->cctx->settings.dsoprefix,
+ dctx->cctx->libname,
+
+ /* 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 ? dctx->cctx->rpath : "");
+
+ return (ret <= 0) || fclose(fout)
+ ? SLBT_SYSTEM_ERROR(dctx)
+ : 0;
}
int slbt_create_library_wrapper(
diff --git a/src/internal/slibtool_objmeta_impl.c b/src/internal/slibtool_objmeta_impl.c
index 9e9cc75..65d67ea 100644
--- a/src/internal/slibtool_objmeta_impl.c
+++ b/src/internal/slibtool_objmeta_impl.c
@@ -50,8 +50,44 @@ static int slbt_create_compatible_object_wrapper(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx)
{
- /* awaiting submission */
- return slbt_create_default_object_wrapper(dctx,ectx);
+ int ret;
+ FILE * fout;
+ const struct slbt_source_version * verinfo;
+
+ if (!(fout = fopen(ectx->ltobjname,"w")))
+ return SLBT_SYSTEM_ERROR(dctx);
+
+ verinfo = slbt_source_version();
+
+ ret = fprintf(fout,
+ "# %s - a libtool object file\n"
+ "# Generated by %s (slibtool %d.%d.%d)\n"
+ "# [commit reference: %s]\n"
+ "#\n"
+ "# Please DO NOT delete this file!\n"
+ "# It is necessary for linking the library.\n\n"
+
+ "# Name of the PIC object.\n"
+ "pic_object='%s'\n\n"
+
+ "# Name of the non-PIC object\n"
+ "non_pic_object='%s'\n",
+
+ ectx->ltobjname,
+ dctx->program,
+ verinfo->major,verinfo->minor,verinfo->revision,
+ verinfo->commit,
+
+ (dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
+ ? ectx->lobjname
+ : "none",
+ (dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
+ ? ectx->aobjname
+ : "none");
+
+ return (ret <= 0) || fclose(fout)
+ ? SLBT_SYSTEM_ERROR(dctx)
+ : 0;
}
int slbt_create_object_wrapper(