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

name                texinfo
conflicts           texinfo-6.4
version             6.7
revision            1
categories          textproc
platforms           darwin
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/

master_sites        gnu
use_xz              yes

checksums           rmd160  c0b9b544c235908ccdbb4a63dec898967e1c7a40 \
                    sha256  988403c1542d15ad044600b909997ba3079b10e03224c61188117f3676b02caa \
                    size    4337984

# set pbranch to desired perl version
set pbranch         5.30

subport texinfo-6.4 {
	# older version of texinfo, needed for some older software like gcc43 that has not been updated
    description         older version of texinfo, needed for some older software builds
    conflicts           texinfo
	version             6.4
	revision            0
	checksums           rmd160  6da2c8fa06194d3176ec7b56155dfd8638094943 \
						sha256  6ae2e61d87c6310f9af7c6f2426bd0470f251d1a6deb61fba83a3b3baff32c3a \
						size    4497624
	set pbranch         5.28
}

depends_build       port:help2man
depends_lib         port:gettext \
                    port:libiconv \
                    port:ncurses \
                    port:perl${pbranch}

configure.perl      ${prefix}/bin/perl${pbranch}
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}
}

post-destroot {
    file delete -force ${destroot}${prefix}/lib/charset.alias
}

# 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}
        system ${prefix}/bin/mktexlsr
    }
}

post-deactivate {
    if {[file exists ${prefix}/bin/mktexlsr]} {
        ui_debug {Rebuilding TeX ls-R filename databases}
        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
