|
|
70f645 |
/*******************************************************************/
|
|
|
70f645 |
/* slibtool: a skinny libtool implementation, written in C */
|
|
|
78d96a |
/* Copyright (C) 2016--2017 Z. Gilboa */
|
|
|
70f645 |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
70f645 |
/*******************************************************************/
|
|
|
70f645 |
|
|
|
70f645 |
#include <stdio.h>
|
|
|
70f645 |
#include <slibtool/slibtool.h>
|
|
|
3d54f3 |
#include "slibtool_errinfo_impl.h"
|
|
|
70f645 |
#include "slibtool_metafile_impl.h"
|
|
|
70f645 |
|
|
|
70f645 |
static int slbt_create_default_object_wrapper(
|
|
|
70f645 |
const struct slbt_driver_ctx * dctx,
|
|
|
70f645 |
struct slbt_exec_ctx * ectx)
|
|
|
70f645 |
{
|
|
|
70f645 |
int ret;
|
|
|
70f645 |
FILE * fout;
|
|
|
70f645 |
const struct slbt_source_version * verinfo;
|
|
|
70f645 |
|
|
|
70f645 |
if (!(fout = fopen(ectx->ltobjname,"w")))
|
|
|
3d54f3 |
return SLBT_SYSTEM_ERROR(dctx);
|
|
|
70f645 |
|
|
|
70f645 |
verinfo = slbt_source_version();
|
|
|
70f645 |
|
|
|
70f645 |
ret = fprintf(fout,
|
|
|
70f645 |
"# libtool compatible object wrapper\n"
|
|
|
70f645 |
"# Generated by %s (slibtool %d.%d.%d)\n"
|
|
|
70f645 |
"# [commit reference: %s]\n\n"
|
|
|
70f645 |
|
|
|
70f645 |
"pic_object='%s'\n"
|
|
|
70f645 |
"non_pic_object='%s'\n",
|
|
|
70f645 |
|
|
|
70f645 |
dctx->program,
|
|
|
70f645 |
verinfo->major,verinfo->minor,verinfo->revision,
|
|
|
70f645 |
verinfo->commit,
|
|
|
70f645 |
|
|
|
70f645 |
(dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
|
|
|
70f645 |
? ectx->lobjname
|
|
|
70f645 |
: "none",
|
|
|
70f645 |
(dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
|
|
|
70f645 |
? ectx->aobjname
|
|
|
70f645 |
: "none");
|
|
|
70f645 |
|
|
|
70f645 |
return (ret <= 0) || fclose(fout)
|
|
|
3d54f3 |
? SLBT_SYSTEM_ERROR(dctx)
|
|
|
3d54f3 |
: 0;
|
|
|
70f645 |
}
|
|
|
70f645 |
|
|
|
70f645 |
static int slbt_create_compatible_object_wrapper(
|
|
|
70f645 |
const struct slbt_driver_ctx * dctx,
|
|
|
70f645 |
struct slbt_exec_ctx * ectx)
|
|
|
70f645 |
{
|
|
Sebastian Wiedenroth |
ec296a |
int ret;
|
|
Sebastian Wiedenroth |
ec296a |
FILE * fout;
|
|
Sebastian Wiedenroth |
ec296a |
const struct slbt_source_version * verinfo;
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
if (!(fout = fopen(ectx->ltobjname,"w")))
|
|
Sebastian Wiedenroth |
ec296a |
return SLBT_SYSTEM_ERROR(dctx);
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
verinfo = slbt_source_version();
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
ret = fprintf(fout,
|
|
Sebastian Wiedenroth |
ec296a |
"# %s - a libtool object file\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# Generated by %s (slibtool %d.%d.%d)\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# [commit reference: %s]\n"
|
|
Sebastian Wiedenroth |
ec296a |
"#\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# Please DO NOT delete this file!\n"
|
|
Sebastian Wiedenroth |
ec296a |
"# It is necessary for linking the library.\n\n"
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
"# Name of the PIC object.\n"
|
|
Sebastian Wiedenroth |
ec296a |
"pic_object='%s'\n\n"
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
"# Name of the non-PIC object\n"
|
|
Sebastian Wiedenroth |
ec296a |
"non_pic_object='%s'\n",
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
ectx->ltobjname,
|
|
Sebastian Wiedenroth |
ec296a |
dctx->program,
|
|
Sebastian Wiedenroth |
ec296a |
verinfo->major,verinfo->minor,verinfo->revision,
|
|
Sebastian Wiedenroth |
ec296a |
verinfo->commit,
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
(dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
|
|
Sebastian Wiedenroth |
ec296a |
? ectx->lobjname
|
|
Sebastian Wiedenroth |
ec296a |
: "none",
|
|
Sebastian Wiedenroth |
ec296a |
(dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
|
|
Sebastian Wiedenroth |
ec296a |
? ectx->aobjname
|
|
Sebastian Wiedenroth |
ec296a |
: "none");
|
|
Sebastian Wiedenroth |
ec296a |
|
|
Sebastian Wiedenroth |
ec296a |
return (ret <= 0) || fclose(fout)
|
|
Sebastian Wiedenroth |
ec296a |
? SLBT_SYSTEM_ERROR(dctx)
|
|
Sebastian Wiedenroth |
ec296a |
: 0;
|
|
|
70f645 |
}
|
|
|
70f645 |
|
|
|
70f645 |
int slbt_create_object_wrapper(
|
|
|
70f645 |
const struct slbt_driver_ctx * dctx,
|
|
|
70f645 |
struct slbt_exec_ctx * ectx)
|
|
|
70f645 |
{
|
|
|
70f645 |
if (dctx->cctx->drvflags & SLBT_DRIVER_LEGABITS)
|
|
|
70f645 |
return slbt_create_compatible_object_wrapper(dctx,ectx);
|
|
|
70f645 |
else
|
|
|
70f645 |
return slbt_create_default_object_wrapper(dctx,ectx);
|
|
|
70f645 |
}
|