app-text/rtf2html: Port to EAPI 7
[gentoo.git] / sys-libs / libcap-ng / libcap-ng-0.7.8.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 AUTOTOOLS_AUTORECONF=1
7 AUTOTOOLS_PRUNE_LIBTOOL_FILES=all
8 PYTHON_COMPAT=( python{2_7,3_6} )
9
10 inherit autotools-utils flag-o-matic python-r1
11
12 DESCRIPTION="POSIX 1003.1e capabilities"
13 HOMEPAGE="https://people.redhat.com/sgrubb/libcap-ng/"
14 SRC_URI="https://people.redhat.com/sgrubb/${PN}/${P}.tar.gz"
15
16 LICENSE="LGPL-2.1"
17 SLOT="0"
18 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~x86-linux"
19 IUSE="python static-libs"
20 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
21
22 RDEPEND="python? ( ${PYTHON_DEPS} )"
23 DEPEND="${RDEPEND}
24         sys-kernel/linux-headers
25         python? ( >=dev-lang/swig-2 )"
26
27 RESTRICT="test"
28
29 src_prepare() {
30         sed -i -e 's:AM_CONFIG_HEADER:AC_CONFIG_HEADERS:' configure.ac || die
31
32         autotools-utils_src_prepare
33
34         use sparc && replace-flags -O? -O0
35 }
36
37 src_configure() {
38         # set up the library build
39         local myeconfargs=( --without-python --without-python3 )
40         autotools-utils_src_configure
41
42         # set up python bindings build(s)
43         if use python ; then
44                 setup_python_flags_configure() {
45                         if [[ ${EPYTHON} == python2* ]] ; then
46                                 myeconfargs=( --with-python --without-python3 )
47                         else
48                                 myeconfargs=( --with-python --with-python3 )
49                         fi
50                         autotools-utils_src_configure
51                 }
52
53                 python_foreach_impl setup_python_flags_configure
54         fi
55 }
56
57 src_compile() {
58         autotools-utils_src_compile
59
60         if use python; then
61                 python_compile() {
62                         local CFLAGS=${CFLAGS}
63
64                         python_is_python3 || CFLAGS+=" -fno-strict-aliasing"
65
66                         emake "${@}" \
67                                 -C "${BUILD_DIR}"/bindings/python
68                 }
69
70                 # help build system find the right objects
71                 python_foreach_impl python_compile \
72                         VPATH="${BUILD_DIR}"/bindings/python \
73                         LIBS="${BUILD_DIR}"/src/libcap-ng.la
74         fi
75 }
76
77 src_test() {
78         if [[ "${EUID}" -eq 0 ]]; then
79                 ewarn "Skipping tests due to root permissions."
80                 return
81         fi
82
83         autotools-utils_src_test
84
85         if use python; then
86                 python_foreach_impl \
87                         autotools-utils_src_compile -C bindings/python check \
88                         VPATH="${BUILD_DIR}"/bindings/python:"${S}"/bindings/python/test
89         fi
90 }
91
92 src_install() {
93         autotools-utils_src_install
94
95         if use python; then
96                 python_foreach_impl \
97                         autotools-utils_src_install -C bindings/python \
98                         VPATH="${BUILD_DIR}"/bindings/python
99         fi
100 }