Makefile.am
This file
Path
Makefile.am
273 lines · 10.0 KiB
Last changed by
Drop the date from the committed man page (#3659)itchynybefore adoption17b87d2
History of this fileTake it
12### C source files to be built and distributed.34LIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h \5 src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h \6 src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h \7 src/linker.h src/locfile.h src/opcode_list.h src/parser.y \8 src/util.h src/iso8601.h \9 src/jv_dtoa_tsd.h src/jv_thread.h src/jv_private.h \10 vendor/decNumber/decContext.h vendor/decNumber/decNumber.h \11 vendor/decNumber/decNumberLocal.h1213LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \14 src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c \15 src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c \16 src/jv_unicode.c src/linker.c src/locfile.c src/util.c \17 src/iso8601.c src/jv_dtoa_tsd.c \18 vendor/decNumber/decContext.c vendor/decNumber/decNumber.c \19 ${LIBJQ_INCS}2021### C build options2223AM_CFLAGS = -Wextra -Wall -Wno-unused-parameter -Wno-unused-function \24 -Woverlength-strings -Wstrict-prototypes2526if WIN3227AM_CFLAGS += -municode28endif2930ACLOCAL_AMFLAGS = -I config/m43132### Generating the lexer and parser3334# While there is some autoconf macro support for lex/flex, it doesn't support35# header file creation so we'll use good old make36if MAINTAINER_MODE37BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \38 src/builtin.inc src/config_opts.inc src/version.h39src/lexer.c: src/lexer.l40 $(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $<41src/lexer.h: src/lexer.c42else43BUILT_SOURCES = src/builtin.inc src/config_opts.inc src/version.h44.y.c:45 $(AM_V_YACC) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(@F) $@46 $(AM_V_YACC) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(*F).h $*.h47 $(AM_V_YACC) touch $@ $*.h4849.l.c:50 $(AM_V_LEX) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(@F) $@51 $(AM_V_LEX) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(*F).h $*.h52 $(AM_V_LEX) touch $@ $*.h53endif5455# Tell YACC (Bison) autoconf macros that you want a header file created.56# If the --warnings=all fails, you probably have an old version of Bison57# macOS ships an old Bison, so update with Homebrew or MacPorts.58AM_YFLAGS = --warnings=all -Wno-yacc -d5960### libjq6162lib_LTLIBRARIES = libjq.la63libjq_la_SOURCES = ${LIBJQ_SRC}64libjq_la_LIBADD = -lm65libjq_la_LDFLAGS = $(onig_LDFLAGS) -export-symbols-regex '^j[qv]_' -version-info 1:4:06667if WIN3268libjq_la_LIBADD += -lshlwapi69libjq_la_LDFLAGS += -no-undefined70endif7172include_HEADERS = src/jv.h src/jq.h7374AM_CPPFLAGS = -I$(srcdir)/src -I$(srcdir)/vendor7576### Address sanitizer (ASan)7778if ENABLE_ASAN79AM_CFLAGS += -fsanitize=address80endif8182### Undefined Behavior Sanitizer8384if ENABLE_UBSAN85AM_CFLAGS += -fsanitize=undefined86endif8788### Code coverage with gcov8990if ENABLE_GCOV91AM_CFLAGS += --coverage --no-inline92endif9394### Error injection for testing9596if ENABLE_ERROR_INJECTION97lib_LTLIBRARIES += libinject_errors.la98libinject_errors_la_SOURCES = src/inject_errors.c99libinject_errors_la_LIBADD = -ldl100libinject_errors_la_LDFLAGS = -module101endif102103### Building the jq binary104105# Remake the version.h header file if, and only if, the git ID has changed106.PHONY: .FORCE107.FORCE:108generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | xargs printf '\043define JQ_VERSION \"%s\"\n'`"109.remake-version-h: .FORCE110 @ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h111src/version.h: .remake-version-h112 mkdir -p src113 $(AM_V_GEN) $(generate_ver); echo "$$ver" > $@114src/config_opts.inc:115 mkdir -p src116 $(AM_V_GEN) if test -x ./config.status; then \117 ./config.status --config; \118 else echo "(unknown)"; \119 fi | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/"/' -e 's/^/#define JQ_CONFIG /' > $@120src/main.c: src/version.h src/config_opts.inc121122src/builtin.inc: $(srcdir)/src/builtin.jq123 mkdir -p src124 $(AM_V_GEN) od -v -A n -t o1 -- $< | \125 sed -e 's/$$/ /' \126 -e 's/\([0123456789]\) /\1, /g' \127 -e 's/ $$//' \128 -e 's/ 0/ 0/g' \129 -e 's/ \([123456789]\)/ 0\1/g' > $@130src/builtin.o: src/builtin.inc131132CLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc133134bin_PROGRAMS = jq135jq_SOURCES = src/main.c136jq_LDADD = libjq.la -lm137138if ENABLE_ALL_STATIC139jq_LDFLAGS = -all-static140endif141142### Tests (make check)143144TESTS = tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test tests/uritest145if !WIN32146TESTS += tests/optionaltest147endif148149AM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq150if ENABLE_VALGRIND151AM_TESTS_ENVIRONMENT += ENABLE_VALGRIND=1152endif153154# This is a magic make variable that causes it to treat tests/man.test as a155# DATA-type dependency for the check target. As a result, it will attempt to156# run any defined targets for tests/man.test as a dependency for check. This157# allows us to ensure that the tests are up-to-date if the manual has been updated158check_DATA = tests/man.test159160### Building the man tests161162# We use the examples in the manual as additional tests, to ensure they always work.163# As a result, we need to rebuild the tests if the manual has been updated.164# Making changes to the manpage without having the python deps means your165# tests won't run. If you aren't making changes to the examples, you probably166# don't care. But if you are, then you need to run the tests anyway.167tests/man.test tests/manonig.test: $(srcdir)/docs/content/manual/dev/manual.yml168if ENABLE_DOCS169 $(AM_V_GEN) ( cd ${abs_srcdir}/docs && \170 $(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \171 $(PIPENV) run python build_mantests.py )172else173 @echo Changes to the manual.yml require docs to be enabled to update the manual test.174 @echo As a result, the manual test is out of date.175endif176177### Building the manpage178179# We build the docs from the manpage yml. If no changes have been made to the180# manpage, then we'll end up using the cached version. Otherwise, we need to181# rebuild it.182man_MANS = jq.1183jq.1.prebuilt: $(srcdir)/docs/content/manual/dev/manual.yml184if ENABLE_DOCS185 $(AM_V_GEN) ( cd ${abs_srcdir}/docs && \186 $(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \187 $(PIPENV) run python build_manpage.py ) > $@188else189 @echo Changes to the manual.yml require docs to be enabled to update the manpage.190 @echo As a result, the manpage is out of date.191endif192193# The committed manpage has no date to avoid merge conflicts. Stamp the date194# of the last commit when building in a git repository, including on make195# dist, so that release tarballs ship a dated jq.1. Respect SOURCE_DATE_EPOCH196# so that distribution builds can pin the date.197jq.1: jq.1.prebuilt198 $(AM_V_GEN) date=`if test -n "$$SOURCE_DATE_EPOCH"; then \199 date -u -d "@$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || \200 date -u -r "$$SOURCE_DATE_EPOCH" +%F 2>/dev/null; \201 elif test -e $(srcdir)/.git; then \202 cd $(srcdir) && git log -1 --format=%cd --date=short 2>/dev/null; \203 fi`; \204 sed 's/^\.TH "JQ" "1" ""/.TH "JQ" "1" "'"$$date"'"/' $(srcdir)/jq.1.prebuilt > $@205206CLEANFILES += jq.1207208### Build oniguruma209210if BUILD_ONIGURUMA211libjq_la_LIBADD += vendor/oniguruma/src/.libs/libonig.la212jq_LDADD += vendor/oniguruma/src/.libs/libonig.la213SUBDIRS = vendor/oniguruma214endif215216AM_CFLAGS += $(onig_CFLAGS)217218if WITH_ONIGURUMA219TESTS += tests/onigtest tests/manonigtest220endif221222### Packaging223224install-binaries: $(BUILT_SOURCES)225 $(MAKE) $(AM_MAKEFLAGS) install-exec226227DOC_FILES = docs/content docs/public docs/templates \228 docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \229 docs/build_mantests.py docs/build_website.py docs/README.md \230 docs/validate_manual_schema.py docs/manual_schema.yml231232EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \233 jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \234 src/parser.h src/version.h src/builtin.jq scripts/version \235 libjq.pc \236 tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \237 tests/modules/c/d.jq tests/modules/data.json \238 tests/modules/deep1.jq tests/modules/deep2a.jq \239 tests/modules/deep2b.jq tests/modules/deep3.jq \240 tests/modules/home1/.jq tests/modules/home2/.jq/g.jq \241 tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \242 tests/modules/shadow1.jq tests/modules/shadow2.jq \243 tests/modules/syntaxerror/syntaxerror.jq \244 tests/modules/test_bind_order.jq \245 tests/modules/test_bind_order0.jq \246 tests/modules/test_bind_order1.jq \247 tests/modules/test_bind_order2.jq \248 tests/modules/cycle_a.jq tests/modules/cycle_b.jq \249 tests/modules/cycle_self.jq \250 tests/onig.supp tests/local.supp \251 tests/setup tests/torture/input0.json \252 tests/optional.test tests/man.test tests/manonig.test \253 tests/jq.test tests/onig.test tests/base64.test tests/uri.test \254 tests/jq-f-test.sh \255 tests/no-main-program.jq tests/yes-main-program.jq256257AM_DISTCHECK_CONFIGURE_FLAGS=--with-oniguruma=builtin258259# README.md is expected in GitHub projects, good stuff in it, so we'll260# distribute it and install it with the package in the doc directory.261dist_doc_DATA = README.md NEWS.md COPYING AUTHORS262263pkgconfigdir = $(libdir)/pkgconfig264pkgconfig_DATA = libjq.pc265266RELEASE ?= 1267rpm: dist jq.spec268 @echo "Packaging jq as an RPM ..."269 mkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS270 cp jq-$(VERSION).tar.gz rpm/SOURCES/271 rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $(VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$(VERSION).tar.gz272 find rpm/RPMS/ -name "*.rpm" -exec mv {} ./ \;273 rm -rf rpm