# -*- 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                tktable
version             2.11
revision            3
categories          x11
license             Tcl/Tk
maintainers         {gmx.us:chrischavez @chrstphrchvz} openmaintainer
description         A table/matrix widget extension to Tk/Tcl
long_description    {*}${description}
homepage            http://tktable.sourceforge.net/

# TkTable 2.11 was never posted to SourceForge.
# A copy of the TkTable repository, owned by a Tcl/Tk developer,
# is available for users to obtain 2.11 from.
master_sites        https://chiselapp.com/user/pooryorick/repository/tktable/tarball/4018de567f/
distname            unnamed-4018de567f
checksums           rmd160  2332e79467b15c5b9855dd12ad6f21328017fa2b \
                    sha256  7c9c06338c2cb7e414f23650e4122093b540c60c672dc4f440a12588e1b3a1d5 \
                    size    292797

# Fix remaining compiler warnings
patchfiles-append   patch-CONST86.diff \
                    patch-INT2PTR.diff

# Avoid a bug in tk +quartz (use X clip region emulation)
patchfiles-append   patch-aqua-xsetclip.diff

# ensure correct libraries are found during testing
# see https://trac.macports.org/ticket/38238
patchfiles-append   patch-dyld_variable.diff \
                    patch-quartz.diff \
                    panic.patch

depends_build       port:tcl

variant universal {}

configure.args      --with-tcl=${prefix}/lib \
                    CPPFLAGS="${configure.cppflags}" \
                    CFLAGS="${configure.cflags} [get_canonical_archflags cc]" \
                    LDFLAGS="${configure.ldflags} [get_canonical_archflags ld]"

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

    variant quartz conflicts x11 {
        depends_build-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_build-append    port:tk-x11
    configure.args-append   --with-tk=${prefix}/lib/tk-x11 \
                            --with-tkinclude=${prefix}/include/tk-x11
}

test.run            yes
test.target         test

livecheck.type      none
