Skip to content
Draft
107 changes: 107 additions & 0 deletions projects/tcl-lang.org/tk/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Tk — Tcl's cross-platform GUI toolkit.
#
# Companion to tcl-lang.org. Needed to build any Tcl-based GUI:
# git-gui, gitk, IDLE/python-tk, AWR, etc.

distributable:
url: https://downloads.sourceforge.net/project/tcl/Tcl/{{version}}/tk{{version}}-src.tar.gz
strip-components: 1

versions:
url: https://www.tcl-lang.org/software/tcltk/download.html
match: /tk\d+\.\d+\.\d+-src\.tar\.gz/
strip:
- /^tk/
- /-src\.tar\.gz/

platforms:
- linux/x86-64
- linux/aarch64
- darwin/x86-64
- darwin/aarch64

dependencies:
tcl-lang.org: '*'
freedesktop.org/pkg-config: '*'
linux:
x.org/x11: '*'
x.org/exts: '*'
freetype.org: '*'

build:
# Tk 9.0+ embeds a zipfs of its own resources into libtk*.zip at
# build time. configure probes for `zip(1)` on PATH; if absent it
# prints "Building minizip" but the resulting Makefile has no
# rule for the `minizip` target and `make` dies with
# "No rule to make target 'minizip', needed by 'libtk9.0.3.zip'"
# Providing zip(1) lets configure pick the simple path.
dependencies:
info-zip.org/zip: '*'
working-directory: unix
darwin:
working-directory: macosx
# brewkit's fix-macho pass dies with "failed to fix machos" on
# wish9.0 — the binary's LC_LOAD_DYLIB references libtcl9tk9.0.dylib
# by absolute path and install_name_tool's heuristics don't relink
# it. Use the same manual install_name_tool + skip:fix-macho dance
# that the sibling tcl.tk/tcl recipe uses.
skip: fix-machos
script:
- ./configure $ARGS
- make --jobs {{ hw.concurrency }}
- make install
- make install-private-headers || true

- run: |
cd "{{prefix}}/bin"
[ ! -e wish ] && ln -sf "wish{{version.major}}.{{version.minor}}" wish || true
- run: |
# Relink wish's libtk reference to @loader_path so the bottle
# is relocatable (`fix-macho` would have done this but it
# bails on this binary; do it manually).
TKLIB=$(basename {{prefix}}/lib/libtcl*tk{{version.major}}.{{version.minor}}.dylib 2>/dev/null | head -1)
if [ -n "$TKLIB" ] && [ -f "{{prefix}}/bin/wish{{version.major}}.{{version.minor}}" ]; then
install_name_tool \
-change "{{prefix}}/lib/$TKLIB" "@loader_path/../lib/$TKLIB" \
"{{prefix}}/bin/wish{{version.major}}.{{version.minor}}" \
|| echo "warn: install_name_tool failed; relocation may break"
fi
if: darwin
env:
# tcl.h's install path varies by Tcl version: 8.6 puts it at
# $prefix/include/tcl-tk/tcl.h, 9.0 at $prefix/include/tcl.h.
# Cover both with multiple -I flags.
CPPFLAGS: -I{{deps.tcl-lang.org.prefix}}/include -I{{deps.tcl-lang.org.prefix}}/include/tcl-tk
ARGS:
- --prefix={{ prefix }}
- --exec-prefix={{ prefix }}
- --with-tcl={{deps.tcl-lang.org.prefix}}/lib
- --with-tclinclude={{deps.tcl-lang.org.prefix}}/include
- --enable-shared
- --enable-threads
- --enable-64bit
darwin:
ARGS:
- --enable-aqua

test:
# Tk 9.0 installs the shared library as `libtcl9tk9.0.so` on Linux
# (Tcl-version-prefixed since Tk 9.x — *not* `libtk9.0.so` like
# Tk 8.6 did). Accept any `lib*tk*` shape to keep working across
# the rename, with a directory listing on failure.
- run: |
set -e
shopt -s nullglob
libs=("{{prefix}}/lib/"lib*tk*.{so,dylib}*)
if [ ${#libs[@]} -eq 0 ]; then
echo "FAIL: no lib*tk* found in {{prefix}}/lib/"
ls -la "{{prefix}}/lib/" || true
exit 1
fi
echo "found tk shared libs:"
printf ' %s\n' "${libs[@]}"
- echo 'puts $tk_version' | wish -display :0 2>&1 | head -1 || true

provides:
- bin/wish
- bin/wish{{version.major}}.{{version.minor}}
Loading