#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/autoconf/strip                       */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Wed Aug  9 14:04:49 1995                          */
#*    Last change :  Wed Jan 15 14:24:24 2003 (serrano)                */
#*    -------------------------------------------------------------    */
#*    Checking for strip                                               */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    flags                                                            */
#*---------------------------------------------------------------------*/
cc=gcc
cflags=
strip=strip
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]*=//'`";;

    --strip=*)
      strip="`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
err=$tmp/Xactest$user.err
obj=`basename $file`

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

cd $tmp

#*---------------------------------------------------------------------*/
#*    Test                                                             */
#*---------------------------------------------------------------------*/
cat > $file.c <<EOF
int main () { ; }
EOF

#*---------------------------------------------------------------------*/
#*    Compilation test                                                 */
#*---------------------------------------------------------------------*/
if $cc $cflags -c $file.c -o $aout >/dev/null 2> $err; then
   if [ "`cat $err` " = " " ]; then
      /bin/rm $err
      true;
   else
      /bin/rm $err
      exit 1
   fi
else
   exit $?
fi

#*---------------------------------------------------------------------*/
#*    We test strip                                                    */
#*---------------------------------------------------------------------*/
eval "strip $aout > /dev/null 2> /dev/null" >/dev/null 2> /dev/null || exit $?

exit 0
