dev-libs/libcgroup: avoid building tests when USE=-test
[gentoo.git] / dev-libs / libcgroup / libcgroup-0.41-r5.ebuild
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit autotools flag-o-matic linux-info pam
7
8 DESCRIPTION="Tools and libraries to configure and manage kernel control groups"
9 HOMEPAGE="http://libcg.sourceforge.net/"
10 SRC_URI="mirror://sourceforge/project/libcg/${PN}/v${PV}/${P}.tar.bz2"
11
12 LICENSE="LGPL-2.1"
13 SLOT="0"
14 KEYWORDS="amd64 arm ~ppc ~ppc64 x86"
15 IUSE="+daemon elibc_musl pam static-libs test +tools"
16
17 RDEPEND="pam? ( virtual/pam )"
18
19 DEPEND="
20         ${RDEPEND}
21         sys-devel/bison
22         sys-devel/flex
23         elibc_musl? ( sys-libs/fts-standalone )
24         "
25 REQUIRED_USE="daemon? ( tools )"
26
27 DOCS=(README_daemon README README_systemd INSTALL)
28 pkg_setup() {
29         local CONFIG_CHECK="~CGROUPS"
30         if use daemon; then
31                 CONFIG_CHECK="${CONFIG_CHECK} ~CONNECTOR ~PROC_EVENTS"
32         fi
33         linux-info_pkg_setup
34 }
35
36 PATCHES=(
37         "${FILESDIR}"/${P}-replace_DECLS.patch
38         "${FILESDIR}"/${P}-replace_INLCUDES.patch
39         "${FILESDIR}"/${P}-reorder-headers.patch
40         "${FILESDIR}"/${P}-remove-umask.patch
41 )
42
43 src_prepare() {
44         default
45         # Change rules file location
46         sed -e 's:/etc/cgrules.conf:/etc/cgroup/cgrules.conf:' \
47                 -i src/libcgroup-internal.h || die "sed failed"
48         sed -e 's:/etc/cgconfig.conf:/etc/cgroup/cgconfig.conf:' \
49                 -i src/libcgroup-internal.h || die "sed failed"
50         sed -e 's:\(pam_cgroup_la_LDFLAGS.*\):\1\ -avoid-version:' \
51                 -i src/pam/Makefile.am || die "sed failed"
52         sed -e 's#/var/run#/run#g' -i configure.in || die "sed failed"
53
54         # If we're not running tests, don't bother building them.
55         if ! use test; then
56                 sed -i '/^SUBDIRS/s:tests::' Makefile.am || die
57         fi
58
59         eautoreconf
60 }
61
62 src_configure() {
63         local my_conf
64
65         if use pam; then
66                 my_conf=" --enable-pam-module-dir=$(getpam_mod_dir) "
67         fi
68
69         use elibc_musl && append-ldflags "-lfts"
70         econf \
71                 $(use_enable static-libs static) \
72                 $(use_enable daemon) \
73                 $(use_enable pam) \
74                 $(use_enable tools) \
75                 ${my_conf}
76 }
77
78 src_test() {
79         # Use mount cgroup to build directory
80         # sandbox restricted to trivial build,
81         # possible kill Diego tanderbox ;)
82         true
83 }
84
85 src_install() {
86         default
87         prune_libtool_files --all
88
89         insinto /etc/cgroup
90         doins samples/*.conf || die
91
92         if use tools; then
93                 newconfd "${FILESDIR}"/cgconfig.confd-r1 cgconfig || die
94                 newinitd "${FILESDIR}"/cgconfig.initd-r1 cgconfig || die
95         fi
96
97         if use daemon; then
98                 newconfd "${FILESDIR}"/cgred.confd-r2 cgred || die
99                 newinitd "${FILESDIR}"/cgred.initd-r1 cgred || die
100         fi
101 }