aboutsummaryrefslogtreecommitdiff
blob: 134e3e51e656bd7cc101a9141c6ad2aa46f5dae9 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5

SUPPORT_PYTHON_ABIS="1"
RESTRICT_PYTHON_ABIS="*-jython *-pypy-*"

inherit autotools flag-o-matic python eutils-multilib multilib-minimal

DESCRIPTION="POSIX 1003.1e capabilities"
HOMEPAGE="http://people.redhat.com/sgrubb/libcap-ng/"
SRC_URI="http://people.redhat.com/sgrubb/${PN}/${P}.tar.gz"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64"
IUSE="python static-libs"

RDEPEND="python? ( dev-lang/python )"
DEPEND="${RDEPEND}
	sys-kernel/linux-headers
	python? ( >=dev-lang/swig-2 )"

PYTHON_CFLAGS=("2.* + -fno-strict-aliasing")

pkg_setup() {
	use python && python_pkg_setup
}

src_prepare() {
	# Disable byte-compilation of Python modules.
	>py-compile

	# Python bindings are built/tested/installed manually.
	sed -i -e "/^SUBDIRS/s/ python//" bindings/Makefile.am || die
	sed -i -e 's:AM_CONFIG_HEADER:AC_CONFIG_HEADERS:' configure.ac || die

	eautoreconf

	use sparc && replace-flags -O? -O0
}

multilib_src_configure() {
	local CFLAGS="${CFLAGS}"
	export CFLAGS
	ECONF_SOURCE="${S}" econf \
		$(use_enable static-libs static) \
		$(use_with_best_abi python)
}

multilib_src_compile() {
	default

	if multilib_is_best_abi && use python; then
		S="${BUILD_DIR}" python_copy_sources bindings/python
		building() {
			emake \
				CFLAGS="${CFLAGS} $(python-config --cflags)" \
				PYTHON_VERSION="$(python_get_version)" \
				pyexecdir="$(python_get_sitedir)" \
				pythondir="$(python_get_sitedir)"
		}
		S="${BUILD_DIR}" python_execute_function -s --source-dir bindings/python building
	fi
}

multilib_src_test() {
	if [[ "${EUID}" -eq 0 ]]; then
		ewarn "Skipping tests due to root permissions."
		return
	fi

	default

	if multilib_is_best_abi use python; then
		testing() {
			emake \
				CFLAGS="${CFLAGS} $(python-config --cflags)" \
				PYTHON_VERSION="$(python_get_version)" \
				pyexecdir="$(python_get_sitedir)" \
				pythondir="$(python_get_sitedir)" \
				TESTS_ENVIRONMENT="PYTHONPATH=..:../.libs" \
				check
		}
		S="${BUILD_DIR}" python_execute_function -s --source-dir bindings/python testing
	fi
}

multilib_src_install() {
	default

	if multilib_is_best_abi && use python; then
		installation() {
			emake \
				DESTDIR="${D}" \
				PYTHON_VERSION="$(python_get_version)" \
				pyexecdir="$(python_get_sitedir)" \
				pythondir="$(python_get_sitedir)" \
				install
		}
		S="${BUILD_DIR}" python_execute_function -s --source-dir bindings/python installation

		python_clean_installation_image
	fi

	rm -f "${ED}"/usr/lib*/${PN}.la
}

pkg_postinst() {
	use python && python_mod_optimize capng.py
}

pkg_postrm() {
	use python && python_mod_cleanup capng.py
}