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

if {[string match *gcc* ${configure.compiler}]} {
    # https://trac.macports.org/ticket/65995
    PortGroup       muniversal 1.0
}

name                texinfo
version             7.2
revision            0
categories          textproc
license             GPL-3+
maintainers         nomaintainer

installs_libs       no

description         The official documentation format of the GNU project
long_description    Texinfo is the official documentation format of \
                    the GNU project. It uses a single source file to \
                    produce output in a number of formats, both \
                    online and printed (dvi, info, html, xml, etc.). \
                    This means that instead of writing different \
                    documents for online information and another for \
                    a printed manual, you need write only one \
                    document. Some features need texlive (unnecessary \
                    if only the info command is used).
homepage            https://www.gnu.org/software/texinfo/

perl5.require_variant yes
perl5.conflict_variants yes
perl5.branches 5.28 5.30 5.32 5.34 5.36 5.38
perl5.default_branch 5.34
perl5.create_variants ${perl5.branches}

depends_build       port:gettext \
                    port:help2man
depends_lib         port:gettext-runtime \
                    port:libiconv \
                    port:libunistring \
                    port:ncurses \
                    port:perl${perl5.major}

master_sites        gnu
use_xz              yes

checksums           rmd160 e6ba34142ecfed2add55e288f9739d30ba103d1d \
                    sha256 0329d7788fbef113fa82cb80889ca197a344ce0df7646fe000974c5d714363a6 \
                    size   6408432

# https://trac.macports.org/wiki/WimplicitFunctionDeclaration#strchr
configure.checks.implicit_function_declaration.whitelist-append strchr

configure.perl      ${perl5.bin}
pre-configure {
    configure.env-append \
        PERL_EXT_CFLAGS=[get_canonical_archflags cc] \
        PERL_EXT_LDFLAGS=[get_canonical_archflags ld]
}

destroot.target-append  install-tex
destroot.args           TEXMF=${prefix}/share/texmf

pre-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -v -W ${worksrcpath} \
        AUTHORS COPYING ChangeLog NEWS README TODO doc/refcard/txirefcard.pdf \
        ${destroot}${prefix}/share/doc/${name}
}

# mktexlsr is provided by texlive-bin (and needed only if texlive-bin
# is installed). texlive-bin may be installed/uninstalled independently
# of texinfo (but not at the same time, unless a locking mechanism is
# provided). The use of a variant would not be flexible enough.

post-activate {
    if {[file exists ${prefix}/bin/mktexlsr]} {
        ui_debug {Rebuilding TeX ls-R filename databases}
        catch {system ${prefix}/bin/mktexlsr}
    }
}

post-deactivate {
    if {[file exists ${prefix}/bin/mktexlsr]} {
        ui_debug {Rebuilding TeX ls-R filename databases}
        catch {system ${prefix}/bin/mktexlsr}
    }
}

# We need to support names like 'texinfo-4.8a.tar.bz2'.
livecheck.type      regex
livecheck.url       https://ftp.gnu.org/gnu/texinfo/?C=M\;O=D
livecheck.regex     ${name}-(\[0-9.a-s\]+)\\.tar
