summaryrefslogtreecommitdiffhomepage
path: root/src/logic/slbt_exec_link.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-16 20:53:08 -0400
committermidipix <writeonce@midipix.org>2016-04-17 02:51:57 -0400
commit0913c3d46b180e40867e7de6a062582acd1902e9 (patch)
treeaf3169150d257fabb06d7073a9a7b1c0e038580c /src/logic/slbt_exec_link.c
parentdcb4535da0c4e22eafb51a20128c436e3337f8b7 (diff)
downloadslibtool-0913c3d46b180e40867e7de6a062582acd1902e9.tar.bz2
slibtool-0913c3d46b180e40867e7de6a062582acd1902e9.tar.xz
link mode: .deps file generation: initial implementation.
Diffstat (limited to 'src/logic/slbt_exec_link.c')
-rw-r--r--src/logic/slbt_exec_link.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 501486f..3fd35ad 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -245,6 +245,56 @@ static int slbt_exec_link_remove_file(
return -1;
}
+static int slbt_exec_link_create_dep_file(
+ struct slbt_exec_ctx * ectx,
+ char ** altv,
+ const char * libfilename)
+{
+ char ** parg;
+ char * popt;
+ char * plib;
+ char depfile[PATH_MAX];
+
+ if (ectx->fdeps)
+ fclose(ectx->fdeps);
+
+ if ((size_t)snprintf(depfile,sizeof(depfile),"%s.slibtool.deps",
+ libfilename)
+ >= sizeof(depfile))
+ return -1;
+
+ if (!(ectx->fdeps = fopen(depfile,"w")))
+ return -1;
+
+ for (parg=altv; *parg; parg++) {
+ popt = 0;
+ plib = 0;
+
+ if (!strcmp(*parg,"-l")) {
+ popt = *parg++;
+ plib = *parg;
+ } else if (!strcmp(*parg,"--library")) {
+ popt = *parg++;
+ plib = *parg;
+ } else if (!strncmp(*parg,"-l",2)) {
+ popt = *parg;
+ plib = popt + 2;
+ } else if (!strncmp(*parg,"--library=",10)) {
+ popt = *parg;
+ plib = popt + 10;
+ }
+
+ if (plib)
+ if (fprintf(ectx->fdeps,"-l%s\n",plib) < 0)
+ return -1;
+ }
+
+ if (fflush(ectx->fdeps))
+ return -1;
+
+ return 0;
+}
+
static int slbt_exec_link_create_archive(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
@@ -298,6 +348,10 @@ static int slbt_exec_link_create_archive(
if (slbt_exec_link_remove_file(dctx,ectx,output))
return -1;
+ /* .deps */
+ if (slbt_exec_link_create_dep_file(ectx,ectx->cargv,arfilename))
+ return -1;
+
/* ar spawn */
if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode)
return -1;
@@ -413,6 +467,10 @@ static int slbt_exec_link_create_library(
if (slbt_output_link(dctx,ectx))
return -1;
+ /* .deps */
+ if (slbt_exec_link_create_dep_file(ectx,ectx->argv,dsofilename))
+ return -1;
+
/* spawn */
if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode)
return -1;