diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/driver/slbt_amain.c | 22 | ||||
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 12 | ||||
-rw-r--r-- | src/driver/slbt_split_argv.c | 15 | ||||
-rw-r--r-- | src/internal/slibtool_driver_impl.h | 7 | ||||
-rw-r--r-- | src/internal/slibtool_lconf_impl.c | 18 | ||||
-rw-r--r-- | src/logic/slbt_exec_stoolie.c | 26 | ||||
-rw-r--r-- | src/skin/slbt_skin_default.c | 10 |
7 files changed, 97 insertions, 13 deletions
diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index e0f4241..a9cc118 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -67,6 +67,16 @@ static ssize_t slbt_print_m4_dir(int fdout) return slbt_dprintf(fdout,"%s\n",SLBT_PACKAGE_DATADIR); } +static ssize_t slbt_print_shared_ext(int fdout, struct slbt_driver_ctx * dctx) +{ + return slbt_dprintf(fdout,"%s\n",dctx->cctx->settings.dsosuffix); +} + +static ssize_t slbt_print_static_ext(int fdout, struct slbt_driver_ctx * dctx) +{ + return slbt_dprintf(fdout,"%s\n",dctx->cctx->settings.arsuffix); +} + static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx) { if (dctx->cctx->drvflags & SLBT_DRIVER_INFO) @@ -219,6 +229,18 @@ int slbt_main(char ** argv, char ** envp, const struct slbt_fd_ctx * fdctx) ? slbt_exit(dctx,SLBT_ERROR) : slbt_exit(dctx,SLBT_OK); + /* -print-shared-ext must be the first (and only) action */ + if (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_SHARED_EXT) + return (slbt_print_shared_ext(fdout,dctx) < 0) + ? slbt_exit(dctx,SLBT_ERROR) + : slbt_exit(dctx,SLBT_OK); + + /* -print-static-ext must be the first (and only) action */ + if (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_STATIC_EXT) + return (slbt_print_static_ext(fdout,dctx) < 0) + ? slbt_exit(dctx,SLBT_ERROR) + : slbt_exit(dctx,SLBT_OK); + /* perform all other actions */ slbt_perform_driver_actions(dctx); diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 76c7c4a..09adb68 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -440,6 +440,7 @@ int slbt_lib_get_driver_ctx( sargv.cargv = 0; objlistv = 0; ndlopen = 0; + lflags = 0; switch (slbt_split_argv(argv,flags,&sargv,&objlistv,fdctx->fderr,fdctx->fdcwd)) { case SLBT_OK: @@ -617,6 +618,14 @@ int slbt_lib_get_driver_ctx( cctx.drvflags |= SLBT_DRIVER_OUTPUT_M4_DIR; break; + case TAG_PRINT_SHARED_EXT: + cctx.drvflags |= SLBT_DRIVER_OUTPUT_SHARED_EXT; + break; + + case TAG_PRINT_STATIC_EXT: + cctx.drvflags |= SLBT_DRIVER_OUTPUT_STATIC_EXT; + break; + case TAG_DEBUG: cctx.drvflags |= SLBT_DRIVER_DEBUG; break; @@ -1004,7 +1013,8 @@ int slbt_lib_get_driver_ctx( if (cctx.drvflags & SLBT_DRIVER_HEURISTICS) { if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags,false) < 0) - return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + if (!(cctx.drvflags & SLBT_DRIVER_OUTPUT_MASK)) + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); } else { switch (cctx.mode) { case SLBT_MODE_UNKNOWN: diff --git a/src/driver/slbt_split_argv.c b/src/driver/slbt_split_argv.c index 8fd131a..f9828f1 100644 --- a/src/driver/slbt_split_argv.c +++ b/src/driver/slbt_split_argv.c @@ -60,6 +60,7 @@ slbt_hidden int slbt_split_argv( struct argv_entry * ccwrap; struct argv_entry * dumpmachine; struct argv_entry * printdir; + struct argv_entry * printext; struct argv_entry * aropt; struct argv_entry * stoolieopt; const struct argv_option ** popt; @@ -67,7 +68,7 @@ slbt_hidden int slbt_split_argv( const struct argv_option * optv[SLBT_OPTV_ELEMENTS]; struct argv_ctx ctx = {ARGV_VERBOSITY_NONE, ARGV_MODE_SCAN, - 0,0,0,0,0,0,0}; + 0,0,0,0,0,0,0,0}; program = slbt_program_name(argv[0]); @@ -126,7 +127,7 @@ slbt_hidden int slbt_split_argv( /* missing all of --mode, --help, --version, --info, --config, --dumpmachine, --features, and --finish? */ /* as well as -print-aux-dir and -print-m4-dir? */ - mode = help = version = info = config = finish = features = ccwrap = dumpmachine = printdir = aropt = stoolieopt = 0; + mode = help = version = info = config = finish = features = ccwrap = dumpmachine = printdir = printext = aropt = stoolieopt = 0; for (entry=meta->entries; entry->fopt; entry++) if (entry->tag == TAG_MODE) @@ -151,6 +152,10 @@ slbt_hidden int slbt_split_argv( printdir = entry; else if (entry->tag == TAG_PRINT_M4_DIR) printdir = entry; + else if (entry->tag == TAG_PRINT_SHARED_EXT) + printext = entry; + else if (entry->tag == TAG_PRINT_STATIC_EXT) + printext = entry; /* alternate execusion mode? */ if (!altmode && mode && !strcmp(mode->arg,"ar")) @@ -175,7 +180,7 @@ slbt_hidden int slbt_split_argv( return -1; } - if (!mode && !help && !version && !info && !config && !finish && !features && !dumpmachine && !printdir && !altmode) { + if (!mode && !help && !version && !info && !config && !finish && !features && !dumpmachine && !printdir && !printext && !altmode) { slbt_dprintf(fderr, "%s: error: --mode must be specified.\n", program); @@ -183,7 +188,7 @@ slbt_hidden int slbt_split_argv( } /* missing compiler? */ - if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine && !printdir) { + if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine && !printdir && !printext) { if (!altmode && !aropt && !stoolieopt) { if (flags & SLBT_DRIVER_VERBOSITY_ERRORS) slbt_dprintf(fderr, @@ -345,7 +350,7 @@ slbt_hidden int slbt_split_argv( if (ctx.unitidx) { (void)0; - } else if (help || version || features || info || config || dumpmachine || printdir || altmode) { + } else if (help || version || features || info || config || dumpmachine || printdir || printext || altmode) { for (i=0; i<argc; i++) sargv->targv[i] = argv[i]; diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 429cdc4..7b6114d 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -20,6 +20,11 @@ #define SLBT_OPTV_ELEMENTS 128 +#define SLBT_DRIVER_OUTPUT_MASK (SLBT_DRIVER_OUTPUT_M4_DIR \ + | SLBT_DRIVER_OUTPUT_AUX_DIR \ + | SLBT_DRIVER_OUTPUT_SHARED_EXT \ + | SLBT_DRIVER_OUTPUT_STATIC_EXT) + extern const struct argv_option slbt_default_options[]; enum app_tags { @@ -32,6 +37,8 @@ enum app_tags { TAG_DUMPMACHINE, TAG_PRINT_AUX_DIR, TAG_PRINT_M4_DIR, + TAG_PRINT_SHARED_EXT, + TAG_PRINT_STATIC_EXT, TAG_DEBUG, TAG_DRY_RUN, TAG_FEATURES, diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index ffe92b0..7f43034 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -545,6 +545,7 @@ static int slbt_lconf_open( fdcwd = slbt_driver_fdcwd(dctx); fdlconfdir = fdcwd; fsilent |= (dctx->cctx->drvflags & SLBT_DRIVER_SILENT); + fsilent |= (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_MASK); if (lconf) { mconf = 0; @@ -629,15 +630,21 @@ static int slbt_lconf_open( if (stparent.st_dev != stcwd.st_dev) { trace_result(dctx,fdparent,fdparent,".",EXDEV,lconfpath); close(fdparent); - return SLBT_CUSTOM_ERROR( - dctx,SLBT_ERR_LCONF_OPEN); + + return (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_MASK) + ? (-1) + : SLBT_CUSTOM_ERROR( + dctx,SLBT_ERR_LCONF_OPEN); } if (stparent.st_ino == stinode) { trace_result(dctx,fdparent,fdparent,".",ELOOP,lconfpath); close(fdparent); - return SLBT_CUSTOM_ERROR( - dctx,SLBT_ERR_LCONF_OPEN); + + return (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_MASK) + ? (-1) + : SLBT_CUSTOM_ERROR( + dctx,SLBT_ERR_LCONF_OPEN); } fdlconfdir = fdparent; @@ -766,7 +773,8 @@ slbt_hidden int slbt_get_lconf_flags( /* open relative libtool script */ if ((fdlconf = slbt_lconf_open(dctx,lconf,fsilent,&val)) < 0) - return SLBT_NESTED_ERROR(dctx); + return (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_MASK) + ? (-1) : SLBT_NESTED_ERROR(dctx); /* cache the configuration in library friendly form) */ if (slbt_lib_get_txtfile_ctx(dctx,val,&ctx->lconfctx) < 0) diff --git a/src/logic/slbt_exec_stoolie.c b/src/logic/slbt_exec_stoolie.c index 698faaa..779146a 100644 --- a/src/logic/slbt_exec_stoolie.c +++ b/src/logic/slbt_exec_stoolie.c @@ -88,6 +88,7 @@ static int slbt_exec_stoolie_perform_actions( char auxdir[PATH_MAX]; char slibm4[PATH_MAX]; char ltmain[PATH_MAX]; + char arlib [PATH_MAX]; bool fslibm4; bool fltmain; @@ -101,11 +102,17 @@ static int slbt_exec_stoolie_perform_actions( return SLBT_BUFFER_ERROR(dctx); if (slbt_snprintf( - ltmain,sizeof(slibm4),"%s/%s", + ltmain,sizeof(ltmain),"%s/%s", SLBT_PACKAGE_DATADIR, "ltmain.sh") < 0) return SLBT_BUFFER_ERROR(dctx); + if (slbt_snprintf( + arlib,sizeof(arlib),"%s/%s", + SLBT_PACKAGE_DATADIR, + "ar-lib") < 0) + return SLBT_BUFFER_ERROR(dctx); + /* --force? */ if (dctx->cctx->drvflags & SLBT_DRIVER_STOOLIE_FORCE) { if (ictx->fdm4 >= 0) @@ -115,6 +122,9 @@ static int slbt_exec_stoolie_perform_actions( if (slbt_exec_stoolie_remove_file(dctx,ictx->fdaux,"ltmain.sh") < 0) return SLBT_NESTED_ERROR(dctx); + if (slbt_exec_stoolie_remove_file(dctx,ictx->fdaux,"ar-lib") < 0) + return SLBT_NESTED_ERROR(dctx); + fslibm4 = (ictx->fdm4 >= 0); fltmain = true; } else { @@ -158,6 +168,9 @@ static int slbt_exec_stoolie_perform_actions( if (slbt_util_copy_file(ectx,ltmain,auxdir) < 0) return SLBT_NESTED_ERROR(dctx); + + if (slbt_util_copy_file(ectx,arlib,auxdir) < 0) + return SLBT_NESTED_ERROR(dctx); } } else { /* default to symlinks */ @@ -170,7 +183,7 @@ static int slbt_exec_stoolie_perform_actions( SLBT_SYMLINK_LITERAL) < 0) return SLBT_NESTED_ERROR(dctx); - if (fltmain) + if (fltmain) { if (slbt_create_symlink_ex( dctx,ectx, ictx->fdaux, @@ -178,6 +191,15 @@ static int slbt_exec_stoolie_perform_actions( "ltmain.sh", SLBT_SYMLINK_LITERAL) < 0) return SLBT_NESTED_ERROR(dctx); + + if (slbt_create_symlink_ex( + dctx,ectx, + ictx->fdaux, + arlib, + "ar-lib", + SLBT_SYMLINK_LITERAL) < 0) + return SLBT_NESTED_ERROR(dctx); + } } return 0; diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c index 07f099d..8ae0833 100644 --- a/src/skin/slbt_skin_default.c +++ b/src/skin/slbt_skin_default.c @@ -46,6 +46,16 @@ const slbt_hidden struct argv_option slbt_default_options[] = { "for additional information, see the slibtoolize(1) " "manual page."}, + {"print-shared-ext", 0,TAG_PRINT_SHARED_EXT,ARGV_OPTARG_NONE, + ARGV_OPTION_HYBRID_ONLY,0,0, + "print the shared library extension for the specified " + "(or otherwise detected) host."}, + + {"print-static-ext", 0,TAG_PRINT_STATIC_EXT,ARGV_OPTARG_NONE, + ARGV_OPTION_HYBRID_ONLY,0,0, + "print the static library extension for the specified " + "(or otherwise detected) host."}, + {"finish", 0,TAG_FINISH,ARGV_OPTARG_NONE,0,0,0, "same as --mode=finish"}, |