*/*: Discontinue Gentoo SuperH port
[gentoo.git] / net-firewall / iptables / iptables-1.8.4.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 # Force users doing their own patches to install their own tools
7 AUTOTOOLS_AUTO_DEPEND=no
8
9 inherit multilib systemd toolchain-funcs autotools flag-o-matic usr-ldscript
10
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"
14
15 LICENSE="GPL-2"
16 # Subslot reflects PV when libxtables and/or libip*tc was changed
17 # the last time.
18 SLOT="0/1.8.3"
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"
21
22 COMMON_DEPEND="
23         conntrack? ( >=net-libs/libnetfilter_conntrack-1.0.6 )
24         netlink? ( net-libs/libnfnetlink )
25         nftables? (
26                 >=net-libs/libmnl-1.0:0=
27                 >=net-libs/libnftnl-1.1.5:0=
28         )
29         pcap? ( net-libs/libpcap )
30 "
31 DEPEND="${COMMON_DEPEND}
32         virtual/os-headers
33         >=sys-kernel/linux-headers-4.4:0
34 "
35 BDEPEND="
36         virtual/pkgconfig
37         nftables? (
38                 sys-devel/flex
39                 virtual/yacc
40         )
41 "
42 RDEPEND="${COMMON_DEPEND}
43         nftables? ( net-misc/ethertypes )
44 "
45
46 src_prepare() {
47         # use the saner headers from the kernel
48         rm include/linux/{kernel,types}.h || die
49
50         eapply "${FILESDIR}"/${PN}-1.8.2-link.patch
51         eapply_user
52         eautoreconf
53 }
54
55 src_configure() {
56         # Some libs use $(AR) rather than libtool to build #444282
57         tc-export AR
58
59         # Hack around struct mismatches between userland & kernel for some ABIs. #472388
60         use amd64 && [[ ${ABI} == "x32" ]] && append-flags -fpack-struct
61
62         sed -i \
63                 -e "/nfnetlink=[01]/s:=[01]:=$(usex netlink 1 0):" \
64                 -e "/nfconntrack=[01]/s:=[01]:=$(usex conntrack 1 0):" \
65                 configure || die
66
67         local myeconfargs=(
68                 --sbindir="${EPREFIX}/sbin"
69                 --libexecdir="${EPREFIX}/$(get_libdir)"
70                 --enable-devel
71                 --enable-shared
72                 $(use_enable nftables)
73                 $(use_enable pcap bpf-compiler)
74                 $(use_enable pcap nfsynproxy)
75                 $(use_enable static-libs static)
76                 $(use_enable ipv6)
77         )
78         econf "${myeconfargs[@]}"
79 }
80
81 src_compile() {
82         emake V=1
83 }
84
85 src_install() {
86         default
87         dodoc INCOMPATIBILITIES iptables/iptables.xslt
88
89         # all the iptables binaries are in /sbin, so might as well
90         # put these small files in with them
91         into /
92         dosbin iptables/iptables-apply
93         dosym iptables-apply /sbin/ip6tables-apply
94         doman iptables/iptables-apply.8
95
96         insinto /usr/include
97         doins include/iptables.h $(use ipv6 && echo include/ip6tables.h)
98         insinto /usr/include/iptables
99         doins include/iptables/internal.h
100
101         keepdir /var/lib/iptables
102         newinitd "${FILESDIR}"/${PN}-r2.init iptables
103         newconfd "${FILESDIR}"/${PN}-r1.confd iptables
104         if use ipv6 ; then
105                 keepdir /var/lib/ip6tables
106                 dosym iptables /etc/init.d/ip6tables
107                 newconfd "${FILESDIR}"/ip6tables-r1.confd ip6tables
108         fi
109
110         if use nftables; then
111                 # Bug 647458
112                 rm "${ED}"/etc/ethertypes || die
113
114                 # Bug 660886
115                 rm "${ED}"/sbin/{arptables,ebtables} || die
116
117                 # Bug 669894
118                 rm "${ED}"/sbin/ebtables-{save,restore} || die
119         fi
120
121         systemd_dounit "${FILESDIR}"/systemd/iptables-{re,}store.service
122         if use ipv6 ; then
123                 systemd_dounit "${FILESDIR}"/systemd/ip6tables-{re,}store.service
124         fi
125
126         # Move important libs to /lib #332175
127         gen_usr_ldscript -a ip{4,6}tc xtables
128
129         find "${ED}" -type f -name "*.la" -delete || die
130 }