diff options
author | midipix <writeonce@midipix.org> | 2024-04-01 04:14:04 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-04-01 04:14:04 +0000 |
commit | 8056668eebf28eec3101cf567b63a0600e40f36d (patch) | |
tree | dbb23c361237f1cf6b884560b6b6e0d056e1da6b /src/driver | |
parent | 78607f18014baed2cae9bc1b133dbf2be54cc1e9 (diff) | |
download | slibtool-8056668eebf28eec3101cf567b63a0600e40f36d.tar.bz2 slibtool-8056668eebf28eec3101cf567b63a0600e40f36d.tar.xz |
driver: added -print-aux-dir and -print-m4-dir (for slibtool.m4 integration).
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/slbt_amain.c | 22 | ||||
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 8 | ||||
-rw-r--r-- | src/driver/slbt_split_argv.c | 14 |
3 files changed, 40 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]; |