# Description: A GUI toolkit for TCL.
# URL: https://www.tcl.tk/
# Maintainer: Danny Rawlins, crux at romster dot me
# Depends on: xorg-libxft tcl

name=tk
version=8.6.13
_version=$(echo $version | awk -F'.' '{if (NF <= '2') {print $0} else {print $1 "." $2 "." $3}}')
release=1
source=(https://downloads.sourceforge.net/project/tcl/Tcl/$_version/$name$version-src.tar.gz)

build() {
	cd $name$_version/unix

	./configure \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--enable-gcc \
		--enable-shared \
		--enable-xft

	make
	make MKLINKS_FLAGS="-s" INSTALL_ROOT=$PKG install install-private-headers

	cp ../generic/*.h $PKG/usr/include/
	cp tkUnixPort.h $PKG/usr/include/tkPort.h
	cp tkUnixDefault.h $PKG/usr/include/tkDefault.h
	cp tkUnixInt.h $PKG/usr/include/tkInt.h

	# remove $SRC traces
	sed \
		-e "s|$SRC/tk$_version/unix|/usr/lib|g" \
		-e "s|$SRC/tk$_version|/usr/include|g" \
		-i $PKG/usr/lib/tkConfig.sh

	rm -r $PKG/usr/lib/tk${_version%.*}/demos
	rm $PKG/usr/lib/tk${_version%.*}/images/README

	ln -s wish${_version%.*} $PKG/usr/bin/wish
	ln -s libtk${_version%.*}.so $PKG/usr/lib/libtk.so
	ln -s libtkstub${_version%.*}.a $PKG/usr/lib/libtkstub.a

	chmod -R u+w $PKG/usr/share/man
}
