1{ stdenv, fetchurl, fetchpatch, flex, bison }:
2
3stdenv.mkDerivation rec {
4 name = "libpcap-1.9.0";
5
6 src = fetchurl {
7 url = "https://www.tcpdump.org/release/${name}.tar.gz";
8 sha256 = "06bhydl4vr4z9c3vahl76f2j96z1fbrcl7wwismgs4sris08inrf";
9 };
10
11 nativeBuildInputs = [ flex bison ];
12
13 # We need to force the autodetection because detection doesn't
14 # work in pure build enviroments.
15 configureFlags = [
16 ("--with-pcap=" + {
17 linux = "linux";
18 darwin = "bpf";
19 }.${stdenv.hostPlatform.parsed.kernel.name})
20 ] ++ stdenv.lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [
21 "ac_cv_linux_vers=2"
22 ];
23
24 dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;
25
26 prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
27 substituteInPlace configure --replace " -arch i386" ""
28 '';
29
30 patches = [
31 # https://github.com/the-tcpdump-group/libpcap/pull/735
32 (fetchpatch {
33 name = "add-missing-limits-h-include-pr735.patch";
34 url = https://github.com/the-tcpdump-group/libpcap/commit/aafa3512b7b742f5e66a5543e41974cc5e7eebfa.patch;
35 sha256 = "05zb4hx9g24gx07bi02rprk2rn7fdc1ss3249dv5x36qkasnfhvf";
36 })
37 ];
38
39 meta = with stdenv.lib; {
40 homepage = https://www.tcpdump.org;
41 description = "Packet Capture Library";
42 platforms = platforms.unix;
43 maintainers = with maintainers; [ fpletz ];
44 license = licenses.bsd3;
45 };
46}