Blame gnulib/m4/lib-ld.m4

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