|
| 1 | +# Copyright 1999-2023 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +inherit autotools |
| 7 | + |
| 8 | +MY_PV="${PV/_/}" |
| 9 | +MY_P="${PN}-${MY_PV}" |
| 10 | +DESCRIPTION="A lightweight and flexible command-line JSON processor" |
| 11 | +HOMEPAGE="https://stedolan.github.io/jq/" |
| 12 | +SRC_URI="https://github.com/jqlang/jq/archive/refs/tags/${MY_P}.tar.gz -> ${P}.gh.tar.gz" |
| 13 | +S="${WORKDIR}/${PN}-${MY_P}" |
| 14 | + |
| 15 | +LICENSE="MIT CC-BY-3.0" |
| 16 | +SLOT="0" |
| 17 | +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~arm64-macos ~x64-macos ~x64-solaris" |
| 18 | +IUSE="+oniguruma static-libs test" |
| 19 | + |
| 20 | +ONIGURUMA_MINPV='>=dev-libs/oniguruma-6.9.3' # Keep this in sync with bundled modules/oniguruma/ |
| 21 | +DEPEND=" |
| 22 | + >=sys-devel/bison-3.0 |
| 23 | + sys-devel/flex |
| 24 | + oniguruma? ( ${ONIGURUMA_MINPV}:=[static-libs?] ) |
| 25 | +" |
| 26 | +RDEPEND=" |
| 27 | + !static-libs? ( |
| 28 | + oniguruma? ( ${ONIGURUMA_MINPV}[static-libs?] ) |
| 29 | + ) |
| 30 | +" |
| 31 | +PATCHES=( |
| 32 | + "${FILESDIR}"/jq-1.6-r3-never-bundle-oniguruma.patch |
| 33 | + "${FILESDIR}"/jq-1.7-runpath.patch |
| 34 | +) |
| 35 | + |
| 36 | +RESTRICT="!test? ( test )" |
| 37 | +REQUIRED_USE="test? ( oniguruma )" |
| 38 | + |
| 39 | +src_prepare() { |
| 40 | + sed -e '/^dist_doc_DATA/d; s:-Wextra ::' -i Makefile.am || die |
| 41 | + printf "#!/bin/sh\\nprintf '%s'\\n\n" "${MY_PV}" > scripts/version || die |
| 42 | + |
| 43 | + # jq-1.6-r3-never-bundle-oniguruma makes sure we build with the system oniguruma, |
| 44 | + # but the bundled copy of oniguruma still gets eautoreconf'd since it |
| 45 | + # exists; save the cycles by nuking it. |
| 46 | + sed -e '/modules\/oniguruma/d' -i Makefile.am || die |
| 47 | + rm -rf "${S}"/modules/oniguruma || die |
| 48 | + |
| 49 | + default |
| 50 | + |
| 51 | + sed -i "s/\[jq_version\]/[${MY_PV}]/" configure.ac || die |
| 52 | + |
| 53 | + eautoreconf |
| 54 | +} |
| 55 | + |
| 56 | +src_configure() { |
| 57 | + local econfargs=( |
| 58 | + # don't try to rebuild docs |
| 59 | + --disable-docs |
| 60 | + --disable-valgrind |
| 61 | + --disable-maintainer-mode |
| 62 | + --enable-rpathhack |
| 63 | + $(use_enable static-libs static) |
| 64 | + $(use_with oniguruma oniguruma yes) |
| 65 | + ) |
| 66 | + econf "${econfargs[@]}" |
| 67 | +} |
| 68 | + |
| 69 | +src_test() { |
| 70 | + if ! LD_LIBRARY_PATH="${S}/.libs" nonfatal emake check; then |
| 71 | + if [[ -r "${S}/test-suite.log" ]]; then |
| 72 | + eerror "Tests failed, outputting testsuite log" |
| 73 | + cat "${S}/test-suite.log" |
| 74 | + fi |
| 75 | + die "Tests failed" |
| 76 | + fi |
| 77 | +} |
| 78 | + |
| 79 | +src_install() { |
| 80 | + local DOCS=( AUTHORS NEWS.md README.md SECURITY.md ) |
| 81 | + default |
| 82 | + |
| 83 | + use static-libs || { find "${D}" -name '*.la' -delete || die; } |
| 84 | +} |
0 commit comments