# $Id: Portfile 92890 2012-05-10 10:14:22Z jmr@macports.org $

PortSystem              1.0
name                    tcp_wrappers
version                 20
revision                2
categories              net
license                 Permissive
maintainers             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
master_sites            ${homepage}/tarballs/${name}

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

checksums           sha1    6b197780e11633013bc6026e9f5d1b008c9e8e64 \
                    rmd160  c98c1ad9cff26b10f5c5c80f38d41178f28a8a4d \
                    sha256  5c144021828edf10933997f9a085720862f937255d4ca10e60d63a651d3ea493

platforms               darwin

patchfiles              clang.patch
patch.pre_args          -p2

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}
}
