# -*- 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 119197 2014-04-20 03:58:44Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               conflicts_build 1.0

name                    gawk
version                 4.1.1
revision                2
categories              lang
license                 GPL-3+
installs_libs           no
maintainers             gmail.com:mschamschula openmaintainer
platforms               darwin
master_sites            gnu
homepage                http://www.gnu.org/software/gawk/
description             The GNU awk utility.
use_xz                  yes

long_description \
    The awk utility interprets a special-purpose programming language   \
    that makes it possible to handle simple data-reformatting jobs with \
    just a few lines of code. It is a free, extended version of awk.

checksums               sha256  efd4c6aafb1ce996309fc903ceb625e7012221c464eb72483dbb23adef1ee8db \
                        rmd160  a5a6ab9491bf702310cef7c035531cc7fad0a62d

depends_lib             port:gettext \
                        port:readline

conflicts_build         nawk

patchfiles              patch-extensions-Makefile.in.diff

configure.args          --with-libiconv-prefix=${prefix} \
                        --without-mpfr \
                        ac_cv_libsigsegv=no

test.run                yes
test.target             check

post-destroot {
    delete ${destroot}${prefix}/bin/awk

    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin
    foreach binary [glob -tails -directory ${destroot}${prefix}/bin g*] {
        ln -s ${prefix}/bin/${binary} ${destroot}${prefix}/libexec/gnubin/[string range $binary 1 end]
    }
    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin/man/man1
    foreach manpage [glob -tails -directory ${destroot}${prefix}/share/man/man1 g*] {
        ln -s ${prefix}/share/man/man1/${manpage}.gz ${destroot}${prefix}/libexec/gnubin/man/man1/[string range $manpage 1 end].gz
    }
}

variant mpfr description {Add mpfr support} {
    depends_lib-append  port:gmp \
                        port:mpfr

    configure.args-delete   --without-mpfr
}
