#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/config/autoconf/stackdown            */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Wed Aug  9 13:27:23 1995                          */
#*    Last change :  Wed Aug  9 13:56:25 1995 (serrano)                */
#*    -------------------------------------------------------------    */
#*    Give the ptr size on the current architecture                    */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    flags                                                            */
#*---------------------------------------------------------------------*/
cc=gcc
cflags=
file=/tmp/actest
aout=/tmp/actest

#*---------------------------------------------------------------------*/
#*    We parse the arguments                                           */
#*---------------------------------------------------------------------*/
while : ; do
  case $1 in
    "")
      break;;
    --cc=*|-cc=*)
      cc="`echo $1 | sed 's/^[-a-z]*=//'`";;

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

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

#*---------------------------------------------------------------------*/
#*    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

#*---------------------------------------------------------------------*/
#*    Test                                                             */
#*---------------------------------------------------------------------*/
cat > $file.c <<EOF
main( argc, argv )
int   argc;
char *argv[];
{
   direction( 1 );
}

direction( new_addr )
int new_addr;
{
   static int *old_addr;
   static int flag = 0;

   if( !flag )
   {
      old_addr = &new_addr;
      flag = 1;
      direction( 2 );
   }
   else
   {
      old_addr > &new_addr ? puts( "1" ) : puts( "0" );
   }
}
EOF

#*---------------------------------------------------------------------*/
#*    Compilation test                                                 */
#*---------------------------------------------------------------------*/
if eval $compile; then
   \rm -f $file.*
   eval $aout
else
   \rm -f $file.*
   exit $?
fi

rm -f $aout
