diff --git a/Makefile.am b/Makefile.am index b2b666ecee..2fdc256580 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,12 +33,12 @@ ACLOCAL_AMFLAGS = -I config/m4 # header file creation so we'll use good old make if MAINTAINER_MODE BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \ - src/builtin.inc src/version.h + src/builtin.inc src/config_opts.inc src/version.h src/lexer.c: src/lexer.l $(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $< src/lexer.h: src/lexer.c else -BUILT_SOURCES = src/builtin.inc src/version.h +BUILT_SOURCES = src/builtin.inc src/config_opts.inc src/version.h .y.c: $(AM_V_YACC) echo "NOT building parser.c!" .l.c: @@ -109,14 +109,20 @@ generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | sed src/version.h: .remake-version-h mkdir -p src $(AM_V_GEN) $(generate_ver); echo "$$ver" > $@ -src/main.c: src/version.h +src/config_opts.inc: + mkdir -p src + $(AM_V_GEN) if test -x ./config.status; then \ + ./config.status --config; \ + else echo "(unknown)"; \ + fi | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' -e 's/^/#define JQ_CONFIG /' > $@ +src/main.c: src/version.h src/config_opts.inc src/builtin.inc: $(srcdir)/src/builtin.jq mkdir -p src $(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $(srcdir)/src/builtin.jq > $@ src/builtin.o: src/builtin.inc -CLEANFILES = src/version.h .remake-version-h src/builtin.inc +CLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc bin_PROGRAMS = jq jq_SOURCES = src/main.c src/version.h diff --git a/docs/content/manual/manual.yml b/docs/content/manual/manual.yml index cebc0d8835..832e69260d 100644 --- a/docs/content/manual/manual.yml +++ b/docs/content/manual/manual.yml @@ -301,6 +301,12 @@ sections: Output the jq version and exit with zero. + * `--build-configuration`: + + Output the build configuration of jq and exit with zero. + This output has no supported format or structure and may change + without notice in future releases. + * `--help` / `-h`: Output the jq help and exit with zero. diff --git a/jq.1.prebuilt b/jq.1.prebuilt index e6ccd1815f..3080978c53 100644 --- a/jq.1.prebuilt +++ b/jq.1.prebuilt @@ -235,6 +235,12 @@ Windows users using WSL, MSYS2, or Cygwin, should use this option when using a n Output the jq version and exit with zero\. . .TP +\fB\-\-build\-configuration\fR: +. +.IP +Output the build configuration of jq and exit with zero\. This output has no supported format or structure and may change without notice in future releases\. +. +.TP \fB\-\-help\fR / \fB\-h\fR: . .IP diff --git a/src/main.c b/src/main.c index 2b00ce295a..f76fde567d 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,7 @@ extern void jv_tsd_dtoa_ctx_init(); #include "jv_alloc.h" #include "util.h" #include "src/version.h" +#include "src/config_opts.inc" int jq_testsuite(jv lib_dirs, int verbose, int argc, char* argv[]); @@ -580,6 +581,11 @@ int main(int argc, char* argv[]) { ret = JQ_OK; goto out; } + if (isoption(argv[i], 0, "build-configuration", &short_opts)) { + printf("%s\n", JQ_CONFIG); + ret = JQ_OK; + goto out; + } if (isoption(argv[i], 0, "run-tests", &short_opts)) { i++; // XXX Pass program_arguments, even a whole jq_state *, through;