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

name                zathura
version             0.4.4
revision            0
categories          office
maintainers         nomaintainer
license             zlib

description         Zathura is a highly customizable and functional document viewer.
long_description \
    Zathura is a highly customizable and functional document viewer. It     \
    provides a minimalistic and space saving interface as well as an easy   \
    usage that mainly focuses on keyboard interaction. Zathura uses a plug- \
    in based system for supported document types. Zathura makes it possible \
    to completely view and navigate through different documents without a   \
    mouse. It supports bi-directional SyncTeX, as well as quickmarks, book- \
    marks and automatic document reloading. Almost everything in Zathura is \
    customizable.

homepage            https://git.pwmt.org/pwmt/zathura

master_sites        ${homepage}/-/archive/${version}/

checksums           rmd160  50dbda19ca101f680c3935befbde631217143a3b \
                    sha256  ebc98478fd8ec412b8f87c6b75067cf52d89d200731c1848ec3a2700f2a3b36c \
                    size    194105

depends_build-append \
                    port:gettext \
                    port:intltool \
                    path:bin/pkg-config:pkgconfig

depends_lib         port:desktop-file-utils \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:sqlite3 \
                    port:libmagic \
                    path:lib/libgirara-gtk3.dylib:girara

patchfiles          meson.build.patch

# meson will automatically detect if synctex is available and link
# against it. Explicitly disable it to avoid breaking zathura if
# ever users uninstall texlive-bin
configure.args-append   -Dsynctex=disabled

compiler.c_standard 2011

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
}

notes "
For handling additional file types, consider installing the various
zathura-plugin-* ports (port search zathura-plugin).
"

subport ${name}-docs {
    platforms           any
    supported_archs     noarch

    set python.version 39
    set python.dot_version "[string index ${python.version} 0].[string range ${python.version} 1 end]"

    post-patch {
        reinplace "s|sphinx-build|${frameworks_dir}/Python.framework/Versions/${python.dot_version}/bin/sphinx-build|g" ${worksrcpath}/doc/meson.build
    }

    depends_build-append \
                        port:py${python.version}-sphinx

    depends_run-append  port:${name}

    build.target        doc/zathura.1 doc/zathurarc.5

    destroot {
        xinstall -m 640 ${build_dir}/doc/zathura.1   ${destroot}${prefix}/share/man/man1
        xinstall -m 640 ${build_dir}/doc/zathurarc.5 ${destroot}${prefix}/share/man/man5
    }

    unset notes
}

variant synctex description "Enable synctex support" {
    depends_lib-append  port:texlive-bin

    configure.args-replace -Dsynctex=disabled -Dsynctex=enabled
}

livecheck.type      regex
livecheck.url       ${homepage}/tags
livecheck.regex     [quotemeta ${name}]-(\\d\\.\\d\\.\\d)[quotemeta ${extract.suffix}]
