Blame m4/lib-ld.m4

rpm-build 0a0c83
# lib-ld.m4 serial 6
rpm-build 0a0c83
dnl Copyright (C) 1996-2003, 2009-2013 Free Software Foundation, Inc.
rpm-build 0a0c83
dnl This file is free software; the Free Software Foundation
rpm-build 0a0c83
dnl gives unlimited permission to copy and/or distribute it,
rpm-build 0a0c83
dnl with or without modifications, as long as this notice is preserved.
rpm-build 0a0c83
rpm-build 0a0c83
dnl Subroutines of libtool.m4,
rpm-build 0a0c83
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
rpm-build 0a0c83
dnl collision with libtool.m4.
rpm-build 0a0c83
rpm-build 0a0c83
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
rpm-build 0a0c83
AC_DEFUN([AC_LIB_PROG_LD_GNU],
rpm-build 0a0c83
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
rpm-build 0a0c83
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
rpm-build 0a0c83
case `$LD -v 2>&1 
rpm-build 0a0c83
*GNU* | *'with BFD'*)
rpm-build 0a0c83
  acl_cv_prog_gnu_ld=yes
rpm-build 0a0c83
  ;;
rpm-build 0a0c83
*)
rpm-build 0a0c83
  acl_cv_prog_gnu_ld=no
rpm-build 0a0c83
  ;;
rpm-build 0a0c83
esac])
rpm-build 0a0c83
with_gnu_ld=$acl_cv_prog_gnu_ld
rpm-build 0a0c83
])
rpm-build 0a0c83
rpm-build 0a0c83
dnl From libtool-2.4. Sets the variable LD.
rpm-build 0a0c83
AC_DEFUN([AC_LIB_PROG_LD],
rpm-build 0a0c83
[AC_REQUIRE([AC_PROG_CC])dnl
rpm-build 0a0c83
AC_REQUIRE([AC_CANONICAL_HOST])dnl
rpm-build 0a0c83
rpm-build 0a0c83
AC_ARG_WITH([gnu-ld],
rpm-build 0a0c83
    [AS_HELP_STRING([--with-gnu-ld],
rpm-build 0a0c83
        [assume the C compiler uses GNU ld [default=no]])],
rpm-build 0a0c83
    [test "$withval" = no || with_gnu_ld=yes],
rpm-build 0a0c83
    [with_gnu_ld=no])dnl
rpm-build 0a0c83
rpm-build 0a0c83
# Prepare PATH_SEPARATOR.
rpm-build 0a0c83
# The user is always right.
rpm-build 0a0c83
if test "${PATH_SEPARATOR+set}" != set; then
rpm-build 0a0c83
  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
rpm-build 0a0c83
  # contains only /bin. Note that ksh looks also at the FPATH variable,
rpm-build 0a0c83
  # so we have to set that as well for the test.
rpm-build 0a0c83
  PATH_SEPARATOR=:
rpm-build 0a0c83
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
rpm-build 0a0c83
    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
rpm-build 0a0c83
           || PATH_SEPARATOR=';'
rpm-build 0a0c83
       }
rpm-build 0a0c83
fi
rpm-build 0a0c83
rpm-build 0a0c83
ac_prog=ld
rpm-build 0a0c83
if test "$GCC" = yes; then
rpm-build 0a0c83
  # Check if gcc -print-prog-name=ld gives a path.
rpm-build 0a0c83
  AC_MSG_CHECKING([for ld used by $CC])
rpm-build 0a0c83
  case $host in
rpm-build 0a0c83
  *-*-mingw*)
rpm-build 0a0c83
    # gcc leaves a trailing carriage return which upsets mingw
rpm-build 0a0c83
    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
rpm-build 0a0c83
  *)
rpm-build 0a0c83
    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
rpm-build 0a0c83
  esac
rpm-build 0a0c83
  case $ac_prog in
rpm-build 0a0c83
    # Accept absolute paths.
rpm-build 0a0c83
    [[\\/]]* | ?:[[\\/]]*)
rpm-build 0a0c83
      re_direlt='/[[^/]][[^/]]*/\.\./'
rpm-build 0a0c83
      # Canonicalize the pathname of ld
rpm-build 0a0c83
      ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
rpm-build 0a0c83
      while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
rpm-build 0a0c83
        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
rpm-build 0a0c83
      done
rpm-build 0a0c83
      test -z "$LD" && LD="$ac_prog"
rpm-build 0a0c83
      ;;
rpm-build 0a0c83
  "")
rpm-build 0a0c83
    # If it fails, then pretend we aren't using GCC.
rpm-build 0a0c83
    ac_prog=ld
rpm-build 0a0c83
    ;;
rpm-build 0a0c83
  *)
rpm-build 0a0c83
    # If it is relative, then search for the first ld in PATH.
rpm-build 0a0c83
    with_gnu_ld=unknown
rpm-build 0a0c83
    ;;
rpm-build 0a0c83
  esac
rpm-build 0a0c83
elif test "$with_gnu_ld" = yes; then
rpm-build 0a0c83
  AC_MSG_CHECKING([for GNU ld])
rpm-build 0a0c83
else
rpm-build 0a0c83
  AC_MSG_CHECKING([for non-GNU ld])
rpm-build 0a0c83
fi
rpm-build 0a0c83
AC_CACHE_VAL([acl_cv_path_LD],
rpm-build 0a0c83
[if test -z "$LD"; then
rpm-build 0a0c83
  acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
rpm-build 0a0c83
  for ac_dir in $PATH; do
rpm-build 0a0c83
    IFS="$acl_save_ifs"
rpm-build 0a0c83
    test -z "$ac_dir" && ac_dir=.
rpm-build 0a0c83
    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
rpm-build 0a0c83
      acl_cv_path_LD="$ac_dir/$ac_prog"
rpm-build 0a0c83
      # Check to see if the program is GNU ld.  I'd rather use --version,
rpm-build 0a0c83
      # but apparently some variants of GNU ld only accept -v.
rpm-build 0a0c83
      # Break only if it was the GNU/non-GNU ld that we prefer.
rpm-build 0a0c83
      case `"$acl_cv_path_LD" -v 2>&1 
rpm-build 0a0c83
      *GNU* | *'with BFD'*)
rpm-build 0a0c83
        test "$with_gnu_ld" != no && break
rpm-build 0a0c83
        ;;
rpm-build 0a0c83
      *)
rpm-build 0a0c83
        test "$with_gnu_ld" != yes && break
rpm-build 0a0c83
        ;;
rpm-build 0a0c83
      esac
rpm-build 0a0c83
    fi
rpm-build 0a0c83
  done
rpm-build 0a0c83
  IFS="$acl_save_ifs"
rpm-build 0a0c83
else
rpm-build 0a0c83
  acl_cv_path_LD="$LD" # Let the user override the test with a path.
rpm-build 0a0c83
fi])
rpm-build 0a0c83
LD="$acl_cv_path_LD"
rpm-build 0a0c83
if test -n "$LD"; then
rpm-build 0a0c83
  AC_MSG_RESULT([$LD])
rpm-build 0a0c83
else
rpm-build 0a0c83
  AC_MSG_RESULT([no])
rpm-build 0a0c83
fi
rpm-build 0a0c83
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
rpm-build 0a0c83
AC_LIB_PROG_LD_GNU
rpm-build 0a0c83
])