summaryrefslogtreecommitdiffhomepage
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-02 19:33:00 -0400
committermidipix <writeonce@midipix.org>2016-04-02 19:34:01 -0400
commit4c76f7e588baf71574c3e7b536632f46db39af3d (patch)
tree97e510d12e91432a058d5ddd35540efce7fba88e /src/logic
parent53aa85177cf44dbe997a9dfeb6072f913aca3b5b (diff)
downloadslibtool-4c76f7e588baf71574c3e7b536632f46db39af3d.tar.bz2
slibtool-4c76f7e588baf71574c3e7b536632f46db39af3d.tar.xz
link mode: slbt_exec_link_create_symlink(): initial implementation.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_link.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 7816749..639d014 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -133,6 +133,45 @@ static int slbt_exec_link_create_archive(
return 0;
}
+static int slbt_exec_link_create_symlink(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx,
+ const char * target,
+ char * lnkname)
+{
+ const char * slash;
+ char * ln[6];
+ char atarget[PATH_MAX];
+
+ /* atarget */
+ if ((slash = strrchr(target,'/')))
+ slash++;
+ else
+ slash = target;
+
+ if ((size_t)snprintf(atarget,sizeof(atarget),"../%s",
+ slash) >= sizeof(atarget))
+ return -1;
+
+ /* ln argv (fake) */
+ ln[0] = "ln";
+ ln[1] = "-f";
+ ln[2] = "-s";
+ ln[3] = atarget;
+ ln[4] = lnkname;
+ ectx->argv = ln;
+
+ /* step output */
+ if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
+ if (slbt_output_link(dctx,ectx))
+ return -1;
+
+ /* remove old symlink (if any) */
+ unlink(lnkname);
+
+ /* create symlink */
+ return symlink(atarget,lnkname);
+}
int slbt_exec_link(
const struct slbt_driver_ctx * dctx,
@@ -189,6 +228,15 @@ int slbt_exec_link(
ret = fprintf(fout,
"# slibtool (pre-alphe) generated file\n\n");
+ /* wrapper symlink */
+ if (slbt_exec_link_create_symlink(
+ dctx,ectx,
+ output,
+ ectx->lafilename)) {
+ slbt_free_exec_ctx(actx);
+ return -1;
+ }
+
/* all done */
fclose(fout);
slbt_free_exec_ctx(actx);