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

name                    tkimg
version                 1.4.16
revision                1
categories              graphics
license                 Tcl/Tk
maintainers             {mcalhoun @MarcusCalhoun-Lopez} {gmx.us:chrischavez @chrstphrchvz} openmaintainer
homepage                https://tkimg.sourceforge.net
description             adds a lot of image formats to Tcl/Tk
long_description        The \"Img\" package adds a lot of image formats to Tcl/Tk.

master_sites            sourceforge:tkimg/tkimg/[join [lrange [split ${version} .] 0 1] .]/tkimg%20${version}
distname                Img-${version}-Source
extract.rename          yes

checksums               rmd160  6b4fb4bd3558990ffc8aa4bb30246973027b5a7c \
                        sha256  d99af4835fe3e20960817c7a1b5235dcfaa97c642593cce50bdb64c5827cd321 \
                        size    12129708

# ensure tkimg works when tk is installed +quartz
patchfiles-append       patch-quartz.diff

# tkimg builds local copies of jpeg, libpng, and tiff
# Other package management systems have patches that allow tkimg to use external (MacPorts) versions.
# Unfortunately, these patches are highly intrusive and difficult to maintain.
# This really is an upstream issue.
# See
#    https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-tcltk/tkimg
#    https://packages.debian.org/sid/libtk-img


# for dtplite
depends_build-append    port:tcllib

depends_lib-append      port:tcl \
                        port:zlib

configure.args-append   --with-tcl=${prefix}/lib

destroot.destdir        INSTALL_ROOT=${destroot}

if {${os.platform} eq "darwin" && ${os.subplatform} eq "macosx"
    && ${os.major} >= 10 && ![string match ppc* ${build_arch}]} {

    variant quartz conflicts x11 {
        depends_lib-append  port:tk-quartz
        configure.args-append   --with-tk=${prefix}/lib/tk-quartz \
                                --with-tkinclude=${prefix}/include/tk-quartz
    }
    if {![variant_isset x11]} {
        default_variants +quartz
    }
    set x11conflicts quartz
} else {
    default_variants +x11
    set x11conflicts {}
}

variant x11 conflicts {*}${x11conflicts} {
    depends_lib-append  port:tk-x11
    configure.args-append   --with-tk=${prefix}/lib/tk-x11 \
                            --with-tkinclude=${prefix}/include/tk-x11
}

livecheck.url           https://wiki.tcl-lang.org/page/Img
livecheck.regex         {>(\d+\.\d+\.\d+)<}
