8.18. Tcl-8.6.16

The Tcl package contains the Tool Command Language, a robust general-purpose scripting language. The Expect package is written in Tcl (pronounced "tickle").

Approximate build time: 3.1 SBU
Required disk space: 91 MB

8.18.1. Installation of Tcl

This package and the next two (Expect and DejaGNU) are installed to support running the test suites for Binutils, GCC and other packages. Installing three packages for testing purposes may seem excessive, but it is very reassuring, if not essential, to know that the most important tools are working properly.

Create the PKGBUILD for the Tcl package with the following commands:

mkdir /sources/tcl
cd /sources/tcl
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="tcl"
pkgver="8.6.16"
pkgrel="1"
pkgdesc="The Tcl package contains the Tool Command Language, a robust general-purpose scripting language."
arch=('x86'
      'x86_64')
url="https://tcl.sourceforge.net/"
license=('UC-Regents3C')
groups=('core')
options=('staticlibs')
depends=('glibc'
         'zlib')
makedepends=('bash'
             'binutils'
             'coreutils'
             'diffutils'
             'grep'
             'make'
             'sed')
source=('https://downloads.sourceforge.net/tcl/tcl8.6.16-src.tar.gz'
        'https://downloads.sourceforge.net/tcl/tcl8.6.16-html.tar.gz')
md5sums=('eaef5d0a27239fb840f04af8ec608242'
         '750c221bcb6f8737a6791c1fbe98b684')
    
noextract=("${pkgname}${pkgver}-html.tar.gz")

_tdbc="1.1.10"
_itcl="4.3.2"
_ver="8.6"

build() {
  cd "${srcdir}/tcl${pkgver}"
  SRCDIR=$(pwd)
  cd unix
  ./configure --prefix=/usr           \
              --mandir=/usr/share/man \
              --disable-rpath

  make

  sed -e "s|${SRCDIR}/unix|/usr/lib|" \
      -e "s|${SRCDIR}|/usr/include|"  \
      -i tclConfig.sh

  sed -e "s|${SRCDIR}/unix/pkgs/tdbc${_tdbc}|/usr/lib/tdbc${_tdbc}|" \
      -e "s|${SRCDIR}/pkgs/tdbc${_tdbc}/generic|/usr/include|"       \
      -e "s|${SRCDIR}/pkgs/tdbc${_tdbc}/library|/usr/lib/tcl8.6|"    \
      -e "s|${SRCDIR}/pkgs/tdbc${_tdbc}|/usr/include|"               \
      -i "pkgs/tdbc${_tdbc}/tdbcConfig.sh"

  sed -e "s|${SRCDIR}/unix/pkgs/itcl${_itcl}|/usr/lib/itcl${_itcl}|" \
      -e "s|${SRCDIR}/pkgs/itcl${_itcl}/generic|/usr/include|"       \
      -e "s|${SRCDIR}/pkgs/itcl${_itcl}|/usr/include|"               \
      -i "pkgs/itcl${_itcl}/itclConfig.sh"
}

check() {
  cd "${srcdir}/tcl${pkgver}/unix"
  make test
}

package() {
  cd "${srcdir}/tcl${pkgver}/unix"
  make DESTDIR="${pkgdir}" install

  # Make the installed library writable so that it can be stirpped
  chmod -v u+w "${pkgdir}/usr/lib/libtcl${_ver}.so"

  # Install the headers
  make DESTDIR="${pkgdir}" install-private-headers

  # Create the normal tclsh link
  ln -sfv "tclsh${_ver}" "${pkgdir}/usr/bin/tclsh"

  # Rename a man page that conflicts with a Perl man page
  mv -v "${pkgdir}"/usr/share/man/man3/{,Tcl_}Thread.3

  # Install the documentation
  tar -xf "${srcdir}/${pkgname}${pkgver}-html.tar.gz" --strip-components=1
  mkdir -pv "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
  cp -rv    ./html/* "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
}
REALEOF

The meaning of the new configure parameters:

--disable-rpath

This parameter prevents hard coding library search paths (rpath) into the binary executable files and shared libraries. This package does not need rpath for an installation into the standard location, and rpath may sometimes cause unwanted effects or even security issues.

The various sed instructions after the make command remove references to the build directory from the configuration files and replace them with the install directory. This is not mandatory for the remainder of LFS, but may be needed if a package built later uses Tcl.

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp tcl-8.6.16-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/tcl-8.6.16-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Tcl package:

pacman -Syu
pacman -S tcl --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/tcl
cp PKGBUILD /srv/pacman/source/LFS/tcl
cd /sources
rm -rf tcl

8.18.2. Contents of Tcl

Installed programs: tclsh (link to tclsh8.6) and tclsh8.6
Installed library: libtcl8.6.so and libtclstub8.6.a

Short Descriptions

tclsh8.6

The Tcl command shell

tclsh

A link to tclsh8.6

libtcl8.6.so

The Tcl library

libtclstub8.6.a

The Tcl Stub library