summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-16 22:27:11 -0400
committermidipix <writeonce@midipix.org>2016-04-17 02:52:05 -0400
commit8b7d50c8d25d9c5fe7b75c5bce080e79c55d75da (patch)
tree7d5cd18075fce08ea800053aec406e44df4a5cc9 /src/logic
parentafaba2644dc577480ca3ffb138df370197029026 (diff)
downloadslibtool-8b7d50c8d25d9c5fe7b75c5bce080e79c55d75da.tar.bz2
slibtool-8b7d50c8d25d9c5fe7b75c5bce080e79c55d75da.tar.xz
link mode: slbt_get_deps_meta(): initial implementation.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_link.c60
1 files changed, 56 insertions, 4 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index e143c40..afedc0f 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -4,6 +4,7 @@
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
/*******************************************************************/
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
@@ -15,6 +16,13 @@
#include "slibtool_spawn_impl.h"
#include "slibtool_symlink_impl.h"
+struct slbt_deps_meta {
+ char ** altv;
+ char * args;
+ int depscnt;
+ int infolen;
+};
+
/*******************************************************************/
/* */
/* -o <ltlib> switches input result */
@@ -56,6 +64,45 @@
/* */
/*******************************************************************/
+static int slbt_get_deps_meta(
+ char * libfilename,
+ struct slbt_deps_meta * depsmeta)
+{
+ int ret;
+ FILE * fdeps;
+ struct stat st;
+ char depfile[4*PATH_MAX];
+ char * deplibs = depfile;
+
+ if ((size_t)snprintf(depfile,sizeof(depfile),"%s.slibtool.deps",
+ libfilename)
+ >= sizeof(depfile))
+ return -1;
+
+ if ((stat(depfile,&st)))
+ return -1;
+
+ if (!(fdeps = fopen(depfile,"r")))
+ return -1;
+
+ if ((size_t)st.st_size >= sizeof(depfile))
+ if (!(deplibs = malloc(st.st_size+1))) {
+ fclose(fdeps);
+ return -1;
+ }
+
+ depsmeta->infolen += st.st_size;
+ depsmeta->infolen++;
+
+ while (fscanf(fdeps,"%s\n",deplibs) == 1)
+ depsmeta->depscnt++;
+
+ ret = ferror(fdeps) ? -1 : 0;
+ fclose(fdeps);
+
+ return ret;
+}
+
static bool slbt_adjust_input_argument(
char * arg,
const char * osuffix,
@@ -97,7 +144,8 @@ static int slbt_adjust_linker_argument(
char * arg,
bool fpic,
const char * dsosuffix,
- const char * arsuffix)
+ const char * arsuffix,
+ struct slbt_deps_meta * depsmeta)
{
int fdlib;
char * slash;
@@ -136,7 +184,7 @@ static int slbt_adjust_linker_argument(
else
sprintf(dot,"%s",arsuffix);
- return 0;
+ return slbt_get_deps_meta(arg,depsmeta);
}
/* input archive */
@@ -393,6 +441,7 @@ static int slbt_exec_link_create_library(
char cwd [PATH_MAX];
char output [PATH_MAX];
char soname [PATH_MAX];
+ struct slbt_deps_meta depsmeta = {0};
/* initial state */
slbt_reset_arguments(ectx);
@@ -409,7 +458,8 @@ static int slbt_exec_link_create_library(
if (slbt_adjust_linker_argument(
*parg,true,
dctx->cctx->settings.dsosuffix,
- dctx->cctx->settings.arsuffix) < 0)
+ dctx->cctx->settings.arsuffix,
+ &depsmeta) < 0)
return -1;
/* --no-undefined */
@@ -490,6 +540,7 @@ static int slbt_exec_link_create_executable(
char wrapper[PATH_MAX];
char wraplnk[PATH_MAX];
bool fabspath;
+ struct slbt_deps_meta depsmeta = {0};
/* initial state */
slbt_reset_arguments(ectx);
@@ -506,7 +557,8 @@ static int slbt_exec_link_create_executable(
if (slbt_adjust_linker_argument(
*parg,true,
dctx->cctx->settings.dsosuffix,
- dctx->cctx->settings.arsuffix) < 0)
+ dctx->cctx->settings.arsuffix,
+ &depsmeta) < 0)
return -1;
/* --no-undefined */