Blame m4/lib-ld.m4

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