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-22 16:20:21 -07:00
|
|
|
LIBJQ_INCS = builtin.h bytecode.h compile.h exec_stack.h jq_parser.h \
|
|
|
|
jv_alloc.h jv_dtoa.h jv_unicode.h jv_utf8_tables.h lexer.l \
|
|
|
|
libm.h linker.h locfile.h opcode_list.h parser.y util.h
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2015-08-22 16:20:21 -07:00
|
|
|
LIBJQ_SRC = builtin.c bytecode.c compile.c execute.c jq_test.c jv.c \
|
|
|
|
jv_alloc.c jv_aux.c jv_dtoa.c jv_file.c jv_parse.c jv_print.c \
|
|
|
|
jv_unicode.c linker.c locfile.c util.c ${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
|
|
|
|
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
|
2013-05-25 23:46:20 +01:00
|
|
|
BUILT_SOURCES = lexer.h lexer.c parser.h parser.c version.h
|
2013-05-08 02:30:08 +01:00
|
|
|
lexer.c: lexer.l
|
2013-06-05 13:43:23 +01:00
|
|
|
$(AM_V_LEX) flex -o lexer.c --header-file=lexer.h $<
|
2013-05-08 02:30:08 +01:00
|
|
|
lexer.h: lexer.c
|
2015-02-15 17:57:53 -06:00
|
|
|
else
|
2015-08-13 22:33:37 -07:00
|
|
|
BUILT_SOURCES =
|
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
|
2013-06-23 12:10:58 +01:00
|
|
|
libjq_la_LDFLAGS = -export-symbols-regex '^j[qv]_' -version-info 1:4:0
|
2013-06-16 08:25:12 -05:00
|
|
|
|
|
|
|
include_HEADERS = jv.h jq.h
|
|
|
|
|
2015-06-27 09:52:12 -07:00
|
|
|
### Running tests under Valgrind
|
|
|
|
|
|
|
|
if ENABLE_VALGRIND
|
|
|
|
NO_VALGRIND =
|
|
|
|
else
|
|
|
|
NO_VALGRIND = 1
|
|
|
|
endif
|
|
|
|
|
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
|
|
|
|
libinject_errors_la_SOURCES = inject_errors.c
|
|
|
|
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
|
|
|
|
@ $(generate_ver); test "x`cat version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
|
|
|
|
version.h: .remake-version-h
|
|
|
|
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
|
2015-06-09 16:45:06 -07:00
|
|
|
main.c: version.h
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2013-05-08 02:30:08 +01:00
|
|
|
bin_PROGRAMS = jq
|
2015-03-08 16:52:08 -05:00
|
|
|
jq_SOURCES = main.c 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
|
|
|
|
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
|
|
|
|
2015-06-18 19:38:25 -07:00
|
|
|
TESTS = tests/mantest tests/jqtest tests/onigtest tests/shtest
|
2015-06-27 09:52:12 -07:00
|
|
|
TESTS_ENVIRONMENT = NO_VALGRIND=$(NO_VALGRIND)
|
2013-02-04 07:01:18 -06:00
|
|
|
|
2012-11-28 01:08:23 -06:00
|
|
|
|
2013-05-09 11:31:17 +01:00
|
|
|
### Building the manpage
|
|
|
|
|
2013-05-09 20:27:12 +01:00
|
|
|
# If ENABLE_DOCS is not set, just copy jq.1.default to jq.1
|
|
|
|
# The real_docs target succeeds (possibly after building jq.1) only if ENABLE_DOCS is set
|
|
|
|
# Thus, making "dist" depend on "real_docs" ensures that we never build a tarball with
|
|
|
|
# a stub manpage.
|
|
|
|
|
2013-05-09 11:31:17 +01:00
|
|
|
man_MANS = jq.1
|
2013-05-09 15:22:38 +01:00
|
|
|
.PHONY: real_docs
|
|
|
|
if ENABLE_DOCS
|
2013-05-09 13:40:00 +01:00
|
|
|
jq.1: $(srcdir)/docs/content/3.manual/manual.yml
|
2013-05-25 23:46:20 +01:00
|
|
|
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage ) > $@ || { rm -f $@; false; }
|
2014-06-13 17:22:17 -05:00
|
|
|
jq.1.prebuilt: jq.1
|
|
|
|
$(AM_V_GEN) cp $^ $@ || { rm -f $@; false; }
|
2013-05-09 20:27:12 +01:00
|
|
|
jq.1.default: $(srcdir)/docs/default_manpage.md
|
2013-05-25 23:46:20 +01:00
|
|
|
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage_default ) > $@ || { rm -f $@; false; }
|
2014-06-13 17:22:17 -05:00
|
|
|
real_docs: jq.1 jq.1.prebuilt
|
|
|
|
@if cmp jq.1 $(srcdir)/jq.1.default > /dev/null; then\
|
2013-05-09 20:43:26 +01:00
|
|
|
rm -f jq.1; $(MAKE) $(AM_MAKEFLAGS) jq.1;\
|
|
|
|
fi
|
2013-05-09 15:22:38 +01:00
|
|
|
else
|
2014-06-12 17:30:09 -05:00
|
|
|
jq.1: $(srcdir)/jq.1.prebuilt
|
2013-05-25 23:46:20 +01:00
|
|
|
$(AM_V_GEN) cp $^ $@
|
2013-05-09 15:22:38 +01:00
|
|
|
real_docs:
|
2013-05-09 20:27:12 +01:00
|
|
|
@echo "Ruby dependencies not found, cannot build manpage." > /dev/stderr
|
|
|
|
@echo "Follow the instructions in docs/README.md to install them" > /dev/stderr
|
|
|
|
@echo "and then rerun ./configure" > /dev/stderr
|
2014-06-12 17:30:09 -05:00
|
|
|
@echo "A pre-built, possibly out-of-date manpage used." > /dev/stderr
|
2013-05-09 15:22:38 +01:00
|
|
|
false
|
|
|
|
endif
|
2013-05-09 11:31:17 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-05-09 15:22:38 +01:00
|
|
|
# Ensure "make dist" fails when we can't build the real manpage
|
|
|
|
dist-hook: real_docs
|
2013-05-09 01:50:20 +01:00
|
|
|
|
2015-08-22 15:31:47 -07:00
|
|
|
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
|
|
|
docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \
|
|
|
|
docs/default_manpage.md jq.1.default
|
2013-05-09 20:53:51 +01:00
|
|
|
|
2013-05-08 02:30:08 +01:00
|
|
|
# setup is only used by distribution developers, not package developers.
|
2015-08-13 22:33:37 -07:00
|
|
|
# Still, as a matter of allowing patching, its not a bad idea to distribute
|
2013-05-08 02:30:08 +01:00
|
|
|
# the developer setup script in the tarball.
|
2015-08-22 16:20:21 -07:00
|
|
|
EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
|
|
|
|
jq.1.prebuilt jq.spec lexer.c lexer.h parser.c parser.h \
|
|
|
|
scripts/version tests/jq.test tests/modules/.jq \
|
|
|
|
tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \
|
|
|
|
tests/modules/c/d.jq tests/modules/data.json \
|
2015-08-22 15:31:47 -07:00
|
|
|
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
|
|
|
|
tests/modules/syntaxerror/syntaxerror.jq \
|
|
|
|
tests/modules/test_bind_order.jq \
|
|
|
|
tests/modules/test_bind_order0.jq \
|
|
|
|
tests/modules/test_bind_order1.jq \
|
2015-08-22 16:20:21 -07:00
|
|
|
tests/modules/test_bind_order2.jq tests/onig.supp \
|
|
|
|
tests/onig.test tests/setup tests/torture/input0.json
|
2015-01-01 15:14:49 -06:00
|
|
|
|
2012-11-27 16:02:59 -06:00
|
|
|
|
2015-08-13 22:33:37 -07: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
|
|
|
|
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:
|
|
|
|
rm -f *.gcno *.gcda *.gcov
|
|
|
|
|
|
|
|
clean-local: clean-local-docs clean-local-gcov
|
2013-06-15 00:08:59 -05:00
|
|
|
rm -f version.h .remake-version-h
|
2015-06-27 10:16:13 -07:00
|
|
|
|
|
|
|
.PHONY: clean-local-docs clean-local-gcov
|