#!/bin/sh

do_debug=

for option
do
  case "$option" in
  -d | --debug)
    do_debug="yes" ;;
  -help | --help | --hel | --he)
echo "\
Usage: configure [-d | --debug]
  -d or --debug           save debug info in config.log
  --help                  print this message
" >&1
    exit 0 ;;
  esac
done

trap 'rm -fr conftest* confdefs* core core.* *.core; exit 1' 1 2 15

exec 6>&1

if test -n "$do_debug"; then
  exec 5>./config.log
else
  exec 5>/dev/null
fi

echo "\
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
" 1>&5

rm -rf conftest* confdefs.h

ac_unique_file=osf.osc.mk

ac_prog=$0
ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
srcdir=$ac_confdir
if test ! -r $srcdir/$ac_unique_file; then
  srcdir=..
fi

if test ! -r $srcdir/$ac_unique_file; then
  if test "$ac_srcdir_defaulted" = yes; then
    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
  else
    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
  fi
fi
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`

ac_ext=c
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
    ac_n= ac_c='
' ac_t='	'
  else
    ac_n=-n ac_c= ac_t=
  fi
else
  ac_n= ac_c='\c' ac_t=
fi

# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:49: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
  echo $ac_n "(cached) $ac_c" 1>&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  for ac_dir in $PATH; do
    test -z "$ac_dir" && ac_dir=.
    if test -f $ac_dir/$ac_word; then
      ac_cv_prog_CC="gcc"
      break
    fi
  done
  IFS="$ac_save_ifs"
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
  echo "$ac_t""$CC" 1>&6
else
  echo "$ac_t""no" 1>&6
fi

if test -z "$CC"; then
  # Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:78: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
  echo $ac_n "(cached) $ac_c" 1>&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  ac_prog_rejected=no
  for ac_dir in $PATH; do
    test -z "$ac_dir" && ac_dir=.
    if test -f $ac_dir/$ac_word; then
      if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
	continue
      fi
      ac_cv_prog_CC="cc"
      break
    fi
  done
  IFS="$ac_save_ifs"
if test $ac_prog_rejected = yes; then
  # We found a bogon in the path, so make sure we never use it.
  set dummy $ac_cv_prog_CC
  shift
  if test $# -gt 0; then
    shift
    set dummy "$ac_dir/$ac_word" "$@"
    shift
    ac_cv_prog_CC="$@"
  fi
fi
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
  echo "$ac_t""$CC" 1>&6
else
  echo "$ac_t""no" 1>&6
fi

  test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi

echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:123: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5

CFLAGS=-MD
ac_ext=c
ac_compile='${CC-cc} -c $CFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest $CFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross

cat > conftest.$ac_ext <<EOF
#line 132 "configure"
main(){return(0);}
EOF
if { (eval echo configure:135: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
  ac_cv_prog_cc_works=yes
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  ac_cv_prog_cc_works=no
fi
rm -fr conftest*

echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
  { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi

extra_dep_file=osf.extra.mk
echo "\
# This file is created by a script at MACH build time.
# Do not edit this file.
" 1>$srcdir/$extra_dep_file
echo $ac_n __GCC_BUILTIN_INCLUDE_PATH__=-I >>$srcdir/$extra_dep_file

path_to_builtin=

echo $ac_n "searching for gcc's builtin include""... $ac_c" 1>&6

cat > conftest.$ac_ext <<EOF
#line 161 "configure"
#include <stdarg.h>
main(){return(0);}
EOF
if { (eval echo configure:165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
  if (grep stdarg ./conftest.d | awk -F / '{NF--; ORS=""; for (num=2; num < NF; num++) print "/"$num; ORS="\n"; print "/"$NF}' > conftest.tmp) 2>/dev/null; then
    path_to_builtin="yes"
    cat conftest.tmp >>$srcdir/$extra_dep_file
  else
    echo "configure: failed to parse conftest.d:" >&5
    cat conftest.d >&5
  fi
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
fi

if test -n "$path_to_builtin"; then
  cat conftest.tmp 1>&6
else
  echo "$ac_t""not found" 1>&6
fi

rm -fr conftest*

