view network/libpcap/libpcap.sh @ 1188:6d825a761bae

network/libpcap: initial import, closes #2421
author David Demelier <markand@malikania.fr>
date Mon, 28 Oct 2019 13:21:51 +0100
parents
children 6710613b88b9
line wrap: on
line source

#!/bin/sh
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

PKGNAME=libpcap
PKGVERSION=1.9.1
PKGREVISION=1
PKGLICENSE="BSD3CLAUSE"
PKGSUMMARY="system-independent interface for user-level packet capture"
PKGWWW="https://www.tcpdump.org"
PKGDOWNLOAD="https://www.tcpdump.org/release/$PKGNAME-$PKGVERSION.tar.gz"
PKGDEPENDS="bison:build flex:build linux-headers:build"
PKGOPTIONS="DBUS IPV6 NETLINK USB"

: ${CHOST:=$(uname -m)-linux-musl}
: ${CBUILD:=$(uname -m)-linux-musl}
: ${AR:=llvm-ar}
: ${CC:=clang}
: ${CFLAGS:=-O2}
: ${LDFLAGS:=}
: ${LIBS:=}
: ${RANLIB:=llvm-ranlib}
: ${DBUS:=yes}
: ${IPV6:=yes}
: ${NETLINK:=yes}
: ${USB:=yes}

if [ "$DBUS" = "yes" ]; then
	PKGDEPENDS="dbus $PKGDEPENDS"
	with_dbus="--enable-dbus"
else
	with_dbus="--disable-dbus"
fi

if [ "$IPV6" = "yes" ]; then
	with_ipv6="--enable-ipv6"
else
	with_ipv6="--disable-ipv6"
fi

if [ "$NETLINK" = "yes" ]; then
	PKGDEPENDS="libnl $PKGDEPENDS"
	with_netlink="--with-libnl"
else
	with_netlink="--without-libnl"
fi

if [ "$USB" = "yes" ]; then
	PKGDEPENDS="eudev:build $PKGDEPENDS"
	with_usb="--enable-usb"
else
	with_usb="--disable-usb"
fi

build()
{
	rm -rf $PKGNAME-$PKGVERSION
	tar xvf $PKGNAME-$PKGVERSION.tar.gz
	cd $PKGNAME-$PKGVERSION

	AR="$AR" \
	CC="$CC" \
	CFLAGS="$CFLAGS" \
	LDFLAGS="$LDFLAGS" \
	LIBS="$LIBS" \
	RANLIB="$RANLIB" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix= \
		$with_dbus \
		$with_ipv6 \
		$with_netlink \
		$with_usb
	make
	make install DESTDIR=$DESTDIR

	cd ..
	rm -rf $PKGNAME-$PKGVERSION
}