# -*- 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           cmake 1.1
PortGroup           conflicts_build 1.0

# Need strndup()
PortGroup           legacysupport 1.1
legacysupport.newest_darwin_requires_legacy 10

name                weechat
version             4.7.1
revision            0
checksums           rmd160  c8683962267f791620f688e7f14b98fa55b25504 \
                    sha256  e83fb71ca251c5dd74bd9c5a6bd3f85dc2eb8ecec0955f43c07f3e0911edb7d3 \
                    size    2768340

master_sites        https://weechat.org/files/src/
use_xz              yes

livecheck.type      regex
livecheck.regex     ^(\[0-9.\]*)$
livecheck.url       https://weechat.org/dev/info/stable/

homepage            https://weechat.org/
license             GPL-3
description         Fast, light & extensible IRC client
long_description    WeeChat (Wee Enhanced Environment for Chat) is \
                    a fast and light IRC client for many operating \
                    systems. Everything can be done with a keyboard. \
                    It is customizable and extensible with \
                    plugins/scripts, and includes: \
                    \n - nicklist \
                    \n - smart hotlist \
                    \n - infobar with highlight notification \
                    \n - horizontal and vertical split \
                    \n - double charset support (decode/encode) \
                    \n - FIFO pipe for remote control \
                    \n - and much more!

categories          irc
maintainers         {acm.org:cardi @cardi} openmaintainer

depends_build-append \
                    port:asciidoctor \
                    port:docbook-xsl-nons \
                    port:libxslt \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:curl \
                    port:gettext \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    port:libcjson \
                    port:libgcrypt \
                    port:libiconv \
                    port:ncurses

depends_run-append  path:etc/openssl/cert.pem:curl-ca-bundle

depends_test-append port:cpputest

license_noconflict  asciidoctor

patchfiles          no-extra-gcc-warnings.patch

configure.args-append \
                    -DENABLE_GUILE=OFF \
                    -DENABLE_JAVASCRIPT=OFF \
                    -DENABLE_LUA=OFF \
                    -DENABLE_MAN=ON \
                    -DENABLE_PERL=OFF \
                    -DENABLE_PHP=OFF \
                    -DENABLE_PYTHON=OFF \
                    -DENABLE_RUBY=OFF \
                    -DENABLE_SPELL=OFF \
                    -DENABLE_TCL=OFF \
                    -DENABLE_TESTS=OFF

variant python requires python313 description {Compatibility variant, requires +python313} {}

variant python39 description "Bindings for Python 3.9 plugins" conflicts python310 python311 python312 python313 {
    configure.args-replace  -DENABLE_PYTHON=OFF -DENABLE_PYTHON=ON
    configure.pkg_config_path-append \
                            ${frameworks_dir}/Python.framework/Versions/3.9/lib/pkgconfig
    depends_lib-append      port:python39
}

variant python310 description "Bindings for Python 3.10 plugins" conflicts python39 python311 python312 python313 {
    configure.args-replace  -DENABLE_PYTHON=OFF -DENABLE_PYTHON=ON
    configure.pkg_config_path-append \
                            ${frameworks_dir}/Python.framework/Versions/3.10/lib/pkgconfig
    depends_lib-append      port:python310
}

variant python311 description "Bindings for Python 3.11 plugins" conflicts python39 python310 python312 python313 {
    configure.args-replace  -DENABLE_PYTHON=OFF -DENABLE_PYTHON=ON
    configure.pkg_config_path-append \
                            ${frameworks_dir}/Python.framework/Versions/3.11/lib/pkgconfig
    depends_lib-append      port:python311
}

variant python312 description "Bindings for Python 3.12 plugins" conflicts python39 python310 python311 python313 {
    configure.args-replace  -DENABLE_PYTHON=OFF -DENABLE_PYTHON=ON
    configure.pkg_config_path-append \
                            ${frameworks_dir}/Python.framework/Versions/3.12/lib/pkgconfig
    depends_lib-append      port:python312
}

variant python313 description "Bindings for Python 3.13 plugins" conflicts python39 python310 python311 python312 {
    configure.args-replace  -DENABLE_PYTHON=OFF -DENABLE_PYTHON=ON
    configure.pkg_config_path-append \
                            ${frameworks_dir}/Python.framework/Versions/3.13/lib/pkgconfig
    depends_lib-append      port:python313
}

variant ruby requires ruby33 description {Compatibility variant, requires +ruby33} {}

variant ruby31 description "Bindings for Ruby 3.1 plugins" conflicts ruby32 ruby33 {
    configure.args-replace  -DENABLE_RUBY=OFF -DENABLE_RUBY=ON
    depends_lib-append      port:ruby31
}

variant ruby32 description "Bindings for Ruby 3.2 plugins" conflicts ruby31 ruby33 {
    configure.args-replace  -DENABLE_RUBY=OFF -DENABLE_RUBY=ON
    depends_lib-append      port:ruby32
}

variant ruby33 description "Bindings for Ruby 3.3 plugins" conflicts ruby31 ruby32 {
    configure.args-replace  -DENABLE_RUBY=OFF -DENABLE_RUBY=ON
    depends_lib-append      port:ruby33
}

variant aspell description {Support for Spellcheck (aspell)} {
    configure.args-delete   -DENABLE_SPELL=OFF
    configure.args-append   -DENABLE_SPELL=ON
    depends_lib-append      port:aspell
}

variant doc description {Build HTML Documentation and Plugin API} {
    configure.args-append   -DENABLE_DOC=ON -DENABLE_DOC_INCOMPLETE=ON
    depends_build-append    port:source-highlight

    notes-append "Documentation is not built for disabled plugins."
}

variant lua description {Bindings for Lua plugins} {
    configure.args-delete   -DENABLE_LUA=OFF
    configure.args-append   -DENABLE_LUA=ON
    depends_lib-append      port:lua
}

variant perl description {Bindings for Perl plugins} {
    configure.args-delete   -DENABLE_PERL=OFF
    configure.args-append   -DENABLE_PERL=ON
    depends_lib-append      path:bin/perl:perl5
}

variant scheme description {Bindings for Scheme (guile) plugins} {
    configure.args-delete   -DENABLE_GUILE=OFF
    configure.args-append   -DENABLE_GUILE=ON
    depends_lib-append      port:guile-3.0
}

variant tcl description {Bindings for Tcl plugins} {
    configure.args-delete   -DENABLE_TCL=OFF
    configure.args-append   -DENABLE_TCL=ON
    depends_lib-append      port:tcl
}

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/weechat
    xinstall -m 644 -W ${worksrcpath} AUTHORS.md COPYING CHANGELOG.md README.md ${destroot}${prefix}/share/doc/weechat
    xinstall -m 644 -W ${worksrcpath} {*}[glob doc/en/weechat*.adoc] ${destroot}${prefix}/share/doc/weechat
}
