Blame gnulib/m4/lib-ld.m4

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