summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-07-19 01:03:37 +0000
committermidipix <writeonce@midipix.org>2024-07-19 01:03:37 +0000
commit979507dfb71780d8ac2bd393d4e914e5578900f9 (patch)
tree4134f7ad4c3b4c0808ef6b715ce984bf36337c7a
parent64383cc119375fe535f7c5acd5bf93c74fe4e988 (diff)
downloadslibtool-979507dfb71780d8ac2bd393d4e914e5578900f9.tar.bz2
slibtool-979507dfb71780d8ac2bd393d4e914e5578900f9.tar.xz
driver: added the -print-shared-ext and -print-static-ext output commands.
-rw-r--r--include/slibtool/slibtool.h3
-rw-r--r--src/driver/slbt_amain.c22
-rw-r--r--src/driver/slbt_driver_ctx.c8
-rw-r--r--src/driver/slbt_split_argv.c13
-rw-r--r--src/internal/slibtool_driver_impl.h2
-rw-r--r--src/skin/slbt_skin_default.c10
6 files changed, 54 insertions, 4 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index f05de74..9336728 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -72,6 +72,9 @@ extern "C" {
#define SLBT_DRIVER_EXPORT_DYNAMIC SLBT_DRIVER_XFLAG(0x0010)
#define SLBT_DRIVER_STATIC_LIBTOOL_LIBS SLBT_DRIVER_XFLAG(0x0100)
+#define SLBT_DRIVER_OUTPUT_SHARED_EXT SLBT_DRIVER_XFLAG(0x0400)
+#define SLBT_DRIVER_OUTPUT_STATIC_EXT SLBT_DRIVER_XFLAG(0x0800)
+
#define SLBT_DRIVER_OUTPUT_MACHINE SLBT_DRIVER_XFLAG(0x1000)
#define SLBT_DRIVER_OUTPUT_CONFIG SLBT_DRIVER_XFLAG(0x2000)
#define SLBT_DRIVER_OUTPUT_AUX_DIR SLBT_DRIVER_XFLAG(0x4000)
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..c4f50b5 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -617,6 +617,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;
diff --git a/src/driver/slbt_split_argv.c b/src/driver/slbt_split_argv.c
index 71c1342..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;
@@ -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..3a1ca05 100644
--- a/src/internal/slibtool_driver_impl.h
+++ b/src/internal/slibtool_driver_impl.h
@@ -32,6 +32,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/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"},