Blame m4/lib-ld.m4

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