# Which Executable Linker ?
#
_ld_list='LD LDFLAGS LIBS runpathprexix LDneedWl LDused GNULDused'
case "$osname" in
  darwin) LIBS= ;;
  osf1)   LIBS='-lm -lots';;
  *)      LIBS=-lm;;
esac

if test -z "$LD"; then LD=$CC; fi

if test "$fastread" != yes; then
  echo $n ..."Which linker for building executables ? $c"
  dflt=$LD; rep=; . ./myread
  LD=$ans
fi
LDused=$LD

# Which Flags for Executable Linker?
ldflags=
if test "$LD"="$CC"; then
  ldflags=$CFLAGS
  GNULDused=
  if test -n "$__gnuc__"; then
    LDused=`$CC -print-prog-name=ld`
    LDneedsWl=yes
  else
    if test "$osname"=hpux; then LDneedsWl=yes; fi
  fi
fi
if ($LDused -v 2>&1 | grep GNU > /dev/null); then GNULDused=yes; fi

case "$osname-$arch" in
  linux-*|cygwin*|freebsd-*)
    tmp=`./ldflags "$LDneedsWl" "-export-dynamic"`
    ldflags="$ldflags $tmp" ;;
  aix-*)  ldflags='-brtl' ;; # in case we link against a shared library
  os2-*)  ldflags="$ldflags -Zexe"
          case "$optimization" in
            full) ldflags="$ldflags -s";;
          esac;;
esac
LDFLAGS="$ldflags $LDFLAGS"

if test "$fastread" != yes; then
  echo $n ..."With which flags ? $c"
  dflt=$LDFLAGS; rep=; . ./myread
  LDFLAGS=$ans
fi

echo "Executable linker is   $LD  $LDFLAGS"

case "$osname" in
  osf1|linux|cygwin*|freebsd) runpathprefix='-rpath ' ;;
  solaris) runpathprefix='-R ' ;;
  hpux) runpathprefix='+b ' ;;
  aix) runpathprefix='-blibpath:' ;;
esac
