# $Id: Portfile 67973 2010-05-23 16:10:07Z ryandesign@macports.org $

################################################################
# The developer of whois is hostile toward bug reports. Do     #
# not waste his time and yours by speaking with him about his  #
# software. If you encounter problems updating this port to a  #
# newer version, find a workaround and write a patch. Do not   #
# report upstream. See http://trac.macports.org/ticket/16037   #
################################################################

PortSystem                  1.0
PortGroup                   archcheck 1.0

name                        whois
conflicts                   bahamut
version                     5.0.5
categories                  net
maintainers                 ryandesign
homepage                    http://www.linux.it/~md/software/
platforms                   darwin
use_parallel_build          yes

description                 A replacement whois client

long_description            whois is an improved whois client that follows the \
                            delegations from the Verisign whois server.

master_sites                http://ftp.debian.org/debian/pool/main/w/${name}/

checksums                   md5     0a045c041a58ca8e8449c9f96fba47e0 \
                            sha1    d460081c1a0006f8b42cc40a707cf6b48e5dbf55 \
                            rmd160  0e1184483e08b23e0110aa15fa8737b84d6cbdf6

distname                    ${name}_${version}
worksrcdir                  ${name}-${version}

depends_lib                 port:gettext
archcheck.files             lib/libintl.dylib

# Bugs should be reported to MacPorts, not upstream.
patchfiles-append           patch-bugreport.diff

platform darwin {
    # -lcrypt cannot be used (and is unnecessary) on Mac OS X
    patchfiles-append       patch-lcrypt.diff
}

configure.cmd               make
configure.pre_args          depend
configure.cflags-append     -DENABLE_NLS
configure.ldflags-append    -lintl
configure.universal_args-delete --disable-dependency-tracking

post-configure {
    reinplace "s|/etc/whois.conf|${prefix}/etc/whois.conf|g" \
        ${worksrcpath}/whois.1
}

set my_includes {}
set my_libs {}

build.target-append         pos
build.env                   CC=${configure.cc} \
                            CONFIG_FILE=${prefix}/etc/whois.conf \
                            LOCALEDIR=${prefix}/share/locale

pre-build {
    eval lappend my_includes ${configure.cflags} ${configure.cppflags}
    eval lappend my_libs ${configure.ldflags}
    build.args              prefix=${prefix} \
                            INCLUDES="${my_includes}" \
                            LIBS="${my_libs}"
}

destroot.target-append      install-pos
destroot.args               prefix=${destroot}${prefix}

post-destroot {
    xinstall -m 644 -W ${worksrcpath} whois.conf ${destroot}${prefix}/etc/whois.conf.sample
}

post-activate {
    if {![file exists ${prefix}/etc/whois.conf]} {
        ui_msg "To customize which whois servers get used, copy"
        ui_msg "${prefix}/etc/whois.conf.sample to"
        ui_msg "${prefix}/etc/whois.conf and then make changes."
    }
}

variant universal {
    eval lappend my_includes ${configure.universal_cflags}
    eval lappend my_libs ${configure.universal_ldflags}
}

livecheck.type              regex
livecheck.url               [lindex ${master_sites} 0]?C=M&O=D
livecheck.regex             "${name}_(.+?)${extract.suffix}"
