# -*- 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
PortGroup           github 1.0
PortGroup           legacysupport 1.1
PortGroup           openssl 1.0

# memmem
legacysupport.newest_darwin_requires_legacy 10

github.setup        hackerschoice dsniff 4b270c79748a2141d4007886b1f8db1ddc17984a
version             2025.12.10
revision            0

categories          net
license             BSD
maintainers         {@barracuda156 macos-powerpc.org:barracuda}

description         ${name} is a network sniffer
long_description    Resurrection and enhancements of Dug Song’s \
                    all-time-classic network sniffer
checksums           rmd160  85fbfc298915a7cac6407d1e585c49cc60aa2910 \
                    sha256  604d3c8fff9b8fb5595e69ed59b2676c164f88c8107597770251decc5a3a183d \
                    size    222771
github.tarball_from archive

use_autoreconf      yes

# Requires BDB 1.85 compatibility.
set db_v            46

patch.pre_args-replace -p0 -p1
patchfiles-append   0001-strlcat.h-strlcpy.h-use-declarations-only-when-neede.patch \
                    0002-Makefile.in-do-not-hardcode-prefix.patch \
                    0003-configure.ac-improve-detection-of-db-and-pcap.patch \
                    0004-nfs_prot.x-fix-for-Apple.patch

if {[string match *gcc-4.* ${configure.compiler}]} {
    patchfiles-append \
                    0005-gcc4.patch
}

depends_lib-append  port:db${db_v} \
                    port:libnet \
                    port:libnids \
                    port:libpcap \
                    port:xorg-libice \
                    port:xorg-libsm \
                    port:xorg-libX11 \
                    port:xorg-libXmu

configure.args-append \
                    --prefix=${prefix} \
                    --with-db=${prefix} \
                    --with-openssl=[openssl::install_area] \
                    --x-includes=${prefix}/include \
                    --x-libraries=${prefix}/lib

# dnsspoof.c:184:9: error: unknown type name 'HEADER' etc.
configure.cflags-append \
                    -DBIND_8_COMPAT

# https://github.com/Homebrew/legacy-homebrew/issues/27642
compiler.blacklist-append \
                    {clang} macports-clang*
compiler.fallback   gcc-4.2 macports-gcc-14 macports-gcc-13 macports-gcc-12 macports-gcc-11

# https://github.com/hackerschoice/dsniff/issues/3
# record.c:76:30: error: passing argument 2 of 'xdr_u_long' from incompatible pointer type [-Wincompatible-pointer-types]
if {[string match macports-gcc* ${configure.compiler}]} {
    configure.cflags-append \
                    -Wno-error=incompatible-pointer-types
}

destroot.destdir    prefix=${destroot}${prefix}
