# -*- 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
# $Id: Portfile 75725 2011-02-05 20:46:22Z 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 ripe-whois
version                     5.0.11
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                   sha1    435770400fbccd0066af62a85e2028420e43ca4b \
                            rmd160  c1b4fecf6759aafe54b0b05ff32a0fc9503ea0de

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

depends_lib                 port:gettext \
                            port:libidn \
                            port:libiconv

archcheck.files             lib/libintl.dylib \
                            lib/libidn.dylib \
                            lib/libiconv.dylib

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

# Add libidn and libiconv support.
patchfiles-append           patch-idn-iconv.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
}

variant universal {}
if {[variant_isset universal]} {
    set archflags ${configure.universal_cflags}
} else {
    set archflags ${configure.cc_archflags}
}

build.target-append         pos
build.env                   CC="${configure.cc} ${archflags}" \
                            CONFIG_FILE=${prefix}/etc/whois.conf \
                            HAVE_LIBIDN=1 \
                            HAVE_ICONV=1 \
                            LOCALEDIR=${prefix}/share/locale
build.args                  prefix=${prefix} \
                            INCLUDES="${configure.cflags} ${configure.cppflags}" \
                            LIBS="${configure.ldflags}"

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
}

notes "
To customize which whois servers get used, copy\
${prefix}/etc/whois.conf.sample to\
${prefix}/etc/whois.conf and then make changes.
"

pre-activate {
    # Clear the notes if the user has already done what they say to do.
    if {[file exists ${prefix}/etc/whois.conf]} {
        notes
    }
}

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