Blame m4/lib-ld.m4

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