*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / sys-libs / libcap-ng / libcap-ng-0.7.9.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python{2_7,3_{6,7}} )
7
8 inherit autotools flag-o-matic python-r1
9
10 DESCRIPTION="POSIX 1003.1e capabilities"
11 HOMEPAGE="https://people.redhat.com/sgrubb/libcap-ng/"
12 SRC_URI="https://people.redhat.com/sgrubb/${PN}/${P}.tar.gz"
13
14 LICENSE="LGPL-2.1"
15 SLOT="0"
16 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~x86-linux"
17 IUSE="python static-libs"
18 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
19
20 RDEPEND="python? ( ${PYTHON_DEPS} )"
21 DEPEND="${RDEPEND}
22         sys-kernel/linux-headers
23         python? ( >=dev-lang/swig-2 )"
24
25 src_prepare() {
26         default
27         if use prefix ; then
28                 sed -i "s@cat /usr@cat ${EPREFIX}/usr@" bindings/python*/Makefile.am || die
29                 eautomake #668722
30         fi
31 }
32
33 src_configure() {
34         use sparc && replace-flags -O? -O0
35
36         local ECONF_SOURCE="${S}"
37
38         local myconf=(
39                 $(use_enable static-libs static)
40         )
41
42         local pythonconf=( --without-python --without-python3 )
43
44         # set up python bindings build(s)
45         if use python ; then
46                 setup_python_flags_configure() {
47                         if python_is_python3; then
48                                 pythonconf=( --without-python --with-python3 )
49                         else
50                                 pythonconf=( --with-python --without-python3 )
51                                 local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
52                         fi
53                         run_in_build_dir econf "${pythonconf[@]}" "${myconf[@]}"
54                 }
55
56                 python_foreach_impl setup_python_flags_configure
57         else
58                 local BUILD_DIR=${WORKDIR}/build
59                 run_in_build_dir econf "${pythonconf[@]}" "${myconf[@]}"
60         fi
61 }
62
63 src_compile() {
64         if use python; then
65                 python_foreach_impl run_in_build_dir emake
66         else
67                 local BUILD_DIR=${WORKDIR}/build
68                 emake -C "${BUILD_DIR}"
69         fi
70 }
71
72 src_test() {
73         if [[ "${EUID}" -eq 0 ]]; then
74                 ewarn "Skipping tests due to root permissions."
75                 return
76         fi
77
78         if use python; then
79                 python_foreach_impl run_in_build_dir emake check
80         else
81                 local BUILD_DIR=${WORKDIR}/build
82                 emake -C "${BUILD_DIR}" check
83         fi
84 }
85
86 src_install() {
87         if use python; then
88                 python_foreach_impl run_in_build_dir emake DESTDIR="${D}" install
89         else
90                 local BUILD_DIR=${WORKDIR}/build
91                 emake -C "${BUILD_DIR}" DESTDIR="${D}" install
92         fi
93         find "${ED}" -name '*.la' -delete || die
94 }