#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/autoconf/installinfodir              */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Thu Jan 14 15:12:37 1999                          */
#*    Last change :  Tue Aug  6 10:07:36 2002 (serrano)                */
#*    -------------------------------------------------------------    */
#*    Check if info is an old version                                  */
#*=====================================================================*/

installinfo=install-info
cc=gcc
path=
tmp=/tmp
user=bigloo

#*---------------------------------------------------------------------*/
#*    We parse the arguments                                           */
#*---------------------------------------------------------------------*/
while : ; do
  case $1 in
    "")
      break;;

    --user=*)
      user="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --installinfo=*|-installinfo=*)
      installinfo="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --cc=*|-cc=*)
      cc="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --exe=*)
      exe="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --tmp=*|-tmp=*)
      tmp="`echo $1 | sed 's/^[-a-z]*=//'`";;

    -*)
      echo "Unknown option \"$1\", ignored" >&2;;
  esac
  shift
done

file=$tmp/actest$user
aout=$tmp/Xactest$user

#*---------------------------------------------------------------------*/
#*    The test C file                                                  */
#*---------------------------------------------------------------------*/
if [ -f $file.c ]; then
   rm -f $file.c || exit $?
fi

#*---------------------------------------------------------------------*/
#*    Test                                                             */
#*---------------------------------------------------------------------*/
cat > $file.c <<EOF
main( argc, argv )
int   argc;
char *argv[];
{
   printf( "%s", argv[ 1 ] );
   return 0;
}
EOF

$cc $cflags $file.c -o $aout >/dev/null 2> /dev/null

if [ "`$installinfo --help 2>&1 | grep 'dir-file=DIR' 2> /dev/null`" != "" ]; then
    $aout$exe "--dir-file"
else 
  if [ "`$installinfo --help 2>&1 | grep 'dirfile=xxx' 2> /dev/null`" != "" ]; then
    $aout$exe "--dirfile"
  else
     $aout$exe ""
  fi
fi

/bin/rm -rf $file.c $file.o $aout$exe $aout
