From 771899443dce44974234093859111570560ebddc Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 14 Feb 2024 02:25:39 +0000 Subject: driver: rlibtool mode: also derive from the located libtool script. --- src/driver/slbt_driver_ctx.c | 7 +++++++ src/driver/slbt_host_params.c | 5 +++-- src/internal/slibtool_driver_impl.h | 1 + src/internal/slibtool_lconf_impl.c | 13 +++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 15c2cf5..52aa0af 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -338,6 +338,7 @@ int slbt_get_driver_ctx( const char * program; const char * lconf; uint64_t lflags; + const char * cfgmeta_host; const char * cfgmeta_ar; const char * cfgmeta_as; const char * cfgmeta_ranlib; @@ -395,6 +396,7 @@ int slbt_get_driver_ctx( cmdnostatic = 0; cmdnoshared = 0; + cfgmeta_host = 0; cfgmeta_ar = 0; cfgmeta_as = 0; cfgmeta_ranlib = 0; @@ -584,6 +586,7 @@ int slbt_get_driver_ctx( case TAG_HOST: cctx.host.host = entry->arg; + cfgmeta_host = cfgexplicit; break; case TAG_FLAVOR: @@ -816,6 +819,9 @@ int slbt_get_driver_ctx( if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags) < 0) return slbt_get_driver_ctx_fail(&ctx->ctx,0); + if (ctx->cctx.host.host && !cfgmeta_host) + cfgmeta_host = cfglconf; + if (ctx->cctx.host.ar && !cfgmeta_ar) cfgmeta_ar = cfglconf; @@ -867,6 +873,7 @@ int slbt_get_driver_ctx( &ctx->host, &ctx->cctx.host, &ctx->cctx.cfgmeta, + cfgmeta_host, cfgmeta_ar, cfgmeta_as, cfgmeta_ranlib, diff --git a/src/driver/slbt_host_params.c b/src/driver/slbt_host_params.c index 58e0612..690ca30 100644 --- a/src/driver/slbt_host_params.c +++ b/src/driver/slbt_host_params.c @@ -136,6 +136,7 @@ int slbt_init_host_params( struct slbt_host_strs * drvhost, struct slbt_host_params * host, struct slbt_host_params * cfgmeta, + const char * cfgmeta_host, const char * cfgmeta_ar, const char * cfgmeta_as, const char * cfgmeta_ranlib, @@ -185,7 +186,7 @@ int slbt_init_host_params( /* host */ if (host->host) { - cfgmeta->host = cfgexplicit; + cfgmeta->host = cfgmeta_host ? cfgmeta_host : cfgexplicit; fhost = true; } else if (cctx->target) { @@ -645,7 +646,7 @@ int slbt_set_alternate_host( &ictx->ctx.ahost, &ictx->ctx.cctx.ahost, &ictx->ctx.cctx.acfgmeta, - 0,0,0,0)) { + 0,0,0,0,0)) { slbt_free_host_params(&ictx->ctx.ahost); return SLBT_CUSTOM_ERROR(ctx,SLBT_ERR_HOST_INIT); } diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 3f04b79..2c5ea39 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -246,6 +246,7 @@ int slbt_init_host_params( struct slbt_host_strs * drvhost, struct slbt_host_params * host, struct slbt_host_params * cfgmeta, + const char * cfgmeta_host, const char * cfgmeta_ar, const char * cfgmeta_as, const char * cfgmeta_ranlib, diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index f1747df..78b38a2 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -780,6 +780,19 @@ int slbt_get_lconf_flags( *flags = optshared | optstatic; + /* host */ + if (!ctx->cctx.host.host) { + if (slbt_get_lconf_var(addr,cap,"host=",&val) < 0) + return SLBT_CUSTOM_ERROR( + dctx,SLBT_ERR_LCONF_PARSE); + + if (val[0] && !(ctx->host.host = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + ctx->cctx.host.host = ctx->host.host; + } + + /* ar tool */ if (!ctx->cctx.host.ar) { if (slbt_get_lconf_var(addr,cap,"AR=",&val) < 0) -- cgit v1.2.3