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