# -*- 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

################################################################
# 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                   compiler_blacklist_versions 1.0
PortGroup                   perl5 1.0

name                        whois
conflicts                   bahamut expect ripe-whois
version                     5.2.15
categories                  net
maintainers                 ryandesign
license                     GPL-2+
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  3da5730f992ef0ef27596bcc9a45d43714f747aa \
                            sha256  7a5a6b690bfc6360d92d9328adbe5c1f096a41f0d6548ce0df4aa664dcb37188

distfiles                   ${name}_${version}${extract.suffix}

perl5.branches              5.24

depends_build               port:perl${perl5.major}

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

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

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

use_configure               no

compiler.blacklist          {clang < 318}

configure.cflags-append     -DENABLE_NLS
configure.ldflags-append    -lintl
configure.perl              ${perl5.bin}

post-configure {
    system -W ${worksrcpath} "CC='${configure.cc}' ${build.cmd} depend servers_charset.h PERL='${configure.perl}'"
}

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}" \
                            PERL="${configure.perl}"

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