summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-04-01 04:14:04 +0000
committermidipix <writeonce@midipix.org>2024-04-01 04:14:04 +0000
commit8056668eebf28eec3101cf567b63a0600e40f36d (patch)
treedbb23c361237f1cf6b884560b6b6e0d056e1da6b /src
parent78607f18014baed2cae9bc1b133dbf2be54cc1e9 (diff)
downloadslibtool-8056668eebf28eec3101cf567b63a0600e40f36d.tar.bz2
slibtool-8056668eebf28eec3101cf567b63a0600e40f36d.tar.xz
driver: added -print-aux-dir and -print-m4-dir (for slibtool.m4 integration).
Diffstat (limited to 'src')
-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.c14
-rw-r--r--src/internal/slibtool_driver_impl.h2
-rw-r--r--src/skin/slbt_skin_default.c13
5 files changed, 55 insertions, 4 deletions
diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c
index 73d1462..e0f4241 100644
--- a/src/driver/slbt_amain.c
+++ b/src/driver/slbt_amain.c
@@ -57,6 +57,16 @@ static ssize_t slbt_version(struct slbt_driver_ctx * dctx, int fdout)
verclr[5],gitver ? "]" : "");
}
+static ssize_t slbt_print_aux_dir(int fdout)
+{
+ return slbt_dprintf(fdout,"%s\n",SLBT_PACKAGE_DATADIR);
+}
+
+static ssize_t slbt_print_m4_dir(int fdout)
+{
+ return slbt_dprintf(fdout,"%s\n",SLBT_PACKAGE_DATADIR);
+}
+
static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx)
{
if (dctx->cctx->drvflags & SLBT_DRIVER_INFO)
@@ -197,6 +207,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-aux-dir must be the first (and only) action */
+ if (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_AUX_DIR)
+ return (slbt_print_aux_dir(fdout) < 0)
+ ? slbt_exit(dctx,SLBT_ERROR)
+ : slbt_exit(dctx,SLBT_OK);
+
+ /* -print-m4-dir must be the first (and only) action */
+ if (dctx->cctx->drvflags & SLBT_DRIVER_OUTPUT_M4_DIR)
+ return (slbt_print_m4_dir(fdout) < 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 e24942e..76c7c4a 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -609,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;
diff --git a/src/driver/slbt_split_argv.c b/src/driver/slbt_split_argv.c
index 7ad20a3..8fd131a 100644
--- a/src/driver/slbt_split_argv.c
+++ b/src/driver/slbt_split_argv.c
@@ -59,6 +59,7 @@ slbt_hidden int slbt_split_argv(
struct argv_entry * features;
struct argv_entry * ccwrap;
struct argv_entry * dumpmachine;
+ struct argv_entry * printdir;
struct argv_entry * aropt;
struct argv_entry * stoolieopt;
const struct argv_option ** popt;
@@ -124,7 +125,8 @@ slbt_hidden int slbt_split_argv(
}
/* missing all of --mode, --help, --version, --info, --config, --dumpmachine, --features, and --finish? */
- mode = help = version = info = config = finish = features = ccwrap = dumpmachine = aropt = stoolieopt = 0;
+ /* as well as -print-aux-dir and -print-m4-dir? */
+ mode = help = version = info = config = finish = features = ccwrap = dumpmachine = printdir = aropt = stoolieopt = 0;
for (entry=meta->entries; entry->fopt; entry++)
if (entry->tag == TAG_MODE)
@@ -145,6 +147,10 @@ slbt_hidden int slbt_split_argv(
ccwrap = entry;
else if (entry->tag == TAG_DUMPMACHINE)
dumpmachine = entry;
+ else if (entry->tag == TAG_PRINT_AUX_DIR)
+ printdir = entry;
+ else if (entry->tag == TAG_PRINT_M4_DIR)
+ printdir = entry;
/* alternate execusion mode? */
if (!altmode && mode && !strcmp(mode->arg,"ar"))
@@ -169,7 +175,7 @@ slbt_hidden int slbt_split_argv(
return -1;
}
- if (!mode && !help && !version && !info && !config && !finish && !features && !dumpmachine && !altmode) {
+ if (!mode && !help && !version && !info && !config && !finish && !features && !dumpmachine && !printdir && !altmode) {
slbt_dprintf(fderr,
"%s: error: --mode must be specified.\n",
program);
@@ -177,7 +183,7 @@ slbt_hidden int slbt_split_argv(
}
/* missing compiler? */
- if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine) {
+ if (!ctx.unitidx && !help && !info && !config && !version && !finish && !features && !dumpmachine && !printdir) {
if (!altmode && !aropt && !stoolieopt) {
if (flags & SLBT_DRIVER_VERBOSITY_ERRORS)
slbt_dprintf(fderr,
@@ -339,7 +345,7 @@ slbt_hidden int slbt_split_argv(
if (ctx.unitidx) {
(void)0;
- } else if (help || version || features || info || config || dumpmachine || altmode) {
+ } else if (help || version || features || info || config || dumpmachine || printdir || 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 7cbea42..429cdc4 100644
--- a/src/internal/slibtool_driver_impl.h
+++ b/src/internal/slibtool_driver_impl.h
@@ -30,6 +30,8 @@ enum app_tags {
TAG_CONFIG,
TAG_MKVARS,
TAG_DUMPMACHINE,
+ TAG_PRINT_AUX_DIR,
+ TAG_PRINT_M4_DIR,
TAG_DEBUG,
TAG_DRY_RUN,
TAG_FEATURES,
diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c
index 476e36e..07f099d 100644
--- a/src/skin/slbt_skin_default.c
+++ b/src/skin/slbt_skin_default.c
@@ -33,6 +33,19 @@ const slbt_hidden struct argv_option slbt_default_options[] = {
"however its addition is expected before the "
"next major release."},
+ {"print-aux-dir", 0,TAG_PRINT_AUX_DIR,ARGV_OPTARG_NONE,
+ ARGV_OPTION_HYBRID_ONLY,0,0,
+ "print the directory of the package-installed, "
+ "backward-compatible ltmain.sh and slibtool.sh; "
+ "for additional information, see the slibtoolize(1) "
+ "manual page."},
+
+ {"print-m4-dir", 0,TAG_PRINT_M4_DIR,ARGV_OPTARG_NONE,
+ ARGV_OPTION_HYBRID_ONLY,0,0,
+ "print the directory of the package-installed slibtool.m4; "
+ "for additional information, see the slibtoolize(1) "
+ "manual page."},
+
{"finish", 0,TAG_FINISH,ARGV_OPTARG_NONE,0,0,0,
"same as --mode=finish"},