1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 # Force users doing their own patches to install their own tools
7 AUTOTOOLS_AUTO_DEPEND=no
9 inherit multilib systemd toolchain-funcs autotools flag-o-matic usr-ldscript
11 DESCRIPTION="Linux kernel (2.4+) firewall, NAT and packet mangling tools"
12 HOMEPAGE="https://www.netfilter.org/projects/iptables/"
13 SRC_URI="https://www.netfilter.org/projects/iptables/files/${P}.tar.bz2"
16 # Subslot reflects PV when libxtables and/or libip*tc was changed
19 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
20 IUSE="conntrack ipv6 netlink nftables pcap static-libs"
23 conntrack? ( >=net-libs/libnetfilter_conntrack-1.0.6 )
24 netlink? ( net-libs/libnfnetlink )
26 >=net-libs/libmnl-1.0:0=
27 >=net-libs/libnftnl-1.1.5:0=
29 pcap? ( net-libs/libpcap )
31 DEPEND="${COMMON_DEPEND}
33 >=sys-kernel/linux-headers-4.4:0
42 RDEPEND="${COMMON_DEPEND}
43 nftables? ( net-misc/ethertypes )
47 # use the saner headers from the kernel
48 rm include/linux/{kernel,types}.h || die
50 eapply "${FILESDIR}"/${PN}-1.8.2-link.patch
56 # Some libs use $(AR) rather than libtool to build #444282
59 # Hack around struct mismatches between userland & kernel for some ABIs. #472388
60 use amd64 && [[ ${ABI} == "x32" ]] && append-flags -fpack-struct
63 -e "/nfnetlink=[01]/s:=[01]:=$(usex netlink 1 0):" \
64 -e "/nfconntrack=[01]/s:=[01]:=$(usex conntrack 1 0):" \
68 --sbindir="${EPREFIX}/sbin"
69 --libexecdir="${EPREFIX}/$(get_libdir)"
72 $(use_enable nftables)
73 $(use_enable pcap bpf-compiler)
74 $(use_enable pcap nfsynproxy)
75 $(use_enable static-libs static)
78 econf "${myeconfargs[@]}"
87 dodoc INCOMPATIBILITIES iptables/iptables.xslt
89 # all the iptables binaries are in /sbin, so might as well
90 # put these small files in with them
92 dosbin iptables/iptables-apply
93 dosym iptables-apply /sbin/ip6tables-apply
94 doman iptables/iptables-apply.8
97 doins include/iptables.h $(use ipv6 && echo include/ip6tables.h)
98 insinto /usr/include/iptables
99 doins include/iptables/internal.h
101 keepdir /var/lib/iptables
102 newinitd "${FILESDIR}"/${PN}-r2.init iptables
103 newconfd "${FILESDIR}"/${PN}-r1.confd iptables
105 keepdir /var/lib/ip6tables
106 dosym iptables /etc/init.d/ip6tables
107 newconfd "${FILESDIR}"/ip6tables-r1.confd ip6tables
110 if use nftables; then
112 rm "${ED}"/etc/ethertypes || die
115 rm "${ED}"/sbin/{arptables,ebtables} || die
118 rm "${ED}"/sbin/ebtables-{save,restore} || die
121 systemd_dounit "${FILESDIR}"/systemd/iptables-{re,}store.service
123 systemd_dounit "${FILESDIR}"/systemd/ip6tables-{re,}store.service
126 # Move important libs to /lib #332175
127 gen_usr_ldscript -a ip{4,6}tc xtables
129 find "${ED}" -type f -name "*.la" -delete || die