summaryrefslogtreecommitdiffhomepage
path: root/src/internal
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-08 20:57:49 +0000
committermidipix <writeonce@midipix.org>2024-02-08 20:57:49 +0000
commitd29f9c69021c51af493b43fe5d15dab02881760e (patch)
tree38a103382004821af31de1f0ff2083dc31e6f79c /src/internal
parent20aece02ccacf12b1ce13b6c61e4ef45d060f798 (diff)
downloadslibtool-d29f9c69021c51af493b43fe5d15dab02881760e.tar.bz2
slibtool-d29f9c69021c51af493b43fe5d15dab02881760e.tar.xz
driver: rlibtool mode: derive AR and RANLIB from the located libtool script.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/slibtool_lconf_impl.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c
index 7ad817c..8271f59 100644
--- a/src/internal/slibtool_lconf_impl.c
+++ b/src/internal/slibtool_lconf_impl.c
@@ -655,13 +655,22 @@ static int slbt_get_lconf_var(
if (mark == cap)
return 0;
- /* for our purposes, only support non-quoted values */
+ /* support a single pair of double quotes */
match = &match[len];
mark = match;
- for (; !isspace(*mark) && (mark < cap); )
+ if (match[0] == '"') {
+ match++;
mark++;
+ for (; (*mark != '"') && (mark < cap); )
+ mark++;
+ } else {
+ for (; !isspace(*mark) && (mark < cap); )
+ mark++;
+ }
+
+
/* validate */
if ((len = mark - match) >= PATH_MAX)
return -1;
@@ -700,6 +709,7 @@ int slbt_get_lconf_flags(
const char * lconf,
uint64_t * flags)
{
+ struct slbt_driver_ctx_impl * ctx;
int fdlconf;
struct stat st;
void * addr;
@@ -709,6 +719,9 @@ int slbt_get_lconf_flags(
uint64_t optstatic;
char val[PATH_MAX];
+ /* driver context (ar, ranlib, cc) */
+ ctx = slbt_get_driver_ictx(dctx);
+
/* open relative libtool script */
if ((fdlconf = slbt_lconf_open(dctx,lconf)) < 0)
return SLBT_NESTED_ERROR(dctx);
@@ -760,13 +773,37 @@ int slbt_get_lconf_flags(
optstatic = SLBT_DRIVER_DISABLE_STATIC;
}
- munmap(addr,st.st_size);
-
if (!optshared || !optstatic)
return SLBT_CUSTOM_ERROR(
dctx,SLBT_ERR_LCONF_PARSE);
*flags = optshared | optstatic;
+
+ /* ar tool */
+ if (!ctx->cctx.host.ar) {
+ if (slbt_get_lconf_var(addr,cap,"AR=",&val) < 0)
+ return SLBT_CUSTOM_ERROR(
+ dctx,SLBT_ERR_LCONF_PARSE);
+
+ if (val[0] && !(ctx->cctx.host.ar = strdup(val)))
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ }
+
+
+ /* ranlib tool */
+ if (!ctx->cctx.host.ranlib) {
+ if (slbt_get_lconf_var(addr,cap,"RANLIB=",&val) < 0)
+ return SLBT_CUSTOM_ERROR(
+ dctx,SLBT_ERR_LCONF_PARSE);
+
+ if (val[0] && !(ctx->cctx.host.ranlib = strdup(val)))
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ }
+
+
+ /* all done */
+ munmap(addr,st.st_size);
+
return 0;
}