#!/bin/sh

#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*            Xavier Leroy, projet Cristal, INRIA Rocquencourt            *
#*                                                                        *
#*   Copyright 1995 Institut National de Recherche en Informatique et     *
#*     en Automatique.                                                    *
#*                                                                        *
#*   All rights reserved.  This file is distributed under the terms of    *
#*   the GNU Lesser General Public License version 2.1, with the          *
#*   special exception on linking described in the file LICENSE.          *
#*                                                                        *
#**************************************************************************

opts=""
libs="$cclibs"
args=$*
rm -f hasgot.c
var="x"
while : ; do
  case "$1" in
    -i) echo "#include <$2>" >> hasgot.c; shift;;
    -t) echo "$2 $var;" >> hasgot.c; var="x$var"; shift;;
    -Xl) libs="$libs $2"; shift;;
    -l*|-L*|-F*) libs="$libs $1";;
    -framework) libs="$libs $1 $2"; shift;;
    -*) opts="$opts $1";;
     *) break;;
  esac
  shift
done

(echo "int main() {"
 for f in $*; do echo "  $f();"; done
 echo "  return 0; }") >> hasgot.c

cmd="$cc $cflags $opts -o tst hasgot.c $ldflags $libs"

if $verbose; then
  echo "hasgot $args: $cmd" >&2
  exec $cmd > /dev/null
else
  exec $cmd > /dev/null 2>/dev/null
fi
