Blame build/autotools/lib-ld.m4

Packit 1069cd
# lib-ld.m4 serial 4 (gettext-0.18)
Packit 1069cd
dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc.
Packit 1069cd
dnl This file is free software; the Free Software Foundation
Packit 1069cd
dnl gives unlimited permission to copy and/or distribute it,
Packit 1069cd
dnl with or without modifications, as long as this notice is preserved.
Packit 1069cd
Packit 1069cd
dnl Subroutines of libtool.m4,
Packit 1069cd
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
Packit 1069cd
dnl with libtool.m4.
Packit 1069cd
Packit 1069cd
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
Packit 1069cd
AC_DEFUN([AC_LIB_PROG_LD_GNU],
Packit 1069cd
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
Packit 1069cd
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
Packit 1069cd
case `$LD -v 2>&1 
Packit 1069cd
*GNU* | *'with BFD'*)
Packit 1069cd
  acl_cv_prog_gnu_ld=yes ;;
Packit 1069cd
*)
Packit 1069cd
  acl_cv_prog_gnu_ld=no ;;
Packit 1069cd
esac])
Packit 1069cd
with_gnu_ld=$acl_cv_prog_gnu_ld
Packit 1069cd
])
Packit 1069cd
Packit 1069cd
dnl From libtool-1.4. Sets the variable LD.
Packit 1069cd
AC_DEFUN([AC_LIB_PROG_LD],
Packit 1069cd
[AC_ARG_WITH([gnu-ld],
Packit 1069cd
[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
Packit 1069cd
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
Packit 1069cd
AC_REQUIRE([AC_PROG_CC])dnl
Packit 1069cd
AC_REQUIRE([AC_CANONICAL_HOST])dnl
Packit 1069cd
# Prepare PATH_SEPARATOR.
Packit 1069cd
# The user is always right.
Packit 1069cd
if test "${PATH_SEPARATOR+set}" != set; then
Packit 1069cd
  echo "#! /bin/sh" >conf$$.sh
Packit 1069cd
  echo  "exit 0"   >>conf$$.sh
Packit 1069cd
  chmod +x conf$$.sh
Packit 1069cd
  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
Packit 1069cd
    PATH_SEPARATOR=';'
Packit 1069cd
  else
Packit 1069cd
    PATH_SEPARATOR=:
Packit 1069cd
  fi
Packit 1069cd
  rm -f conf$$.sh
Packit 1069cd
fi
Packit 1069cd
ac_prog=ld
Packit 1069cd
if test "$GCC" = yes; then
Packit 1069cd
  # Check if gcc -print-prog-name=ld gives a path.
Packit 1069cd
  AC_MSG_CHECKING([for ld used by GCC])
Packit 1069cd
  case $host in
Packit 1069cd
  *-*-mingw*)
Packit 1069cd
    # gcc leaves a trailing carriage return which upsets mingw
Packit 1069cd
    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
Packit 1069cd
  *)
Packit 1069cd
    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
Packit 1069cd
  esac
Packit 1069cd
  case $ac_prog in
Packit 1069cd
    # Accept absolute paths.
Packit 1069cd
    [[\\/]* | [A-Za-z]:[\\/]*)]
Packit 1069cd
      [re_direlt='/[^/][^/]*/\.\./']
Packit 1069cd
      # Canonicalize the path of ld
Packit 1069cd
      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
Packit 1069cd
      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
Packit 1069cd
        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
Packit 1069cd
      done
Packit 1069cd
      test -z "$LD" && LD="$ac_prog"
Packit 1069cd
      ;;
Packit 1069cd
  "")
Packit 1069cd
    # If it fails, then pretend we aren't using GCC.
Packit 1069cd
    ac_prog=ld
Packit 1069cd
    ;;
Packit 1069cd
  *)
Packit 1069cd
    # If it is relative, then search for the first ld in PATH.
Packit 1069cd
    with_gnu_ld=unknown
Packit 1069cd
    ;;
Packit 1069cd
  esac
Packit 1069cd
elif test "$with_gnu_ld" = yes; then
Packit 1069cd
  AC_MSG_CHECKING([for GNU ld])
Packit 1069cd
else
Packit 1069cd
  AC_MSG_CHECKING([for non-GNU ld])
Packit 1069cd
fi
Packit 1069cd
AC_CACHE_VAL([acl_cv_path_LD],
Packit 1069cd
[if test -z "$LD"; then
Packit 1069cd
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
Packit 1069cd
  for ac_dir in $PATH; do
Packit 1069cd
    test -z "$ac_dir" && ac_dir=.
Packit 1069cd
    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
Packit 1069cd
      acl_cv_path_LD="$ac_dir/$ac_prog"
Packit 1069cd
      # Check to see if the program is GNU ld.  I'd rather use --version,
Packit 1069cd
      # but apparently some GNU ld's only accept -v.
Packit 1069cd
      # Break only if it was the GNU/non-GNU ld that we prefer.
Packit 1069cd
      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
Packit 1069cd
      *GNU* | *'with BFD'*)
Packit 1069cd
        test "$with_gnu_ld" != no && break ;;
Packit 1069cd
      *)
Packit 1069cd
        test "$with_gnu_ld" != yes && break ;;
Packit 1069cd
      esac
Packit 1069cd
    fi
Packit 1069cd
  done
Packit 1069cd
  IFS="$ac_save_ifs"
Packit 1069cd
else
Packit 1069cd
  acl_cv_path_LD="$LD" # Let the user override the test with a path.
Packit 1069cd
fi])
Packit 1069cd
LD="$acl_cv_path_LD"
Packit 1069cd
if test -n "$LD"; then
Packit 1069cd
  AC_MSG_RESULT([$LD])
Packit 1069cd
else
Packit 1069cd
  AC_MSG_RESULT([no])
Packit 1069cd
fi
Packit 1069cd
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
Packit 1069cd
AC_LIB_PROG_LD_GNU
Packit 1069cd
])