# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0

name                djview
version             4.12.3
revision            0
categories          aqua graphics www
license             GPL-2+ MIT
maintainers         {nicos @NicosPavlov} openmaintainer
platforms           darwin

description         DjVu files viewer.
long_description    DjVu can advantageously replace PDF, PS, TIFF,JPEG, and GIF for \
                    distributing scanned documents, digital documents, or high-resolution \
                    pictures. DjVu content downloads faster, displays and renders faster, \
                    looks nicer on a screen and consume less client resources than competing \
                    formats.

homepage            http://djvu.sourceforge.net/djview4.html

master_sites        sourceforge:project/djvu/DjView/4.12/

patchfiles          patch-powerpc.diff

checksums           rmd160  7190a27b20118b877c2d58a6a94afbf8319dc513 \
                    sha256  17bfb9731ab8070e01235381f08e57b1231ffb5f49eb031873ebfa189cdaf47d \
                    size    1986642

depends_lib-append  port:djvulibre
depends_build-append \
                    path:bin/pkg-config:pkgconfig

universal_variant   yes
use_autoreconf      yes

if {${os.platform} eq "darwin" && ${os.major} < 17} {
    PortGroup           qt4 1.0

} elseif {${os.platform} eq "darwin" && ${os.major} < 21} {
    PortGroup           qt5 1.0

    # Location of qmake
    configure.env-append QMAKE=${prefix}/libexec/qt5/bin/qmake \
                         QMAKESPEC=macx-clang
} else {
    PortGroup           qt6 1.0

    qt6.depends_lib     qt5compat

    # Location of qmake
    configure.env-append QMAKE=${prefix}/libexec/qt6/bin/qmake \
                         QMAKESPEC=macx-clang
}

subport djview-qt5 {
    PortGroup           obsolete 1.0

    replaced_by         djview
}

configure.ldflags
configure.args \
    --disable-nsdejavu \
    --disable-desktopfiles

build.args-append   V=1

# allow ccache, if specified by the user
pre-build {
    if {[tbool configure.ccache]} {
        build.post_args "CCACHE=ccache"
    }
}

destroot {
    copy ${worksrcpath}/src/djview.app ${destroot}${applications_dir}
}

livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
livecheck.name      djvu
livecheck.distname  DjView
