#!/bin/bash

# tix.build
# Based on the original Slackware Build script
# Modified by Stuart Winter <stuart@armedslack.org> for ARMedslack

# Extract tix source:
cd $TMPBUILD
tar xvvf $CWD/Tix$VERSION.tar.gz
cd Tix$VERSION
slackhousekeeping

# Apply patches:
zcat $CWD/tix.tcl8.5.patch.gz | patch -p1 --backup --suffix=.orig || failpatch
zcat $CWD/tix.soname.patch.gz | patch -p1 || failpatch

# If this can't find the source:
# Unpack ../tcl/sources/tcl-compiled & ../tk/sources/tk-compiled archives
# and edit /usr/lib/tclConfig.sh to point to the source
# locations of both, then try again.
# This used to be scriptable but doesn't seem to be as easy as before.

# Configure:
LDFLAGS="-L/usr/lib" \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
   --prefix=/usr \
   --enable-shared \
   --with-tclconfig=/usr/lib \
   --with-tkconfig=/usr/lib \
   --with-tclinclude=/usr/include \
   --with-tkinclude=/usr/include || failconfig

# Build:
make || failmake

# Install:
make install || failinstall
mkdir -p /usr/doc/$PKGNAM-$VERSION
cp -a ABOUT.* README.* license.terms \
  docs/FAQ.txt docs/Files.* \
  docs/Release-8.4* docs/license* docs/html \
  /usr/doc/$PKGNAM-$VERSION
mkdir -p /usr/man/mann
cp -a man/*.n /usr/man/mann

mkdir -p /install
install -vpm644 $CWD/slack-desc /install/
