summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am45
-rw-r--r--configure.ac20
-rw-r--r--jq.spec31
-rwxr-xr-xsetup.sh9
4 files changed, 70 insertions, 35 deletions
diff --git a/Makefile.am b/Makefile.am
index bb5133bf..3f65c660 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,10 +44,14 @@ JQ_SRC = \
jv_aux.c \
jv_alloc.c \
lexer.c \
- $(JQ_INCS)
-
-if DEVCFLAGS_ENABLED
-DEVCFLAGS = -Wextra -Wall -Wno-missing-field-initializers -Wno-unused-parameter -std=gnu99 -ggdb -Wno-unused-function
+ ${JQ_INCS}
+
+if DEVELOPMENT_ENABLED
+DEVCFLAGS = -Wextra -Wall -Wno-missing-field-initializers -Wno-unused-parameter -std=gnu99 -ggdb -Wno-unused-function -O0 -DJQ_DEBUG=1
+RPMBINS = jq jq_test
+else
+DEVCFLAGS = -DJQ_DEBUG=0
+RPMBINS = jq
endif
# Tell YACC (bison) autoconf macros that you want a header file created.
@@ -55,15 +59,31 @@ endif
# OSX ships an old bison, so update with homebrew or macports
AM_YFLAGS = --warnings=all -d
-bin_PROGRAMS = jq jq_test
+bin_PROGRAMS = jq
BUILT_SOURCES = jv_utf8_tables.gen.h lexer.h lexer.c
-jq_SOURCES = $(JQ_SRC) main.c
-jq_CPPFLAGS = $(DEVCFLAGS) -O -DJQ_DEBUG=0
+jq_SOURCES = ${JQ_SRC} main.c
+jq_CPPFLAGS = ${DEVCFLAGS}
+
+# always test, but conditionally distribute to /usr/libexec/jq/jq_test
+if DEVELOPMENT_ENABLED
+ pkglibexec_PROGRAMS = jq_test
+ # automake doesn't like putting data in libexec (pkglibexec_DATA)
+ # so we'll create our own macro and distribute testdata
+ mydatadir = ${libexecdir}/${PACKAGE}
+ mydata_DATA = testdata
+
+ DEVBUILD=yes
+else
+ noinst_PROGRAMS = jq_test
+
+ DEVBUILD=no
+endif
+jq_test_SOURCES = ${JQ_SRC} jq_test.c
+jq_test_CPPFLAGS = ${DEVCFLAGS}
+# this is what gets "make check" to work
TESTS = jq_test
-jq_test_SOURCES = $(JQ_SRC) jq_test.c
-jq_test_CPPFLAGS = $(DEVCFLAGS) -DJQ_DEBUG=1
LOG_COMPILER = valgrind
AM_LOG_FLAGS = --error-exitcode=1 -q --leak-check=full
@@ -93,15 +113,14 @@ main.c: config.h
releasetag:
git tag -s "jq-$$(cat VERSION)" -m "jq release $$(cat VERSION)"
-# can probably delete and have RPM created off autoconf generated tarball releases
RELEASE ?= 1
-rpm: jq jq_test
+rpm: ${RPMBINS}
@echo "Packaging jq as an RPM ..."
mkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS
cp jq-$$(cat VERSION).tar.gz rpm/SOURCES/
- rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "version $$(cat VERSION)" --define "release ${RELEASE}" rpm/SOURCES/jq-$$(cat VERSION).tar.gz
+ rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $$(cat VERSION)" --define "myrel ${RELEASE}" --define "devbuild ${DEVBUILD}" rpm/SOURCES/jq-$$(cat VERSION).tar.gz
find rpm/RPMS/ -name "*.rpm" -exec mv {} ./ \;
rm -rf rpm
dist-clean-local:
- rm -f $(BUILT_SOURCES)
+ rm -f ${BUILT_SOURCES}
diff --git a/configure.ac b/configure.ac
index 8b00a2a7..5f939493 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,16 +22,16 @@ dnl developers like them by default but the packager can disable if so
dnl desired. This is useful if something other than gcc is needed or
dnl for distros that need to heavily tweek the compiler (gentoo, ARM cpu
dnl linux's, etc)
-AC_ARG_ENABLE([devcflags],
- [AC_HELP_STRING([--enable-devcflags=@<:@yes/no@:>@],
- [Enable the same CFLAGS used by jq developers @<:@default=yes@:>@])],
- [enable_devcflags=$enableval],
- [enable_devcflags=yes])
-AC_MSG_RESULT($enable_devcflags)
-dnl AM_CONDITIONAL(DEVCFLAGS, test x$enable_devcflags = xyes)
-if test "$enable_devcflags" = "yes"; then
- AM_CONDITIONAL(DEVCFLAGS_ENABLED, true)
-fi
+AC_ARG_ENABLE(
+ [devel],
+ [AC_HELP_STRING(
+ [--enable-devel],
+ [Build the tests and enable the same CFLAGS used by jq developers @<:@default=no@:>@])],
+ [],
+ [enable_devel=no]
+)
+AC_MSG_RESULT($enable_devel)
+AM_CONDITIONAL([DEVELOPMENT_ENABLED], [test x$enable_devel = xyes])
dnl
dnl these program checks should probably be deleted
diff --git a/jq.spec b/jq.spec
index 35db1ae1..3697ed02 100644
--- a/jq.spec
+++ b/jq.spec
@@ -2,9 +2,9 @@
# Your OS of choice will likely ignore this RPM spec file.
Summary: Command-line JSON processor
Name: jq
-Version: %{version}
-Release: %{release}
-Source0: jq-%{version}.tar.gz
+Version: %{myver}
+Release: %{myrel}%{?dist}
+Source0: jq-%{myver}.tar.gz
URL: https://github.com/stedolan/jq
License: BSD
AutoReqProv: no
@@ -18,16 +18,22 @@ Group: Applications/System
%global debug_package %{nil}
%global __os_install_post %{nil}
+# Crank up the compression
+%define _binary_payload w7.lzdio
+
%description
jq is a command-line JSON processor
%prep
-
%setup
%build
echo "Building in: \"$(pwd)\""
+%if "%{devbuild}" == "yes"
+./configure --prefix=%{_prefix} --enable-devel
+%else
./configure --prefix=%{_prefix}
+%endif
make
%install
@@ -40,13 +46,16 @@ rm -rf %{buildroot}
%files
%defattr(-,root,root)
%{_bindir}/jq
-%{_bindir}/jq_test
-%{_datadir}/doc/jq/AUTHORS
-%{_datadir}/doc/jq/COPYING
-%{_datadir}/doc/jq/INSTALL
-%{_datadir}/doc/jq/NEWS
-%{_datadir}/doc/jq/README
-%{_datadir}/doc/jq/README.md
+%if "%{devbuild}" == "yes"
+%{_libexecdir}/%{name}/jq_test
+%{_libexecdir}/%{name}/testdata
+%endif
+%{_datadir}/doc/%{name}/AUTHORS
+%{_datadir}/doc/%{name}/COPYING
+%{_datadir}/doc/%{name}/INSTALL
+%{_datadir}/doc/%{name}/NEWS
+%{_datadir}/doc/%{name}/README
+%{_datadir}/doc/%{name}/README.md
%changelog
diff --git a/setup.sh b/setup.sh
index 763e78f4..ef92f88a 100755
--- a/setup.sh
+++ b/setup.sh
@@ -1,12 +1,19 @@
#!/usr/bin/env bash
# RUN ME after pulling the code from git!
+#
+# This script is handy after pulling the code out of git without having
+# to remember all the typing needed to build up and tear down all the
+# crap that autotools puts in your source repo. The intent is to keep
+# all generated files out of git.
+
if [ "clean" == "$1" ]; then
make distclean || echo "continuing..."
rm -rf tmp autom4te.cache config
rm -f INSTALL Makefile.in aclocal.m4 configure config.h.in ChangeLog
rm -f jv_utf8_tables.gen.h lexer.c lexer.h parser.c parser.h
elif [ "superclean" == "$1" ]; then
+ # if autoconf errors during distcheck, it leaves files that need chmod'ing
ver=$(tr -d '\n' <VERSION)
if [ "x${ver}" != "x" ]; then
if [ -d jq-${ver} ]; then
@@ -17,7 +24,7 @@ elif [ "superclean" == "$1" ]; then
fi
else
autoreconf --install
- ./configure --prefix=/opt/junk
+ ./configure --enable-devel --prefix=/opt/junk
make check
mkdir tmp
make DESTDIR=./tmp install