summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-03-20 11:22:57 -0400
committermidipix <writeonce@midipix.org>2016-03-20 11:22:57 -0400
commit2bd7498431c7e7bf4eedc5ccbb333c06893d4089 (patch)
treea9807564777a1aaeec1c351fca6b285a465966d2
parentfa3d12b8b87586ca414cd7707845834168bc3a49 (diff)
downloadslibtool-2bd7498431c7e7bf4eedc5ccbb333c06893d4089.tar.bz2
slibtool-2bd7498431c7e7bf4eedc5ccbb333c06893d4089.tar.xz
slbt_exec_link(): created skeleton.
-rw-r--r--include/slibtool/slibtool.h1
-rw-r--r--project/common.mk1
-rw-r--r--src/logic/slbt_exec_link.c65
3 files changed, 67 insertions, 0 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index cd5caa3..5f0a76a 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -180,6 +180,7 @@ slbt_api void slbt_free_exec_ctx (struct slbt_exec_ctx *);
slbt_api void slbt_reset_placeholders (struct slbt_exec_ctx *);
slbt_api int slbt_exec_compile (const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
+slbt_api int slbt_exec_link (const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
slbt_api int slbt_map_input (int fd, const char * path, int prot, struct slbt_input *);
slbt_api int slbt_unmap_input (struct slbt_input *);
diff --git a/project/common.mk b/project/common.mk
index 25fb716..fafad0f 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -3,6 +3,7 @@ COMMON_SRCS = \
src/driver/slbt_unit_ctx.c \
src/logic/slbt_exec_compile.c \
src/logic/slbt_exec_ctx.c \
+ src/logic/slbt_exec_link.c \
src/logic/slbt_map_input.c \
src/output/slbt_output_config.c \
src/output/slbt_output_exec.c \
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 <string.h>
+#include <stdbool.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <slibtool/slibtool.h>
+#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;
+}