summaryrefslogtreecommitdiffhomepage
path: root/src/driver/slbt_driver_ctx.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-06-23 01:35:08 -0400
committermidipix <writeonce@midipix.org>2018-06-23 02:06:50 -0400
commit23b10108b56a851debb4d1e142e64b6d155e1fc3 (patch)
tree25820604a7e66553e014a6415142179a88f65820 /src/driver/slbt_driver_ctx.c
parent621608e6c6a0714966a4ceddaf5631d90db57d3f (diff)
downloadslibtool-23b10108b56a851debb4d1e142e64b6d155e1fc3.tar.bz2
slibtool-23b10108b56a851debb4d1e142e64b6d155e1fc3.tar.xz
driver: added slbt_output_features(), providing compatible --features output.
Diffstat (limited to 'src/driver/slbt_driver_ctx.c')
-rw-r--r--src/driver/slbt_driver_ctx.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index 2f08895..5b11848 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -45,6 +45,10 @@ static const char cfgnmachine[] = "native (derived from -dumpmachine)";
static const char cfgxmachine[] = "foreign (derived from -dumpmachine)";
static const char cfgnative[] = "native";
+
+/* default compiler argv */
+static char * slbt_default_cargv[] = {"cc",0};
+
/* elf rpath */
static const char*ldrpath_elf[] = {
"/lib",
@@ -191,6 +195,7 @@ static int slbt_split_argv(
struct argv_entry * mode;
struct argv_entry * config;
struct argv_entry * finish;
+ struct argv_entry * features;
const struct argv_option ** popt;
const struct argv_option ** optout;
const struct argv_option * optv[SLBT_OPTV_ELEMENTS];
@@ -219,24 +224,32 @@ static int slbt_split_argv(
}
/* obtain slibtool's own arguments */
- compiler = argv[ctx.unitidx];
- argv[ctx.unitidx] = 0;
+ if (ctx.unitidx) {
+ compiler = argv[ctx.unitidx];
+ argv[ctx.unitidx] = 0;
+
+ meta = argv_get(argv,optv,ARGV_VERBOSITY_NONE);
+ argv[ctx.unitidx] = compiler;
+ } else {
+ meta = argv_get(argv,optv,ARGV_VERBOSITY_NONE);
+ }
- meta = argv_get(argv,optv,ARGV_VERBOSITY_NONE);
- argv[ctx.unitidx] = compiler;
+ /* missing all of --mode, --config, --features, and --finish? */
+ mode = config = finish = features = 0;
- /* missing all of --mode, --config, and --finish? */
- for (mode=0, config=0, finish=0, entry=meta->entries; entry->fopt; entry++)
+ for (entry=meta->entries; entry->fopt; entry++)
if (entry->tag == TAG_MODE)
mode = entry;
else if (entry->tag == TAG_CONFIG)
config = entry;
else if (entry->tag == TAG_FINISH)
finish = entry;
+ else if (entry->tag == TAG_FEATURES)
+ features = entry;
argv_free(meta);
- if (!mode && !config && !finish) {
+ if (!mode && !config && !finish && !features) {
fprintf(stderr,
"%s: error: --mode must be specified.\n",
program);
@@ -244,7 +257,7 @@ static int slbt_split_argv(
}
/* missing compiler? */
- if (!ctx.unitidx && !finish) {
+ if (!ctx.unitidx && !finish && !features) {
if (flags & SLBT_DRIVER_VERBOSITY_ERRORS)
fprintf(stderr,
"%s: error: <compiler> is missing.\n",
@@ -261,6 +274,16 @@ static int slbt_split_argv(
else
return -1;
+ /* --features and no <compiler>? */
+ if (features && !ctx.unitidx) {
+ for (i=0; i<argc; i++)
+ sargv->targv[i] = argv[i];
+
+ sargv->cargv = slbt_default_cargv;
+
+ return 0;
+ }
+
/* split vectors: slibtool's own options */
for (i=0; i<ctx.unitidx; i++)
sargv->targv[i] = argv[i];