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

PortSystem              1.0

# IMPORTANT
# On future version bumps, make sure you also revbump the libtool port
# Otherwise glibtoolize will provide an incompatible version of aclocal.m4
# from the older version of automake.
# cf: ${prefix}/share/libtool/aclocal.m4
name                    automake
version                 1.19
revision                0
categories              devel
license                 GPL-2+
platforms               {darwin any}
supported_archs         noarch
homepage                https://www.gnu.org/software/automake
maintainers             {sethm.id.au:dev @McDaMastR} \
                        openmaintainer

description             The GNU utility for generating Makefile.in files
long_description        Automake is a tool for automatically generating \
                        Makefile.in files from files called Makefile.am. Each \
                        Makefile.am is basically a series of make variable \
                        definitions, with rules being thrown in occasionally. \
                        The generated Makefile.in files are compliant with \
                        the GNU Makefile standards.

# The test suite appears to include checks that automake is compatible with
# a wide variety of programs. Hence to ensure the test suite gives consistent
# results, all these programs must be present in the system. But this would
# require so many test dependencies that it risks introducing circular
# dependencies (since automake is a common build dependency). So just let the
# test suite skip checks with nonexistent programs and accept that `port test`
# will give different results on different systems.

master_sites            gnu
extract.suffix          .tar.xz
checksums               rmd160  79fcaec130719f3ee3dd72a366e5f98079f5da91 \
                        sha256  e3e2c2e3abf37898138db5b6c1d1dc35c9160c5978be7947d2c741705251d445 \
                        size    1682600

depends_extract         port:xz-bootstrap
extract.cmd             ${prefix}/libexec/xz-bootstrap/bin/xz

installs_libs           no

depends_build-append    port:autoconf

patchfiles              test-glibtool.patch

configure.args-append   --disable-silent-rules

# <https://trac.macports.org/wiki/WimplicitFunctionDeclaration>
configure.checks.implicit_function_declaration.whitelist-append \
                        alignof

test.run                yes
test.target             check

post-destroot {
    set destdocdir  ${destroot}${prefix}/share/doc/${name}

    xinstall -d ${destdocdir}
    xinstall -W ${worksrcpath} -m 644 \
        AUTHORS \
        COPYING \
        ChangeLog \
        HACKING \
        INSTALL \
        NEWS \
        NEWS-future \
        README \
        THANKS \
        ${destdocdir}
}

if {${os.platform} eq "darwin"} {
    # It should be safe to use the system Perl, since Automake only uses core
    # modules. The configure script requires 5.6 or later, and Tiger has 5.8.6.
    # Though the script recommends 5.10 or later, which was first included in
    # Snow Leopard. So if Mac OS X < 10.6 users report issues, remember to
    # check whether the perl version is the problem.
    configure.perl          /usr/bin/perl
} else {
    depends_lib-append      path:bin/perl:perl5
    configure.perl          ${prefix}/bin/perl5
}

livecheck.type          regex
livecheck.url           https://ftp.gnu.org/gnu/${name}/
livecheck.regex         "${name}-(\[0-9]+(\\.\[0-9]+)*)\\.tar\\.gz"
