#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/autoconf/gmtoff                      */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Wed Aug  9 13:27:23 1995                          */
#*    Last change :  Fri Apr 11 07:36:17 2014 (serrano)                */
#*    -------------------------------------------------------------    */
#*    Check which of timezone or _timezone is available                */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    flags                                                            */
#*---------------------------------------------------------------------*/
cflags=

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

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

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

#*---------------------------------------------------------------------*/
#*    Test1                                                            */
#*---------------------------------------------------------------------*/
cat > $file.c <<EOF
#include <time.h>
#include <ctype.h>
#include <sys/time.h>

int main( int argc, char *argv[] ) {
   long s = time( 0 );
   struct tm *tm = localtime( &s );
   
   return tm->tm_gmtoff - tm->tm_gmtoff;
}
EOF

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

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

echo "0"
exit 0;
