# -*- 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.2.20260621.0 p
github.tarball_from archive
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  85584fca18077467c2a833886e059160d6b216ce \
                    sha256  3e2adb58abf7d4bad25a8c7258cadf4c85d963c9e692dd66ab387daf4f1f10b9 \
                    size    3380002

# 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.14
    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.
    }
}
