sys-process/glances: revbump 3.1.4.1, add missing doc dep
[gentoo.git] / sys-apps / iproute2 / iproute2-5.5.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit toolchain-funcs flag-o-matic multilib
7
8 if [[ ${PV} == "9999" ]] ; then
9         EGIT_REPO_URI="https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git"
10         inherit git-r3
11 else
12         SRC_URI="https://www.kernel.org/pub/linux/utils/net/${PN}/${P}.tar.xz"
13         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
14 fi
15
16 DESCRIPTION="kernel routing and traffic control utilities"
17 HOMEPAGE="https://wiki.linuxfoundation.org/networking/iproute2"
18
19 LICENSE="GPL-2"
20 SLOT="0"
21 IUSE="atm berkdb caps elf +iptables ipv6 minimal selinux"
22
23 # We could make libmnl optional, but it's tiny, so eh
24 RDEPEND="
25         !net-misc/arpd
26         dev-libs/libbsd
27         !minimal? ( net-libs/libmnl )
28         caps? ( sys-libs/libcap )
29         elf? ( virtual/libelf )
30         iptables? ( >=net-firewall/iptables-1.4.20:= )
31         berkdb? ( sys-libs/db:= )
32         atm? ( net-dialup/linux-atm )
33         selinux? ( sys-libs/libselinux )
34 "
35 # We require newer linux-headers for ipset support #549948 and some defines #553876
36 DEPEND="
37         ${RDEPEND}
38         >=sys-kernel/linux-headers-3.16
39 "
40 BDEPEND="
41         app-arch/xz-utils
42         >=sys-devel/bison-2.4
43         sys-devel/flex
44         virtual/pkgconfig
45 "
46
47 PATCHES=(
48         "${FILESDIR}"/${PN}-3.1.0-mtu.patch #291907
49         "${FILESDIR}"/${PN}-4.20.0-configure-nomagic.patch # bug 643722
50         "${FILESDIR}"/${PN}-5.1.0-portability.patch
51 )
52
53 src_prepare() {
54         if ! use ipv6 ; then
55                 PATCHES+=(
56                         "${FILESDIR}"/${PN}-4.20.0-no-ipv6.patch #326849
57                 )
58         fi
59
60         default
61
62         # echo -n is not POSIX compliant
63         sed 's@echo -n@printf@' -i configure || die
64
65         sed -i \
66                 -e '/^CC :\?=/d' \
67                 -e "/^LIBDIR/s:=.*:=/$(get_libdir):" \
68                 -e "s|-O2|${CFLAGS} ${CPPFLAGS}|" \
69                 -e "/^HOSTCC/s:=.*:= $(tc-getBUILD_CC):" \
70                 -e "/^DBM_INCLUDE/s:=.*:=${T}:" \
71                 Makefile || die
72
73         # Use /run instead of /var/run.
74         sed -i \
75                 -e 's:/var/run:/run:g' \
76                 include/namespace.h \
77                 man/man8/ip-netns.8 || die
78
79         # build against system headers
80         rm -r include/netinet || die #include/linux include/ip{,6}tables{,_common}.h include/libiptc
81         sed -i 's:TCPI_OPT_ECN_SEEN:16:' misc/ss.c || die
82
83         if use minimal ; then
84                 sed -i -e '/^SUBDIRS=/s:=.*:=lib tc ip:' Makefile || die
85         fi
86 }
87
88 src_configure() {
89         tc-export AR CC PKG_CONFIG
90
91         # This sure is ugly.  Should probably move into toolchain-funcs at some point.
92         local setns
93         pushd "${T}" >/dev/null
94         printf '#include <sched.h>\nint main(){return setns(0, 0);}\n' > test.c
95         ${CC} ${CFLAGS} ${CPPFLAGS} -D_GNU_SOURCE ${LDFLAGS} test.c >&/dev/null && setns=y || setns=n
96         echo 'int main(){return 0;}' > test.c
97         ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} test.c -lresolv >&/dev/null || sed -i '/^LDLIBS/s:-lresolv::' "${S}"/Makefile
98         popd >/dev/null
99
100         # run "configure" script first which will create "config.mk"...
101         econf
102
103         # ...now switch on/off requested features via USE flags
104         # this is only useful if the test did not set other things, per bug #643722
105         cat <<-EOF >> config.mk
106         TC_CONFIG_ATM := $(usex atm y n)
107         TC_CONFIG_XT  := $(usex iptables y n)
108         TC_CONFIG_NO_XT := $(usex iptables n y)
109         # We've locked in recent enough kernel headers #549948
110         TC_CONFIG_IPSET := y
111         HAVE_BERKELEY_DB := $(usex berkdb y n)
112         HAVE_CAP      := $(usex caps y n)
113         HAVE_MNL      := $(usex minimal n y)
114         HAVE_ELF      := $(usex elf y n)
115         HAVE_SELINUX  := $(usex selinux y n)
116         IP_CONFIG_SETNS := ${setns}
117         # Use correct iptables dir, #144265 #293709
118         IPT_LIB_DIR := $(use iptables && ${PKG_CONFIG} xtables --variable=xtlibdir)
119         EOF
120 }
121
122 src_compile() {
123         emake V=1
124 }
125
126 src_install() {
127         if use minimal ; then
128                 into /
129                 dosbin tc/tc
130                 dobin ip/ip
131                 return 0
132         fi
133
134         emake \
135                 DESTDIR="${D}" \
136                 PREFIX="${EPREFIX}/usr" \
137                 LIBDIR="${EPREFIX}"/$(get_libdir) \
138                 SBINDIR="${EPREFIX}"/sbin \
139                 CONFDIR="${EPREFIX}"/etc/iproute2 \
140                 DOCDIR="${EPREFIX}"/usr/share/doc/${PF} \
141                 MANDIR="${EPREFIX}"/usr/share/man \
142                 ARPDDIR="${EPREFIX}"/var/lib/arpd \
143                 install
144
145         dodir /bin
146         mv "${ED}"/{s,}bin/ip || die #330115
147
148         dolib.a lib/libnetlink.a
149         insinto /usr/include
150         doins include/libnetlink.h
151         # This local header pulls in a lot of linux headers it
152         # doesn't directly need.  Delete this header that requires
153         # linux-headers-3.8 until that goes stable.  #467716
154         sed -i '/linux\/netconf.h/d' "${ED}"/usr/include/libnetlink.h || die
155
156         if use berkdb ; then
157                 keepdir /var/lib/arpd
158                 # bug 47482, arpd doesn't need to be in /sbin
159                 dodir /usr/bin
160                 mv "${ED}"/sbin/arpd "${ED}"/usr/bin/ || die
161         fi
162 }