#!/bin/sh

# $Id: getTIFFDirs,v 1.9 2007/09/12 08:40:37 svein Exp $

# Determine the TIFF directory parameters

tiff_install="n"
makefile=$XITE_HOME/etc/Makefile.$XITE_HOSTTYPE

if [ -f $makefile ]
then
  tiff_inc_def=`egrep '^ *TIFF_INC_DIR *= *' $makefile | awk '{print $3}'`
  tiff_lib_def=`egrep '^ *TIFF_LIB_DIR *= *' $makefile | awk '{print $3}'`
  if [ -n "$tiff_inc_def" -a -n "$tiff_lib_def" ]; then
    tiff_install="y"
  fi
fi

if test "$tiff_install" = "n" -a \( -z "$TIFF_INC_DIR" -o -z "$TIFF_LIB_DIR" \)
then

cat <<EOF 1>&2

This software provides converters between the XITE image file
format and the TIFF file format.

If the TIFF library "libtiff" by Sam Leffler is already installed on your
platform, you may want these converters installed also.

Note: You need an ANSI compiler (e. g. GNU gcc) for these converters.

EOF
  echo "If you want the TIFF converters, you will need to specify where" 1>&2
  echo "the TIFF library and TIFF include files are located." 1>&2
  $echoNl "Would you like to install the converters between TIFF and " 1>&2
  $echoNl "XITE? ([y]/n) " 1>&2

  read tiff_install

  if test -z "$tiff_install" -o "$tiff_install" = "yes" \
	  -o "$tiff_install" = "y"
  then
    tiff_install="y"
  else
    tiff_install="n"
  fi

  if test "$tiff_install" = "y"
  then
    tiff_inc_def=/usr/include

    if test "$XITE_HOSTTYPE" = "Linux_x86_64"
    then
        tiff_lib_def=/usr/lib64
    else
        tiff_lib_def=/usr/lib
    fi
  fi
elif test "$TIFF_INC_DIR" = "-" -o "$TIFF_LIB_DIR" = "-"
then
  tiff_install="n"
  tiff_inc_def=""
  tiff_lib_def=""
else
  tiff_install="y"
fi

check=1
[ "$XITE_HOSTTYPE" = "Win32" ] && check=0

if test "$tiff_install" = "y"
then
  TIFF_INC_DIR=`$getDir "$TIFF_INC_DIR" "$tiff_inc_def" 'TIFF include directory' "$TMP_INSTALL" "stderr" $check`

  TIFF_LIB_DIR=`$getDir "$TIFF_LIB_DIR" "$tiff_lib_def" 'TIFF library directory' "$TMP_INSTALL" "stderr" $check`
else
  TIFF_INC_DIR="-"
  TIFF_LIB_DIR="-"
  exceptionDirs="$exceptionDirs tiff"
fi

echo "TIFF_INC_DIR=$TIFF_INC_DIR; TIFF_LIB_DIR=$TIFF_LIB_DIR"
echo "tiff_install=$tiff_install; exceptionDirs='$exceptionDirs'"
echo "export TIFF_INC_DIR TIFF_LIB_DIR tiff_install exceptionDirs"
