summaryrefslogtreecommitdiff
blob: 1b8cb49a7c0db45a065415ed83139e0aa6f1b31f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit bash-completion-r1

DESCRIPTION="Command-line tool for structural, content-preserving transformation of PDF files"
HOMEPAGE="http://qpdf.sourceforge.net/"
SRC_URI="mirror://sourceforge/qpdf/${P}.tar.gz"
SRC_URI+=" doc? ( mirror://sourceforge/qpdf/${P}-doc.zip )"

LICENSE="|| ( Apache-2.0 Artistic-2 )"
# subslot = libqpdf soname version
SLOT="0/28"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ppc ~ppc64 ~riscv ~s390 sparc ~x86 ~amd64-linux ~x86-linux ~sparc-solaris"
IUSE="doc examples gnutls ssl test"
RESTRICT="!test? ( test )"

RDEPEND="
	sys-libs/zlib
	virtual/jpeg:0=
	ssl? (
		gnutls? ( net-libs/gnutls:= )
		!gnutls? ( dev-libs/openssl:= )
	)
"
DEPEND="${RDEPEND}
	test? (
		app-text/ghostscript-gpl[tiff(+)]
		media-libs/tiff
		sys-apps/diffutils
	)
"
BDEPEND="dev-lang/perl
	doc? ( app-arch/unzip )"

DOCS=( ChangeLog README.md TODO )

src_configure() {
	# Keep an eye on https://qpdf.readthedocs.io/en/stable/packaging.html.
	local myeconfargs=(
		--disable-check-autofiles

		--disable-implicit-crypto
		--enable-crypto-native

		--disable-oss-fuzz
		$(use_enable test test-compare-images)
	)

	if use ssl ; then
		local crypto_provider=openssl

		if use gnutls ; then
			crypto_provider=gnutls
		fi

		myeconfargs+=(
			--with-default-crypto=${crypto_provider}
			--enable-crypto-${crypto_provider}
		)
	fi

	econf "${myeconfargs[@]}"
}

src_install() {
	default

	if use doc ; then
		docompress -x /usr/share/doc/${PF}/singlehtml
		dodoc -r "${WORKDIR}"/${P}-doc/.

	fi

	if use examples ; then
		dobin $(find examples/build/.libs -maxdepth 1 -type f -executable || die)
	fi

	# Completions
	dobashcomp completions/bash/qpdf

	insinto /usr/share/zsh/site-functions
	doins completions/zsh/_qpdf

	find "${ED}" -type f -name '*.la' -delete || die
}