#!/bin/sh

echo -n "xgusmix: "

if [ "$1" != "driver" ]; then
  echo "Driver required..."
  exit 1
fi

RESULT=n
if [ -r /usr/include/tcl.h ] ||
   [ -r /usr/include/tcl/tcl.h ] ||
   [ -r /usr/local/include/tcl.h ] ||
   [ -r /usr/local/include/tcl/tcl.h ]; then
  RESULT=y
fi

if [ "$RESULT" = "n" ]; then
  echo "Tcl library not found... "
  exit 1
fi

RESULT=n
if [ -r /usr/include/tk.h ] ||
   [ -r /usr/include/tcl/tk.h ] ||
   [ -r /usr/local/include/tk.h ] ||
   [ -r /usr/local/include/tcl/tk.h ]; then
  RESULT=y
fi

if [ "$RESULT" = "n" ]; then
  echo "Tk library not found... "
  exit 1
fi

make syscheck 2> /dev/null > /dev/null
if [ -x ./tcltkcheck ]; then
  if ./tcltkcheck; then
    echo -n ""
  else
    exit 1
  fi
else
  echo "Unexpected error..."
  exit 1
fi

echo "Success..."
exit 0
