From 70f645722337a041bf7f3c131646fafb9c7d21f1 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 20 May 2016 22:06:32 -0400 Subject: compile mode: slbt_create_object_wrapper(): initial implementation. --- src/internal/slibtool_objmeta_impl.c | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/internal/slibtool_objmeta_impl.c (limited to 'src/internal/slibtool_objmeta_impl.c') diff --git a/src/internal/slibtool_objmeta_impl.c b/src/internal/slibtool_objmeta_impl.c new file mode 100644 index 0000000..e37d1eb --- /dev/null +++ b/src/internal/slibtool_objmeta_impl.c @@ -0,0 +1,63 @@ +/*******************************************************************/ +/* slibtool: a skinny libtool implementation, written in C */ +/* Copyright (C) 2016 Z. Gilboa */ +/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ +/*******************************************************************/ + +#include +#include +#include "slibtool_metafile_impl.h" + +static int slbt_create_default_object_wrapper( + const struct slbt_driver_ctx * dctx, + struct slbt_exec_ctx * ectx) +{ + int ret; + FILE * fout; + const struct slbt_source_version * verinfo; + + if (!(fout = fopen(ectx->ltobjname,"w"))) + return -1; + + verinfo = slbt_source_version(); + + ret = fprintf(fout, + "# libtool compatible object wrapper\n" + "# Generated by %s (slibtool %d.%d.%d)\n" + "# [commit reference: %s]\n\n" + + "pic_object='%s'\n" + "non_pic_object='%s'\n", + + 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) + ? -1 : 0; +} + +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 slbt_create_object_wrapper( + const struct slbt_driver_ctx * dctx, + struct slbt_exec_ctx * ectx) +{ + if (dctx->cctx->drvflags & SLBT_DRIVER_LEGABITS) + return slbt_create_compatible_object_wrapper(dctx,ectx); + else + return slbt_create_default_object_wrapper(dctx,ectx); +} -- cgit v1.2.3