# -*- 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           github 1.0
PortGroup           legacysupport 1.1

github.setup        universal-ctags ctags 6.1.20241229.0 p
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                universal-ctags
epoch               1
revision            0

categories          devel
license             GPL-2+
maintainers         {@kaimingguo gmail.com:augustin.guo} \
                    {@judaew judaew} \
                    openmaintainer

description         A maintained ctags implementation
long_description \
    universal-ctags has the objective of continuing the development from what \
    existed in the Sourceforge area. Github exuberant-ctags repository was \
    started by Reza Jelveh and was later moved to the universal-ctags organization.

homepage            https://ctags.io

checksums           rmd160  d8d936b293cfa9ce42ef5fa90ba10f51551cfa41 \
                    sha256  af107f883af01a47f66604beb63c6a780105bf8c5d51eb36133fa85f2c365e60 \
                    size    3209088

# LegacySupport is needed for strnlen before 10.7
legacysupport.newest_darwin_requires_legacy 10

use_autoconf        yes
autoconf.cmd        ./autogen.sh
configure.args      --program-prefix=u --enable-json --enable-yaml

depends_build       port:autoconf \
                    port:automake \
                    port:pkgconfig \
                    port:libtool

depends_lib         port:jansson \
                    port:pcre2 \
                    port:libyaml

universal_variant   no
default_variants    +iconv +libxml2 +manpages

variant aspell description {Enable aspell backend} {
    depends_lib-append      port:aspell
    depends_run             port:aspell-dict-en
    configure.args-append   --enable-aspell
}

variant debug description {Build with debug support} {
    configure.args-append   --enable-debugging
}

variant iconv description {Add iconv support} {
    depends_lib-append      port:libiconv
    configure.args-append   --enable-iconv
}

variant libxml2 description {Extra support for XML based languages} {
    depends_lib-append      port:libxml2
    configure.args-append   --enable-xml
}

variant manpages description {Enable documentation} {
    set python_branch       3.12
    set python_version      [string map {. {}} ${python_branch}]

    depends_build-append    port:py${python_version}-docutils

    configure.args-append   --with-rst2man=${prefix}/bin/rst2man-${python_branch} \
                            --with-rst2html=${prefix}/bin/rst2html-${python_branch}
}

variant link_to_ctags description {Create a link from uctags to ctags} {
    conflicts           ctags
    post-destroot {
        ln -s ${prefix}/bin/uctags ${destroot}${prefix}/bin/ctags
    }
    notes-append {
        The link_to_ctags variant conflicts with the `ctag` (Exuberant Ctags)
        and `global` (GNU Global) ports. In the case of the global port, the
        issue is that it depends on Exuberant Ctags and Universal Ctags at
        the same time.
    }
}
