175584Sru# lib-ld.m4 serial 3 (gettext-0.13)
275584Srudnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
375584Srudnl This file is free software; the Free Software Foundation
4104862Srudnl gives unlimited permission to copy and/or distribute it,
575584Srudnl with or without modifications, as long as this notice is preserved.
675584Sru
775584Srudnl Subroutines of libtool.m4,
875584Srudnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
975584Srudnl with libtool.m4.
1075584Sru
1175584Srudnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
1275584SruAC_DEFUN([AC_LIB_PROG_LD_GNU],
1375584Sru[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
1475584Sru[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
1575584Srucase `$LD -v 2>&1 </dev/null` in
1675584Sru*GNU* | *'with BFD'*)
1775584Sru  acl_cv_prog_gnu_ld=yes ;;
1875584Sru*)
1975584Sru  acl_cv_prog_gnu_ld=no ;;
2075584Sruesac])
2175584Sruwith_gnu_ld=$acl_cv_prog_gnu_ld
22104862Sru])
2375584Sru
2475584Srudnl From libtool-1.4. Sets the variable LD.
2575584SruAC_DEFUN([AC_LIB_PROG_LD],
2675584Sru[AC_ARG_WITH(gnu-ld,
2775584Sru[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
2875584Srutest "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
2975584SruAC_REQUIRE([AC_PROG_CC])dnl
3075584SruAC_REQUIRE([AC_CANONICAL_HOST])dnl
3175584Sru# Prepare PATH_SEPARATOR.
3275584Sru# The user is always right.
3375584Sruif test "${PATH_SEPARATOR+set}" != set; then
3475584Sru  echo "#! /bin/sh" >conf$$.sh
3575584Sru  echo  "exit 0"   >>conf$$.sh
3675584Sru  chmod +x conf$$.sh
3775584Sru  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
3875584Sru    PATH_SEPARATOR=';'
3975584Sru  else
4075584Sru    PATH_SEPARATOR=:
4175584Sru  fi
4275584Sru  rm -f conf$$.sh
4375584Srufi
4475584Sruac_prog=ld
4575584Sruif test "$GCC" = yes; then
4675584Sru  # Check if gcc -print-prog-name=ld gives a path.
4775584Sru  AC_MSG_CHECKING([for ld used by GCC])
4875584Sru  case $host in
4975584Sru  *-*-mingw*)
5075584Sru    # gcc leaves a trailing carriage return which upsets mingw
5175584Sru    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
5275584Sru  *)
5375584Sru    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
5475584Sru  esac
5575584Sru  case $ac_prog in
5675584Sru    # Accept absolute paths.
5775584Sru    [[\\/]* | [A-Za-z]:[\\/]*)]
5875584Sru      [re_direlt='/[^/][^/]*/\.\./']
5975584Sru      # Canonicalize the path of ld
6075584Sru      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
6175584Sru      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
6275584Sru	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
6375584Sru      done
6475584Sru      test -z "$LD" && LD="$ac_prog"
6575584Sru      ;;
6675584Sru  "")
6775584Sru    # If it fails, then pretend we aren't using GCC.
6875584Sru    ac_prog=ld
6975584Sru    ;;
7075584Sru  *)
7175584Sru    # If it is relative, then search for the first ld in PATH.
7275584Sru    with_gnu_ld=unknown
7375584Sru    ;;
7475584Sru  esac
7575584Sruelif test "$with_gnu_ld" = yes; then
7675584Sru  AC_MSG_CHECKING([for GNU ld])
7775584Sruelse
7875584Sru  AC_MSG_CHECKING([for non-GNU ld])
7975584Srufi
80104862SruAC_CACHE_VAL(acl_cv_path_LD,
8175584Sru[if test -z "$LD"; then
8275584Sru  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
8375584Sru  for ac_dir in $PATH; do
8475584Sru    test -z "$ac_dir" && ac_dir=.
8575584Sru    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
8675584Sru      acl_cv_path_LD="$ac_dir/$ac_prog"
8775584Sru      # Check to see if the program is GNU ld.  I'd rather use --version,
8875584Sru      # but apparently some GNU ld's only accept -v.
8975584Sru      # Break only if it was the GNU/non-GNU ld that we prefer.
9075584Sru      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
9175584Sru      *GNU* | *'with BFD'*)
9275584Sru	test "$with_gnu_ld" != no && break ;;
9375584Sru      *)
9475584Sru	test "$with_gnu_ld" != yes && break ;;
9575584Sru      esac
9675584Sru    fi
9775584Sru  done
9875584Sru  IFS="$ac_save_ifs"
9975584Sruelse
10075584Sru  acl_cv_path_LD="$LD" # Let the user override the test with a path.
10175584Srufi])
10275584SruLD="$acl_cv_path_LD"
10375584Sruif test -n "$LD"; then
10475584Sru  AC_MSG_RESULT($LD)
10575584Sruelse
10675584Sru  AC_MSG_RESULT(no)
10775584Srufi
10875584Srutest -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
10975584SruAC_LIB_PROG_LD_GNU
11075584Sru])
11175584Sru