# -*- 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 92609 2012-05-02 07:32:47Z 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 expect ripe-whois
version                     5.0.16
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}/
use_xz                      yes

checksums                   rmd160  c0d3fc28bf61757e858bd048cf58a15f752bde0c \
                            sha256  b628be5bd5e7527b7695a2e28508d61989d8b1e57407d3215ff7145e2070d604

distfiles                   [suffix ${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
}

use_configure               no

if {${configure.compiler} == "clang"} {
    configure.compiler llvm-gcc-4.2
}

configure.cflags-append     -DENABLE_NLS
configure.ldflags-append    -lintl

post-configure {
    system -W ${worksrcpath} "CC='${configure.cc}' make depend servers_charset.h"
    reinplace "s|/etc/whois.conf|${prefix}/etc/whois.conf|g" \
        ${worksrcpath}/whois.1
}

variant universal {}

build.target-append         pos
build.env                   CC="${configure.cc} [get_canonical_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}"
