Blame m4/lib-ld.m4

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