# -*- 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                    tcp_wrappers
version                 20
revision                5

categories              net devel
license                 Permissive
maintainers             {mascguy @mascguy} {jeremyhu @jeremyhu} openmaintainer

description             Security wrappers for TCP services
long_description \
    TCP Wrappers provides tiny daemon wrapper programs that can be installed \
    without any changes to existing software or to existing configuration \
    files.  The wrappers report the name of the client host and of the \
    requested service\; the wrappers do not exchange information with the \
    client or server applications, and impose no overhead on the actual \
    conversation between the client and server applications.

homepage                http://www.opensource.apple.com
# Avoid stealth update (with no code changes) due to hosting being
# moved to GitHub. https://trac.macports.org/ticket/66539
#master_sites            ${homepage}/tarballs/${name}
master_sites            macports_distfiles

worksrcdir              ${name}-${version}/${name}

checksums               rmd160  c98c1ad9cff26b10f5c5c80f38d41178f28a8a4d \
                        sha256  5c144021828edf10933997f9a085720862f937255d4ca10e60d63a651d3ea493 \
                        size    114916

patchfiles-append       patch-clang.diff \
                        patch-fix-prototypes.diff \
                        patch-header-guard.diff \
                        patch-no-return-type.diff

post-patch {
    reinplace "s:/usr/lib/:${prefix}/lib/:g" ${worksrcpath}/Makefile
}

use_configure           no

variant universal {}

build.target            macos
build.args              REAL_DAEMON_DIR=${prefix}/libexec \
                        STYLE=-DPROCESS_OPTIONS           \
                        FACILITY=LOG_REMOTEAUTH           \
                        ALLOW_SEVERITY=LOG_INFO           \
                        DENY_SEVERITY=LOG_WARNING         \
                        PARANOID=                         \
                        HOSTNAME=                         \
                        BUGS=                             \
                        MAJOR=7                           \
                        MINOR=6                           \
                        CFLAGS="-g -Os -pipe -fno-common" \
                        CC="${configure.cc} [get_canonical_archflags cc]"

destroot {
    xinstall -m 755 -W ${worksrcpath} safe_finger tcpdchk tcpdmatch try-from \
        ${destroot}${prefix}/sbin
    xinstall -m 755 -W ${worksrcpath} safe_finger tcpd \
        ${destroot}${prefix}/libexec
    xinstall -m 644 -W ${worksrcpath} hosts_access.3 \
        ${destroot}${prefix}/share/man/man3
    ln -s hosts_access.3 ${destroot}${prefix}/share/man/man3/hosts_ctl.3
    ln -s hosts_access.3 ${destroot}${prefix}/share/man/man3/request_init.3
    ln -s hosts_access.3 ${destroot}${prefix}/share/man/man3/request_set.3
    xinstall -m 644 -W ${worksrcpath} hosts_access.5 hosts_options.5 \
        ${destroot}${prefix}/share/man/man5
    xinstall -m 644 -W ${worksrcpath} tcpd.8 tcpdchk.8 tcpdmatch.8 \
        ${destroot}${prefix}/share/man/man8
    xinstall -m 644 -W ${worksrcpath} libwrap.a libwrap.7.dylib \
        ${destroot}${prefix}/lib
    ln -s libwrap.7.dylib ${destroot}${prefix}/lib/libwrap.dylib
    xinstall -m 644 -W ${worksrcpath} tcpd.h \
        ${destroot}${prefix}/include
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} BLURB DISCLAIMER README README.NIS \
        ${destroot}${prefix}/share/doc/${name}
}

livecheck.type          regex
livecheck.url           ${homepage}/tarballs/${name}
livecheck.regex         ${name}-(\\d+(?:\\.\\d+)*)\\.tar
