summaryrefslogtreecommitdiff
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
parent621608e6c6a0714966a4ceddaf5631d90db57d3f (diff)
downloadslibtool-23b10108b56a851debb4d1e142e64b6d155e1fc3.tar.bz2
slibtool-23b10108b56a851debb4d1e142e64b6d155e1fc3.tar.xz
driver: added slbt_output_features(), providing compatible --features output.
-rw-r--r--include/slibtool/slibtool.h1
-rw-r--r--project/common.mk1
-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
5 files changed, 76 insertions, 8 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index 68fa139..2f7355e 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -283,6 +283,7 @@ slbt_api int slbt_dump_machine (const char * compiler, char * machine, size_t
/* utility api */
slbt_api int slbt_main (int, char **, char **);
slbt_api int slbt_output_config (const struct slbt_driver_ctx *);
+slbt_api int slbt_output_features (const struct slbt_driver_ctx *);
slbt_api int slbt_output_exec (const struct slbt_driver_ctx *, const struct slbt_exec_ctx *, const char *);
slbt_api int slbt_output_compile (const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
slbt_api int slbt_output_execute (const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
diff --git a/project/common.mk b/project/common.mk
index d8eca7c..f41ee7a 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -13,6 +13,7 @@ API_SRCS = \
src/output/slbt_output_config.c \
src/output/slbt_output_error.c \
src/output/slbt_output_exec.c \
+ src/output/slbt_output_features.c \
src/skin/slbt_skin_default.c \
src/skin/slbt_skin_install.c \
src/skin/slbt_skin_uninstall.c \
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;
+}