summaryrefslogtreecommitdiff
blob: bbbdcf9ba346eeaeedd9b3335e4b8775bd21223f (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
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit toolchain-funcs flag-o-matic

MY_P="nc${PV}"
DESCRIPTION="The network swiss army knife"
HOMEPAGE="https://nc110.sourceforge.io"
SRC_URI="mirror://sourceforge/nc110/${MY_P}.tar.xz"
S="${WORKDIR}/nc110"

LICENSE="netcat"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~sparc64-solaris ~x64-solaris"
IUSE="ipv6 static"

src_prepare() {
	default

	sed -i \
		-e '/#define HAVE_BIND/s:#define:#undef:' \
		-e '/#define FD_SETSIZE 16/s:16:1024: #34250' \
		netcat.c || die

	if [[ ${CHOST} == *-solaris* ]] ; then
		sed -i 's:gethostbyname2 *(\([^)]\+\)):getipnodebyname (\1, AI_DEFAULT, NULL):' netcat.c || die
	fi
}

src_configure() {
	if ! use ipv6 ; then
		sed -i '/#define INET6/d' generic.h || die
	fi

	append-cppflags -DTELNET -DGAPING_SECURITY_HOLE
}

src_compile() {
	local xlibs

	[[ ${CHOST} == *-solaris* ]] && xlibs+=" -lnsl -lsocket"

	emake \
		LD="$(tc-getCC) ${LDFLAGS}" \
		DFLAGS="${CPPFLAGS}" \
		XFLAGS="${CFLAGS}" \
		STATIC=$(usex static '-static' '') \
		XLIBS="${xlibs}" \
		nc
}

src_install() {
	dobin nc

	dodoc README* netcat.blurb
	doman nc.1

	docinto scripts
	dodoc scripts/*
}