From 2bd7498431c7e7bf4eedc5ccbb333c06893d4089 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 20 Mar 2016 11:22:57 -0400 Subject: slbt_exec_link(): created skeleton. --- src/logic/slbt_exec_link.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/logic/slbt_exec_link.c (limited to 'src') diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c new file mode 100644 index 0000000..4da33c6 --- /dev/null +++ b/src/logic/slbt_exec_link.c @@ -0,0 +1,65 @@ +/*******************************************************************/ +/* 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 +#include +#include + +#include +#include "slibtool_spawn_impl.h" + + +int slbt_exec_link( + const struct slbt_driver_ctx * dctx, + struct slbt_exec_ctx * ectx) +{ + int ret; + int fdlibs; + char * dot; + FILE * fout; + struct slbt_exec_ctx * actx; + + /* context */ + if (ectx) + actx = 0; + else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + return ret; + else + actx = ectx; + + /* .libs directory */ + if (dctx->cctx->drvflags & SLBT_DRIVER_SHARED) { + if ((fdlibs = open(ectx->ldirname,O_DIRECTORY)) >= 0) + close(fdlibs); + else if ((errno != ENOENT) || mkdir(ectx->ldirname,0777)) { + slbt_free_exec_ctx(actx); + return -1; + } + } + + /* no wrapper? */ + if (!(dot = strrchr(dctx->cctx->output,'.')) || strcmp(dot,".la")) { + slbt_free_exec_ctx(actx); + return 0; + } + + /* hey, yo, let's rap it up */ + if (!(fout = fopen(ectx->ltobjname,"w"))) { + slbt_free_exec_ctx(actx); + return -1; + } + + ret = fprintf(fout, + "# slibtool (pre-alphe) generated file\n\n"); + + /* all done */ + fclose(fout); + slbt_free_exec_ctx(actx); + + return (ret > 0) ? 0 : -1; +} -- cgit v1.2.3