diff options
Diffstat (limited to 'src/driver/slbt_driver_ctx.c')
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 85c75d2..76c7c4a 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -22,6 +22,7 @@ #include "slibtool_objlist_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_lconf_impl.h" +#include "slibtool_mkvars_impl.h" #include "slibtool_txtline_impl.h" #include "slibtool_stoolie_impl.h" #include "slibtool_ar_impl.h" @@ -32,6 +33,7 @@ extern char ** environ; /* annotation strings */ static const char cfgexplicit[] = "command-line argument"; static const char cfglconf[] = "derived from <libtool>"; +static const char cfgmkvars[] = "derived from <makefile>"; /* package info */ static const struct slbt_source_version slbt_src_version = { @@ -398,6 +400,7 @@ int slbt_lib_get_driver_ctx( struct slbt_obj_list * objlistv; struct slbt_driver_ctx_impl * ctx; struct slbt_common_ctx cctx; + struct slbt_error_info** errinfp; const struct argv_option * optv[SLBT_OPTV_ELEMENTS]; struct argv_meta * meta; struct argv_entry * entry; @@ -407,6 +410,7 @@ int slbt_lib_get_driver_ctx( struct argv_entry * cmdnoshared; const char * program; const char * lconf; + const char * mkvars; uint64_t lflags; size_t ndlopen; struct argv_entry ** dlopenv; @@ -455,6 +459,7 @@ int slbt_lib_get_driver_ctx( return slbt_free_argv_buffer(&sargv,objlistv); lconf = 0; + mkvars = 0; program = argv_program_name(argv[0]); memset(&cctx,0,sizeof(cctx)); @@ -519,6 +524,10 @@ int slbt_lib_get_driver_ctx( lconf = entry->arg; break; + case TAG_MKVARS: + mkvars = entry->arg; + break; + case TAG_MODE: if (!strcmp("clean",entry->arg)) cctx.mode = SLBT_MODE_CLEAN; @@ -600,6 +609,14 @@ int slbt_lib_get_driver_ctx( cctx.drvflags |= SLBT_DRIVER_OUTPUT_MACHINE; break; + case TAG_PRINT_AUX_DIR: + cctx.drvflags |= SLBT_DRIVER_OUTPUT_AUX_DIR; + break; + + case TAG_PRINT_M4_DIR: + cctx.drvflags |= SLBT_DRIVER_OUTPUT_M4_DIR; + break; + case TAG_DEBUG: cctx.drvflags |= SLBT_DRIVER_DEBUG; break; @@ -862,6 +879,14 @@ int slbt_lib_get_driver_ctx( "--disable-static", "--disable-shared"); + if (lconf && mkvars) + return slbt_driver_fail_incompatible_args( + fdctx->fderr, + cctx.drvflags, + meta,program, + "--heuristics=<cfgfile>", + "--mkvars=<makefile>"); + /* -static? */ if (cmdstatic) { cctx.drvflags |= SLBT_DRIVER_STATIC; @@ -930,11 +955,81 @@ int slbt_lib_get_driver_ctx( ctx->cctx.cargv = sargv.cargv; ctx->meta = meta; + /* mkvars */ + if (mkvars) { + if (slbt_get_mkvars_flags(&ctx->ctx,mkvars,&lflags) < 0) + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + + if (ctx->cctx.host.host && !cfgmeta_host) + cfgmeta_host = cfgmkvars; + + if (ctx->cctx.host.ar && !cfgmeta_ar) + cfgmeta_ar = cfgmkvars; + + if (ctx->cctx.host.as && !cfgmeta_as) + cfgmeta_as = cfgmkvars; + + if (ctx->cctx.host.nm && !cfgmeta_nm) + cfgmeta_nm = cfgmkvars; + + if (ctx->cctx.host.ranlib && !cfgmeta_ranlib) + cfgmeta_ranlib = cfgmkvars; + + if (ctx->cctx.host.dlltool && !cfgmeta_dlltool) + cfgmeta_dlltool = cfgmkvars; + + if (cmdnoshared) + lflags &= ~(uint64_t)SLBT_DRIVER_DISABLE_STATIC; + + if (cmdnostatic) + if (lflags & SLBT_DRIVER_DISABLE_SHARED) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_DISABLE_STATIC; + + cctx.drvflags |= lflags; + + /* -disable-static? */ + if (cctx.drvflags & SLBT_DRIVER_DISABLE_STATIC) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_STATIC; + + /* -disable-shared? */ + if (cctx.drvflags & SLBT_DRIVER_DISABLE_SHARED) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_SHARED; + + ctx->cctx.drvflags = cctx.drvflags; + } + /* heuristics */ + if (mkvars) + cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_HEURISTICS; + if (cctx.drvflags & SLBT_DRIVER_HEURISTICS) { - if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags) < 0) + if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags,false) < 0) return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + } else { + switch (cctx.mode) { + case SLBT_MODE_UNKNOWN: + case SLBT_MODE_STOOLIE: + break; + + case SLBT_MODE_CONFIG: + lconf = mkvars ? 0 : "slibtool.cfg"; + break; + + default: + lconf = "slibtool.cfg"; + break; + } + + if (lconf && (errinfp = ctx->errinfp)) + if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags,true) < 0) + for (ctx->errinfp=errinfp; *errinfp; errinfp++) + *errinfp = 0; + + if (ctx->lconfctx) + cctx.drvflags |= SLBT_DRIVER_HEURISTICS; + } + if (cctx.drvflags & SLBT_DRIVER_HEURISTICS) { if (ctx->cctx.host.host && !cfgmeta_host) cfgmeta_host = cfglconf; @@ -1113,6 +1208,9 @@ static void slbt_lib_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx) if (ictx->ctx.lconfctx) slbt_lib_free_txtfile_ctx(ictx->ctx.lconfctx); + if (ictx->ctx.mkvarsctx) + slbt_lib_free_txtfile_ctx(ictx->ctx.mkvarsctx); + for (objlistp=ictx->ctx.objlistv; objlistp->name; objlistp++) { free(objlistp->objv); free(objlistp->addr); |