Move closer to the standard autotools idiom. (#3187)

* Create `src/config.h` instead of passing everything on the compiler
  command line.

* To reduce the magnitude of this change, add `--include src/config.h`
  to CFLAGS instead of adding `#include "src/config.h"` at the top of
  each source file.  Not all compilers support this, but I don't think
  we care about anything other than gcc and clang at this point.

* Rather than generate `src/config_opts.inc`, emit `JQ_CONFIG` directly
  into `src/config.h`.

* Rather than generate `src/version.h`, define `JQ_VERSION` as an alias
  for the standard `PACKAGE_VERSION`.
This commit is contained in:
Dag-Erling Smørgrav authored and GitHub committed 2025-01-25 17:10:05 +09:00
1 parent 71ed7b3412
commit d8463c2549
7 files changed
+20 -36

No files matched your search

+5 -23
View File
@@ -34,12 +34,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/config_opts.inc src/version.h
src/builtin.inc
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/config_opts.inc src/version.h
BUILT_SOURCES = src/builtin.inc
.y.c:
$(AM_V_YACC) echo "NOT building parser.c!"
.l.c:
@@ -101,23 +101,6 @@ endif
### Building the jq binary
# Remake the version.h header file if, and only if, the git ID has changed
.PHONY: .FORCE
.FORCE:
generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | sed 's/.*/\#define JQ_VERSION \"&\"/'`"
.remake-version-h: .FORCE
@ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
src/version.h: .remake-version-h
mkdir -p src
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
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/$$/"/' -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) od -v -A n -t o1 -- $< | \
@@ -128,10 +111,10 @@ src/builtin.inc: $(srcdir)/src/builtin.jq
-e 's/ \([123456789]\)/ 0\1/g' > $@
src/builtin.o: src/builtin.inc
CLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc
CLEANFILES = src/builtin.inc
bin_PROGRAMS = jq
jq_SOURCES = src/main.c src/version.h
jq_SOURCES = src/main.c
jq_LDFLAGS = -static-libtool-libs
jq_LDADD = libjq.la -lm
@@ -216,8 +199,7 @@ DOC_FILES = docs/content docs/public docs/templates \
EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \
src/parser.h src/version.h src/builtin.jq scripts/version \
libjq.pc \
src/parser.h src/builtin.jq scripts/version libjq.pc \
tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \
tests/modules/c/d.jq tests/modules/data.json \
tests/modules/home1/.jq tests/modules/home2/.jq/g.jq \