summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver/slbt_amain.c3
-rw-r--r--src/driver/slbt_driver_ctx.c39
-rw-r--r--src/output/slbt_output_features.c40
3 files changed, 74 insertions, 8 deletions
diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c
index 48133b0..7d4a5a9 100644
--- a/src/driver/slbt_amain.c
+++ b/src/driver/slbt_amain.c
@@ -56,6 +56,9 @@ static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx)
if (dctx->cctx->drvflags & SLBT_DRIVER_CONFIG)
slbt_output_config(dctx);
+ if (dctx->cctx->drvflags & SLBT_DRIVER_FEATURES)
+ slbt_output_features(dctx);
+
if (dctx->cctx->mode == SLBT_MODE_COMPILE)
slbt_exec_compile(dctx,0);
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];
diff --git a/src/output/slbt_output_features.c b/src/output/slbt_output_features.c
new file mode 100644
index 0000000..b0252fa
--- /dev/null
+++ b/src/output/slbt_output_features.c
@@ -0,0 +1,40 @@
+/*******************************************************************/
+/* slibtool: a skinny libtool implementation, written in C */
+/* Copyright (C) 2016--2017 Z. Gilboa */
+/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
+/*******************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include <slibtool/slibtool.h>
+#include "slibtool_errinfo_impl.h"
+
+static const char enable[] = "enable";
+static const char disable[] = "disable";
+
+int slbt_output_features(const struct slbt_driver_ctx * dctx)
+{
+ const char * shared_option;
+ const char * static_option;
+
+ shared_option = (dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_SHARED)
+ ? disable : enable;
+
+ static_option = (dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_STATIC)
+ ? disable : enable;
+
+ if (fprintf(stdout,"host: %s\n",dctx->cctx->host.host) < 0)
+ return SLBT_SYSTEM_ERROR(dctx);
+
+ if (fprintf(stdout,"%s shared libraries\n",shared_option) < 0)
+ return SLBT_SYSTEM_ERROR(dctx);
+
+ if (fprintf(stdout,"%s static libraries\n",static_option) < 0)
+ return SLBT_SYSTEM_ERROR(dctx);
+
+ return fflush(stdout)
+ ? SLBT_SYSTEM_ERROR(dctx)
+ : 0;
+}