#!/bin/sh
#
# Checkinstall - perform preinstallation install checks.
#
# This is a modified version of a script written by mark@metalab.unc.edu .
# The original is at http://metalab.unc.edu/pub/packages/solaris/sparc/html/creating.solaris.packages.html .

GTK_CONFIG=@GTK_CONFIG@

gtk_major_needed="1"
gtk_minor_needed="2"

host_cpu="@host_cpu@"
host_os="@host_os@"

release=`uname -r`
platform=`uname -p`

expected_platform="@host_cpu@"

if [ -x $GTK_CONFIG ] ; then
  # First try the GTK location that was used to build ethereal.  This
  # is probably the safest bet.
  gtk_installed=`$GTK_CONFIG --version`
  gtk_major_installed=`echo $gtk_installed | cut -f1 -d.`
  gtk_minor_installed=`echo $gtk_installed | cut -f2 -d.`
elif gtk_installed=`gtk-config --version 2>&-`; then
  # Punt! 
  # If gtk-config is in the $PATH then ethereal should install fine.
  # Some modifications to $LD_LIBRARY_PATH (or non Solaris equivalent)
  # may be required by the user.  Should there be a warning here?
  gtk_major_installed=`echo $gtk_installed | cut -f1 -d.`
  gtk_minor_installed=`echo $gtk_installed | cut -f2 -d.`
else
  gtk_major_installed="0"
  gtk_minor_installed="0"
fi

#
if [ ${platform} != ${expected_platform} ]; then
  echo "\n\n\n\tThis package must be installed on a ${expected_platform} architecture\n"
  echo "\tAborting installation.\n\n\n"
  exit 1
fi
# if [ ${release} != ${expected_release} ]; then
#     echo "\n\n\n\tThis package must be installed on a ${expected_release} machine\n"
#     echo "\tAborting installation.\n\n\n"
#     exit 1
# fi

if [ "$gtk_major_installed" -lt "$gtk_major_needed" -a \
     "$gtk_minor_installed" -lt "$gtk_minor_needed" ] ; then
  echo "\n\n\n\tThis package requires gtk+ version >= $gtk_major_needed.$gtk_minor_needed installed in `dirname ${GTK_CONFIG}`."
  echo "\tAborting installation.\n\n\n"
  exit 1
fi

exit 0
