2015-05-18 12:07:29 -05:00
|
|
|
|
2013-05-09 20:27:12 +01:00
|
|
|
### C source files to be built and distributed.
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2015-08-23 20:36:11 -07:00
|
|
|
LIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h \
|
|
|
|
src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h \
|
|
|
|
src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h \
|
|
|
|
src/linker.h src/locfile.h src/opcode_list.h src/parser.y \
|
|
|
|
src/util.h
|
|
|
|
|
|
|
|
LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \
|
|
|
|
src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c \
|
|
|
|
src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c \
|
|
|
|
src/jv_unicode.c src/linker.c src/locfile.c src/util.c \
|
2018-10-19 21:57:41 +03:00
|
|
|
src/decNumber/decContext.c src/decNumber/decNumber.c \
|
|
|
|
src/jv_dtoa_tsd.c \
|
2015-08-23 20:36:11 -07:00
|
|
|
${LIBJQ_INCS}
|
2013-05-08 02:30:08 +01:00
|
|
|
|
|
|
|
### C build options
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2015-08-22 15:31:47 -07:00
|
|
|
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
|
|
|
|
-Wno-unused-parameter -Wno-unused-function
|
2013-05-08 02:30:08 +01:00
|
|
|
|
2019-02-12 21:33:46 +10:00
|
|
|
if WIN32
|
|
|
|
AM_CFLAGS += -municode
|
|
|
|
endif
|
|
|
|
|
2013-06-23 11:47:42 +01:00
|
|
|
ACLOCAL_AMFLAGS = -I config/m4
|
2013-05-08 02:30:08 +01:00
|
|
|
|
|
|
|
### Generating the lexer and parser
|
|
|
|
|
|
|
|
# While there is some autoconf macro support for lex/flex, it doesn't support
|
|
|
|
# header file creation so we'll use good old make
|
2015-02-15 17:57:53 -06:00
|
|
|
if MAINTAINER_MODE
|
2015-10-22 22:33:47 -05:00
|
|
|
BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \
|
|
|
|
src/builtin.inc src/version.h
|
2015-08-23 20:36:11 -07:00
|
|
|
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
|
2015-02-15 17:57:53 -06:00
|
|
|
else
|
2016-01-15 16:06:18 -06:00
|
|
|
BUILT_SOURCES = src/builtin.inc src/version.h
|
2015-02-15 17:57:53 -06:00
|
|
|
.y.c:
|
|
|
|
$(AM_V_YACC) echo "NOT building parser.c!"
|
|
|
|
.l.c:
|
|
|
|
$(AM_V_LEX) echo "NOT building lexer.c!"
|
|
|
|
endif
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2012-11-28 01:08:23 -06:00
|
|
|
# Tell YACC (bison) autoconf macros that you want a header file created.
|
|
|
|
# If the --warnings=all fails, you probably have an old version of bison
|
|
|
|
# OSX ships an old bison, so update with homebrew or macports
|
|
|
|
AM_YFLAGS = --warnings=all -d
|
|
|
|
|
2013-06-16 08:25:12 -05:00
|
|
|
### libjq
|
|
|
|
|
|
|
|
lib_LTLIBRARIES = libjq.la
|
|
|
|
libjq_la_SOURCES = ${LIBJQ_SRC}
|
|
|
|
libjq_la_LIBADD = -lm
|
2017-01-26 23:29:00 -05:00
|
|
|
libjq_la_LDFLAGS = $(onig_LDFLAGS) -export-symbols-regex '^j[qv]_' -version-info 1:4:0
|
2013-06-16 08:25:12 -05:00
|
|
|
|
2016-01-15 16:06:30 -06:00
|
|
|
if WIN32
|
|
|
|
libjq_la_LIBADD += -lshlwapi
|
2018-12-26 02:45:54 +00:00
|
|
|
libjq_la_LDFLAGS += -no-undefined
|
2016-01-15 16:06:30 -06:00
|
|
|
endif
|
|
|
|
|
2015-08-23 20:36:11 -07:00
|
|
|
include_HEADERS = src/jv.h src/jq.h
|
2013-06-16 08:25:12 -05:00
|
|
|
|
2016-01-17 12:09:43 -06:00
|
|
|
if ENABLE_UBSAN
|
|
|
|
AM_CFLAGS += -fsanitize=undefined
|
|
|
|
endif
|
|
|
|
|
2018-12-26 12:52:22 -06:00
|
|
|
AM_CPPFLAGS = -I$(srcdir)/src
|
|
|
|
|
2015-06-27 09:52:12 -07:00
|
|
|
### Running tests under Valgrind
|
|
|
|
|
2015-10-27 19:01:06 -05:00
|
|
|
if ENABLE_ASAN
|
|
|
|
AM_CFLAGS += -fsanitize=address
|
|
|
|
NO_VALGRIND = 1
|
|
|
|
else
|
2015-06-27 09:52:12 -07:00
|
|
|
if ENABLE_VALGRIND
|
|
|
|
NO_VALGRIND =
|
|
|
|
else
|
|
|
|
NO_VALGRIND = 1
|
|
|
|
endif
|
2015-10-27 19:01:06 -05:00
|
|
|
endif
|
2015-06-27 09:52:12 -07:00
|
|
|
|
2015-06-27 10:16:13 -07:00
|
|
|
### Code coverage with gcov
|
|
|
|
|
|
|
|
if ENABLE_GCOV
|
|
|
|
AM_CFLAGS += --coverage --no-inline
|
|
|
|
endif
|
|
|
|
|
2015-05-03 19:23:37 -05:00
|
|
|
### Error injection for testing
|
|
|
|
|
|
|
|
if ENABLE_ERROR_INJECTION
|
|
|
|
lib_LTLIBRARIES += libinject_errors.la
|
2015-08-23 20:36:11 -07:00
|
|
|
libinject_errors_la_SOURCES = src/inject_errors.c
|
2015-05-03 19:23:37 -05:00
|
|
|
libinject_errors_la_LIBADD = -ldl
|
|
|
|
libinject_errors_la_LDFLAGS = -module
|
|
|
|
endif
|
2013-02-03 14:49:03 -06:00
|
|
|
|
2013-05-08 02:30:08 +01:00
|
|
|
### Building the jq binary
|
2013-02-03 14:49:03 -06:00
|
|
|
|
2013-05-25 23:46:20 +01:00
|
|
|
# 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
|
2015-08-23 20:36:11 -07:00
|
|
|
@ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
|
|
|
|
src/version.h: .remake-version-h
|
2018-11-05 23:16:39 +08:00
|
|
|
mkdir -p src
|
2013-05-25 23:46:20 +01:00
|
|
|
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
|
2015-08-23 20:36:11 -07:00
|
|
|
src/main.c: src/version.h
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2019-05-29 20:36:18 +01:00
|
|
|
src/builtin.inc: $(srcdir)/src/builtin.jq
|
2018-11-05 23:16:39 +08:00
|
|
|
mkdir -p src
|
2019-05-29 20:36:18 +01:00
|
|
|
$(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $(srcdir)/src/builtin.jq > $@
|
2015-10-22 22:33:47 -05:00
|
|
|
src/builtin.o: src/builtin.inc
|
2015-10-17 23:24:13 -07:00
|
|
|
|
2013-05-08 02:30:08 +01:00
|
|
|
bin_PROGRAMS = jq
|
2015-08-23 20:36:11 -07:00
|
|
|
jq_SOURCES = src/main.c src/version.h
|
2013-06-22 20:53:28 +01:00
|
|
|
jq_LDFLAGS = -static-libtool-libs
|
2013-06-16 08:25:12 -05:00
|
|
|
jq_LDADD = libjq.la -lm
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2017-02-25 14:15:18 -06:00
|
|
|
if WIN32
|
|
|
|
jq_LDADD += -lshlwapi
|
|
|
|
endif
|
|
|
|
|
2015-05-25 21:19:56 -05:00
|
|
|
if ENABLE_ALL_STATIC
|
2015-05-18 12:07:29 -05:00
|
|
|
jq_LDFLAGS += -all-static
|
|
|
|
endif
|
|
|
|
|
2013-05-09 11:31:17 +01:00
|
|
|
### Tests (make check)
|
2013-02-04 07:01:18 -06:00
|
|
|
|
2016-01-24 23:30:28 +00:00
|
|
|
TESTS = tests/optionaltest tests/mantest tests/jqtest tests/onigtest tests/shtest tests/utf8test tests/base64test
|
2015-06-27 09:52:12 -07:00
|
|
|
TESTS_ENVIRONMENT = NO_VALGRIND=$(NO_VALGRIND)
|
2013-02-04 07:01:18 -06:00
|
|
|
|
2019-10-22 12:37:19 -04:00
|
|
|
# This is a magic make variable that causes it to treat tests/man.test as a
|
|
|
|
# DATA-type dependency for the check target. As a result, it will attempt to
|
|
|
|
# run any defined targets for tests/man.test as a dependency for check. This
|
|
|
|
# allows us to ensure that the tests are up-to-date if the manual has been updated
|
|
|
|
check_DATA = tests/man.test
|
|
|
|
|
|
|
|
### Building the man tests
|
|
|
|
|
|
|
|
# We use the examples in the manual as additional tests, to ensure they always work.
|
|
|
|
# As a result, we need to rebuild the tests if the manual has been updated.
|
|
|
|
# Making changes to the manpage without having the python deps means your
|
|
|
|
# tests won't run. If you aren't making changes to the examples, you probably
|
|
|
|
# don't care. But if you are, then you need to run the tests anyway.
|
|
|
|
tests/man.test: $(srcdir)/docs/content/manual/manual.yml
|
|
|
|
if ENABLE_DOCS
|
|
|
|
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_mantests.py ) > $@
|
|
|
|
else
|
|
|
|
@echo Changes to the manual.yml require docs to be enabled to run the tests
|
|
|
|
@false
|
|
|
|
endif
|
2012-11-28 01:08:23 -06:00
|
|
|
|
2013-05-09 11:31:17 +01:00
|
|
|
### Building the manpage
|
|
|
|
|
2019-10-22 12:37:19 -04:00
|
|
|
# We build the docs from the manpage yml. If no changes have been made to the
|
|
|
|
# manpage, then we'll end up using the cached version. Otherwise, we need to
|
|
|
|
# rebuild it.
|
2013-05-09 11:31:17 +01:00
|
|
|
man_MANS = jq.1
|
2019-10-22 12:37:19 -04:00
|
|
|
jq.1.prebuilt: $(srcdir)/docs/content/manual/manual.yml
|
2013-05-09 15:22:38 +01:00
|
|
|
if ENABLE_DOCS
|
2019-10-22 12:37:19 -04:00
|
|
|
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_manpage.py ) > $@ || { rm -f $@; false; }
|
2013-05-09 15:22:38 +01:00
|
|
|
else
|
2019-10-22 12:37:19 -04:00
|
|
|
@echo Changes to the manual.yml require docs to be enabled to generate an updated manpage
|
|
|
|
@echo As a result, your manpage is out of date.
|
2013-05-09 15:22:38 +01:00
|
|
|
endif
|
2013-05-09 11:31:17 +01:00
|
|
|
|
2019-10-22 12:37:19 -04:00
|
|
|
jq.1: jq.1.prebuilt
|
2020-03-03 16:23:45 +00:00
|
|
|
$(AM_V_GEN) cp $(srcdir)/jq.1.prebuilt $@
|
2013-05-09 11:31:17 +01:00
|
|
|
|
2017-01-26 23:29:00 -05:00
|
|
|
### Build oniguruma
|
|
|
|
|
|
|
|
if BUILD_ONIGURUMA
|
|
|
|
libjq_la_LIBADD += modules/oniguruma/src/.libs/libonig.la
|
|
|
|
SUBDIRS = modules/oniguruma
|
|
|
|
endif
|
|
|
|
|
|
|
|
AM_CFLAGS += $(onig_CFLAGS)
|
|
|
|
|
2013-05-08 02:30:08 +01:00
|
|
|
### Packaging
|
2012-11-28 01:08:23 -06:00
|
|
|
|
2013-05-08 19:57:29 +01:00
|
|
|
docs/site.yml: configure.ac
|
2013-05-19 10:48:25 +01:00
|
|
|
sed 's/^jq_version: .*/jq_version: "$(VERSION)"/' $@ > $@.new
|
2013-05-08 19:57:29 +01:00
|
|
|
mv $@.new $@
|
|
|
|
|
2013-05-09 01:50:20 +01:00
|
|
|
install-binaries: $(BUILT_SOURCES)
|
|
|
|
$(MAKE) $(AM_MAKEFLAGS) install-exec
|
|
|
|
|
2015-08-22 15:31:47 -07:00
|
|
|
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
2019-02-20 20:53:10 -05:00
|
|
|
docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \
|
|
|
|
docs/build_manpage.py docs/README.md jq.1.prebuilt
|
2013-05-09 20:53:51 +01:00
|
|
|
|
2015-08-22 16:20:21 -07:00
|
|
|
EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
|
2015-08-23 20:36:11 -07:00
|
|
|
jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \
|
2019-02-20 22:53:37 -05:00
|
|
|
src/parser.h src/version.h src/builtin.jq scripts/version \
|
2019-03-29 13:25:39 +01:00
|
|
|
libjq.pc \
|
2019-02-20 22:53:37 -05:00
|
|
|
tests/base64.test tests/jq-f-test.sh tests/jq.test \
|
2015-08-22 16:20:21 -07:00
|
|
|
tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \
|
|
|
|
tests/modules/c/d.jq tests/modules/data.json \
|
2019-02-20 22:53:37 -05:00
|
|
|
tests/modules/home1/.jq tests/modules/home2/.jq/g.jq \
|
2015-08-22 15:31:47 -07:00
|
|
|
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
|
2019-02-20 23:05:29 -05:00
|
|
|
tests/modules/shadow1.jq tests/modules/shadow2.jq \
|
2015-08-22 15:31:47 -07:00
|
|
|
tests/modules/syntaxerror/syntaxerror.jq \
|
|
|
|
tests/modules/test_bind_order.jq \
|
|
|
|
tests/modules/test_bind_order0.jq \
|
|
|
|
tests/modules/test_bind_order1.jq \
|
2018-10-19 21:57:41 +03:00
|
|
|
tests/modules/test_bind_order2.jq \
|
|
|
|
tests/onig.supp tests/local.supp \
|
|
|
|
tests/onig.test tests/setup tests/torture/input0.json \
|
|
|
|
tests/optional.test tests/optionaltest \
|
|
|
|
tests/utf8-truncate.jq tests/utf8test \
|
|
|
|
tests/base64.test tests/base64test \
|
|
|
|
tests/jq-f-test.sh tests/shtest
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2023-06-13 07:01:20 -04:00
|
|
|
# README.md is expected in GitHub projects, good stuff in it, so we'll
|
2013-05-08 02:30:08 +01:00
|
|
|
# distribute it and install it with the package in the doc directory.
|
|
|
|
docdir = ${datadir}/doc/${PACKAGE}
|
2013-05-08 18:55:10 +01:00
|
|
|
dist_doc_DATA = README.md COPYING AUTHORS README
|
2012-11-28 01:08:23 -06:00
|
|
|
|
2019-03-29 13:25:39 +01:00
|
|
|
pkgconfigdir = $(libdir)/pkgconfig
|
|
|
|
pkgconfig_DATA = libjq.pc
|
|
|
|
|
2012-11-27 16:02:59 -06:00
|
|
|
RELEASE ?= 1
|
2013-10-16 12:24:27 -04:00
|
|
|
rpm: dist jq.spec
|
2012-11-27 16:02:59 -06:00
|
|
|
@echo "Packaging jq as an RPM ..."
|
2012-12-03 17:27:40 -06:00
|
|
|
mkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS
|
2013-10-16 12:24:27 -04:00
|
|
|
cp jq-$(VERSION).tar.gz rpm/SOURCES/
|
|
|
|
rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $(VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$(VERSION).tar.gz
|
2012-12-04 16:29:01 -06:00
|
|
|
find rpm/RPMS/ -name "*.rpm" -exec mv {} ./ \;
|
2012-12-03 17:27:40 -06:00
|
|
|
rm -rf rpm
|
2012-11-28 01:08:23 -06:00
|
|
|
|
|
|
|
dist-clean-local:
|
2013-02-03 14:49:03 -06:00
|
|
|
rm -f ${BUILT_SOURCES}
|
2013-02-04 13:35:42 -06:00
|
|
|
|
|
|
|
# Not sure why this doesn't get cleaned up automatically, guess
|
|
|
|
# automake used to man pages which are hand coded?
|
2013-05-23 19:20:19 +01:00
|
|
|
# 'make clean' doesn't delete the manpage if it can't be rebuilt
|
2013-05-25 23:46:20 +01:00
|
|
|
clean-local-docs:
|
|
|
|
if ENABLE_DOCS
|
2013-02-04 13:35:42 -06:00
|
|
|
rm -f jq.1
|
2015-08-13 22:33:37 -07:00
|
|
|
endif
|
2013-05-25 23:46:20 +01:00
|
|
|
|
2015-06-27 10:16:13 -07:00
|
|
|
clean-local-gcov:
|
2015-08-23 20:36:11 -07:00
|
|
|
rm -f src/*.gcno src/*.gcda src/*.gcov
|
2015-06-27 10:16:13 -07:00
|
|
|
|
|
|
|
clean-local: clean-local-docs clean-local-gcov
|
2015-08-23 20:36:11 -07:00
|
|
|
rm -f src/version.h .remake-version-h
|
2015-06-27 10:16:13 -07:00
|
|
|
|
|
|
|
.PHONY: clean-local-docs clean-local-gcov
|