#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/autoconf/timezone                    */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Wed Aug  9 13:27:23 1995                          */
#*    Last change :  Mon Apr  5 13:23:29 2004 (serrano)                */
#*    -------------------------------------------------------------    */
#*    Check which of timezone or _timezone is available                */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    flags                                                            */
#*---------------------------------------------------------------------*/
cc=gcc
cflags=
tmp=/tmp
user=bigloo

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

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

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

    --cflags=*|-cflags=*)
      cflags="`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

#*---------------------------------------------------------------------*/
#*    compile                                                          */
#*---------------------------------------------------------------------*/
compile="$cc $cflags $file.c -o $aout >/dev/null 2> /dev/null"

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

#*---------------------------------------------------------------------*/
#*    Test1                                                            */
#*---------------------------------------------------------------------*/
cat > $file.c <<EOF
#include <time.h>
main( int argc, char *argv[] ) {
   printf( "%d\n", -_timezone );
   return 0;
}
EOF

if eval $compile; then
   \rm -f $file.*
   if eval $aout > /dev/null; then
      rm -f $aout
      echo "_timezone";
      exit 0;
   fi
fi

#*---------------------------------------------------------------------*/
#*    Test2                                                            */
#*---------------------------------------------------------------------*/
cat > $file.c <<EOF
#include <time.h>
main( int argc, char *argv[] ) {
   printf( "%d\n", -timezone );
   return 0;
}
EOF

if eval $compile; then
   \rm -f $file.*
   if eval $aout > /dev/null; then
      rm -f $aout
      echo "timezone";
      exit 0;
   fi
fi

#*---------------------------------------------------------------------*/
#*    default                                                          */
#*---------------------------------------------------------------------*/
\rm -f $file.*

echo "0"
exit 0;
