Skip to content

Commit

Permalink
Add --config option printing ./configure options used
Browse files Browse the repository at this point in the history
  • Loading branch information
nicowilliams committed Aug 4, 2023
1 parent dcaf701 commit 2232b47
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions docs/content/manual/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions jq.1.prebuilt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[]);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2232b47

Please sign in to comment.