1{ lib, stdenv, fetchurl, flex, bison, bluez, pkg-config, withBluez ? false }:
2
3with lib;
4
5stdenv.mkDerivation rec {
6 pname = "libpcap";
7 version = "1.10.1";
8
9 src = fetchurl {
10 url = "https://www.tcpdump.org/release/${pname}-${version}.tar.gz";
11 sha256 = "sha256-7ShfSsyvBTRPkJdXV7Pb/ncrpB0cQBwmSLf6RbcRvdQ=";
12 };
13
14 nativeBuildInputs = [ flex bison ]
15 ++ optionals withBluez [ bluez.dev pkg-config ];
16
17 # We need to force the autodetection because detection doesn't
18 # work in pure build environments.
19 configureFlags = [
20 "--with-pcap=${if stdenv.isLinux then "linux" else "bpf"}"
21 ] ++ optionals stdenv.isDarwin [
22 "--disable-universal"
23 ] ++ optionals (stdenv.hostPlatform == stdenv.buildPlatform)
24 [ "ac_cv_linux_vers=2" ];
25
26 postInstall = ''
27 if [ "$dontDisableStatic" -ne "1" ]; then
28 rm -f $out/lib/libpcap.a
29 fi
30 '';
31
32 meta = {
33 homepage = "https://www.tcpdump.org";
34 description = "Packet Capture Library";
35 platforms = platforms.unix;
36 maintainers = with maintainers; [ fpletz ];
37 license = licenses.bsd3;
38 };
39}