PortSystem      1.0
PortGroup       github 1.0

# No proper release of this version, so we're fetching it from the tag
# on the GitHub mirror.
github.setup    tcltk itk 4-2-2 itk-
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version         [string map {- .} ${github.version}]
revision        1
categories		x11 tk
license			Tcl/Tk MIT
maintainers		nomaintainer
description		\[incr Tk\] A.K.A. \"itk\".  Object oriented extension to Tk.
long_description	{*}${description}
homepage		https://incrtcl.sourceforge.net/itk/

dist_subdir		tcltk

checksums		rmd160 641adb6354e4db234e8104175d0a45039d9c9e7e \
			sha256 409e23d68a5185666da4ab9e49d67ca5f7584e7e9e8d796ee1ad2137aa86c927
depends_lib             port:tk

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

pre-configure {
    # itcl dir has a changing version number in it
    set itcldirs [glob -directory ${prefix}/lib itcl*]
    set itcldirs [lsort -decreasing -command vercmp $itcldirs]
    foreach d ${itcldirs} {
        if {[file isfile ${d}/itclConfig.sh] && [registry_file_registered ${d}/itclConfig.sh] eq "tcl"} {
            configure.args-append --with-itcl=${d}
            break
        }
    }
}

destroot.args   INSTALL=install
post-destroot {
    # Conflicts with tk's "toplevel" man page on case-insensitive systems
    move ${destroot}${prefix}/share/man/mann/Toplevel.n \
        ${destroot}${prefix}/share/man/mann/itk_Toplevel.n
}
