# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0

name                ngrep
version             1.45
revision            1
categories          net
maintainers         nomaintainer

description         Network grep
long_description \
    ngrep strives to provide most of GNU grep's common features, applying \
    them to the network layer. \
    ngrep a pcap-aware tool that will allow you to specify extended \
    regular expressions to match against data payloads of packets. It \
    currently recognizes TCP, UDP, and ICMP across Ethernet, PPP, SLIP, \
    FDDI, Token Ring and null interfaces, and understands BPF filter \
    logic in the same fashion as more common packet sniffing tools, \
    like tcpdump and snoop.

platforms           darwin
homepage            http://ngrep.sourceforge.net
master_sites        sourceforge:project/${name}/${name}/${version}/

checksums           rmd160  d4b89dfa23f6a7c65d3ccefc846362054a46605f \
                    sha256  aea6dd337da8781847c75b3b5b876e4de9c58520e0d77310679a979fc6402fa7

use_bzip2           yes

depends_lib-append  port:libpcap \
                    port:pcre

patch.pre_args-replace  -p0 -p1
patchfiles          10_debian-build.diff \
                    10_man-fixes.diff \
                    20_setlocale.diff \
                    40_ipv6-offsets.diff

configure.args      --with-pcap-includes=${prefix}/include \
                    --mandir=${prefix}/share/man \
                    --enable-pcre \
                    --enable-ipv6 \
                    --disable-pcap-restart
                    # above line required to avoid segfaults
                    # see https://github.com/jpr5/ngrep/commit/e29fc29
                    # https://github.com/Homebrew/homebrew/issues/27171
build.env-append    CC=${configure.cc} \
                    "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"
