net-analyzer/openbsd-netcat: undo Linuxification on Darwin
authorFabian Groffen <grobian@gentoo.org>
Mon, 4 Jul 2016 12:24:02 +0000 (14:24 +0200)
committerFabian Groffen <grobian@gentoo.org>
Mon, 4 Jul 2016 12:25:00 +0000 (14:25 +0200)
Package-Manager: portage-2.2.28

net-analyzer/openbsd-netcat/openbsd-netcat-1.105-r1.ebuild

index c4d9efa17197ef733aaf956c0acd04878feb7aa6..f20c5c3d556636be1c8ed88c3a1d5e706a771c64 100644 (file)
@@ -4,7 +4,7 @@
 
 EAPI=6
 
-inherit toolchain-funcs
+inherit toolchain-funcs flag-o-matic
 
 DESCRIPTION="The OpenBSD network swiss army knife"
 HOMEPAGE="http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/"
@@ -12,11 +12,12 @@ SRC_URI="http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd
        http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_${PV}-7.debian.tar.gz"
 LICENSE="BSD"
 SLOT="0"
+IUSE="elibc_Darwin"
 
 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x64-macos"
 
 DEPEND="virtual/pkgconfig"
-RDEPEND="dev-libs/libbsd
+RDEPEND="!elibc_Darwin? ( dev-libs/libbsd )
        !net-analyzer/netcat
        !net-analyzer/netcat6
 "
@@ -25,6 +26,16 @@ S=${WORKDIR}/netcat-openbsd-${PV}
 
 PATCHES=( "${WORKDIR}/debian/patches" )
 
+src_prepare() {
+       default
+       if [[ ${CHOST} == *-darwin* ]] ; then
+               # Darwin = BSD, so remove libbsd dependency
+               sed -i -e '/#include/s|bsd/||' -e 's/strtonum/strtoimax/' *.[ch] || die
+               # Clang defaults to C99, but strtoimax isn't in C99
+               append-flags -DIPTOS_LOWCOST=0x02 -std=c89
+       fi
+}
+
 src_compile() {
        emake CC=$(tc-getCC) CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" || die
 }