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

PortSystem  1.0
PortGroup   legacysupport 1.1

# strnlen
legacysupport.newest_darwin_requires_legacy 10

name        nmap
version     7.991
revision    0
categories  net
maintainers {darkart.com:opendarwin.org @ghosthound} {geeklair.net:dluke @danielluke}
# NPSL - https://nmap.org/npsl/
# gpl-2 with additional restrictions, so not actually gpl-2
license     {GPL-2 OpenSSLException} Restrictive/Distributable
platforms   darwin freebsd
description Port scanning utility for large networks
long_description Nmap is a utility for port scanning large networks, although \
    it works fine for single hosts. The guiding philosophy for \
    the creation of nmap was TMTOWTDI (There's More Than One Way \
    To Do It). This is the Perl slogan, but it is equally \
    applicable to scanners. Sometimes you need speed, other \
    times you may need stealth. In some cases, bypassing \
    firewalls may be required. Not to mention the fact that you \
    may want to scan different protocols (UDP, TCP, ICMP etc.). \
    You just can't do all this with one scanning mode. And you \
    don't want to have 10 different scanners around, all with \
    different interfaces and capabilities.
homepage        https://nmap.org
master_sites    ${homepage}/dist/
use_bzip2       yes
checksums       rmd160  941be32df1d4deda4f118766252fbc9c082c2439 \
                sha256  a5d507f29437bef3bedd4771ff9aaa8fc1c2a109ddba1f5b1cf12027456929be \
                size    12877122

if {${os.platform} eq "darwin" && ${os.major} < 11} {
            patchfiles-append pre-cxx11-workarounds.patch
}

depends_build \
            port:autoconf \
            port:automake

depends_lib-append \
            port:libpcap \
            port:libssh2 \
            port:zlib

configure.args \
            --infodir=\\\${prefix}/share/info \
            --mandir=\\\${prefix}/share/man \
            --with-liblua=included \
            --without-ndiff \
            --without-zenmap

# https://trac.macports.org/ticket/58837
# build system does not pass the stdlib on the link line resulting in link errors
# for some build configurations using non-default stdlib settings
if {${os.platform} eq "darwin" && ${os.major} < 13} {
    if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
        configure.ldflags-append -stdlib=${configure.cxx_stdlib}
    }
}

# nmap's configure script in nselib-bin does not respect --with-liblua=included
configure.env ac_cv_header_lua_h=no

default_variants +ssl +pcre

variant ssl description "Build with ssl support" {
    PortGroup   openssl 1.0

    openssl.branch 3

    configure.args-append   --with-openssl=[openssl::install_area]
}

variant pcre description "Build with pcre support" {
    depends_lib-append      port:pcre2
    configure.args-append   --with-pcre=${prefix}
}

notes "Zenmap is now provided by a separate port."
