2022-01-21 05:29:34 +08:00
|
|
|
# lib-ld.m4 serial 9
|
|
|
|
dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc.
|
2007-07-20 22:04:50 +08:00
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
2003-03-26 07:11:35 +08:00
|
|
|
|
|
|
|
dnl Subroutines of libtool.m4,
|
2013-06-01 01:30:21 +08:00
|
|
|
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
|
|
|
|
dnl collision with libtool.m4.
|
2003-03-26 07:11:35 +08:00
|
|
|
|
2013-06-01 01:30:21 +08:00
|
|
|
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
|
2003-03-26 07:11:35 +08:00
|
|
|
AC_DEFUN([AC_LIB_PROG_LD_GNU],
|
2010-07-22 03:58:08 +08:00
|
|
|
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
|
2013-06-01 01:30:21 +08:00
|
|
|
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
|
2007-07-20 22:04:50 +08:00
|
|
|
case `$LD -v 2>&1 </dev/null` in
|
|
|
|
*GNU* | *'with BFD'*)
|
2013-06-01 01:30:21 +08:00
|
|
|
acl_cv_prog_gnu_ld=yes
|
|
|
|
;;
|
2007-07-20 22:04:50 +08:00
|
|
|
*)
|
2013-06-01 01:30:21 +08:00
|
|
|
acl_cv_prog_gnu_ld=no
|
|
|
|
;;
|
2007-07-20 22:04:50 +08:00
|
|
|
esac])
|
2003-03-26 07:11:35 +08:00
|
|
|
with_gnu_ld=$acl_cv_prog_gnu_ld
|
|
|
|
])
|
|
|
|
|
2013-06-01 01:30:21 +08:00
|
|
|
dnl From libtool-2.4. Sets the variable LD.
|
2003-03-26 07:11:35 +08:00
|
|
|
AC_DEFUN([AC_LIB_PROG_LD],
|
2013-06-01 01:30:21 +08:00
|
|
|
[AC_REQUIRE([AC_PROG_CC])dnl
|
2003-03-26 07:11:35 +08:00
|
|
|
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
2013-06-01 01:30:21 +08:00
|
|
|
|
|
|
|
AC_ARG_WITH([gnu-ld],
|
|
|
|
[AS_HELP_STRING([--with-gnu-ld],
|
|
|
|
[assume the C compiler uses GNU ld [default=no]])],
|
|
|
|
[test "$withval" = no || with_gnu_ld=yes],
|
|
|
|
[with_gnu_ld=no])dnl
|
|
|
|
|
2007-07-20 22:04:50 +08:00
|
|
|
# Prepare PATH_SEPARATOR.
|
|
|
|
# The user is always right.
|
|
|
|
if test "${PATH_SEPARATOR+set}" != set; then
|
2013-06-01 01:30:21 +08:00
|
|
|
# Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
|
|
|
|
# contains only /bin. Note that ksh looks also at the FPATH variable,
|
|
|
|
# so we have to set that as well for the test.
|
|
|
|
PATH_SEPARATOR=:
|
|
|
|
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|
|
|
|
&& { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|
|
|
|
|| PATH_SEPARATOR=';'
|
|
|
|
}
|
2007-07-20 22:04:50 +08:00
|
|
|
fi
|
2013-06-01 01:30:21 +08:00
|
|
|
|
2022-01-21 05:29:34 +08:00
|
|
|
if test -n "$LD"; then
|
|
|
|
AC_MSG_CHECKING([for ld])
|
|
|
|
elif test "$GCC" = yes; then
|
2013-06-01 01:30:21 +08:00
|
|
|
AC_MSG_CHECKING([for ld used by $CC])
|
2003-03-26 07:11:35 +08:00
|
|
|
elif test "$with_gnu_ld" = yes; then
|
|
|
|
AC_MSG_CHECKING([for GNU ld])
|
|
|
|
else
|
|
|
|
AC_MSG_CHECKING([for non-GNU ld])
|
|
|
|
fi
|
2022-01-21 05:29:34 +08:00
|
|
|
if test -n "$LD"; then
|
|
|
|
# Let the user override the test with a path.
|
|
|
|
:
|
|
|
|
else
|
|
|
|
AC_CACHE_VAL([acl_cv_path_LD],
|
|
|
|
[
|
|
|
|
acl_cv_path_LD= # Final result of this test
|
|
|
|
ac_prog=ld # Program to search in $PATH
|
|
|
|
if test "$GCC" = yes; then
|
|
|
|
# Check if gcc -print-prog-name=ld gives a path.
|
|
|
|
case $host in
|
|
|
|
*-*-mingw*)
|
|
|
|
# gcc leaves a trailing carriage return which upsets mingw
|
|
|
|
acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
|
|
|
|
*)
|
|
|
|
acl_output=`($CC -print-prog-name=ld) 2>&5` ;;
|
|
|
|
esac
|
|
|
|
case $acl_output in
|
|
|
|
# Accept absolute paths.
|
|
|
|
[[\\/]]* | ?:[[\\/]]*)
|
|
|
|
re_direlt='/[[^/]][[^/]]*/\.\./'
|
|
|
|
# Canonicalize the pathname of ld
|
|
|
|
acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'`
|
|
|
|
while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do
|
|
|
|
acl_output=`echo $acl_output | sed "s%$re_direlt%/%"`
|
|
|
|
done
|
|
|
|
# Got the pathname. No search in PATH is needed.
|
|
|
|
acl_cv_path_LD="$acl_output"
|
|
|
|
ac_prog=
|
|
|
|
;;
|
|
|
|
"")
|
|
|
|
# If it fails, then pretend we aren't using GCC.
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# If it is relative, then search for the first ld in PATH.
|
|
|
|
with_gnu_ld=unknown
|
|
|
|
;;
|
2007-07-20 22:04:50 +08:00
|
|
|
esac
|
2003-03-26 07:11:35 +08:00
|
|
|
fi
|
2022-01-21 05:29:34 +08:00
|
|
|
if test -n "$ac_prog"; then
|
|
|
|
# Search for $ac_prog in $PATH.
|
|
|
|
acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
|
|
|
|
for ac_dir in $PATH; do
|
|
|
|
IFS="$acl_save_ifs"
|
|
|
|
test -z "$ac_dir" && ac_dir=.
|
|
|
|
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
|
|
|
|
acl_cv_path_LD="$ac_dir/$ac_prog"
|
|
|
|
# Check to see if the program is GNU ld. I'd rather use --version,
|
|
|
|
# but apparently some variants of GNU ld only accept -v.
|
|
|
|
# Break only if it was the GNU/non-GNU ld that we prefer.
|
|
|
|
case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
|
|
|
|
*GNU* | *'with BFD'*)
|
|
|
|
test "$with_gnu_ld" != no && break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
test "$with_gnu_ld" != yes && break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="$acl_save_ifs"
|
|
|
|
fi
|
|
|
|
case $host in
|
|
|
|
*-*-aix*)
|
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_SOURCE(
|
|
|
|
[[#if defined __powerpc64__ || defined _ARCH_PPC64
|
|
|
|
int ok;
|
|
|
|
#else
|
|
|
|
error fail
|
|
|
|
#endif
|
|
|
|
]])],
|
|
|
|
[# The compiler produces 64-bit code. Add option '-b64' so that the
|
|
|
|
# linker groks 64-bit object files.
|
|
|
|
case "$acl_cv_path_LD " in
|
|
|
|
*" -b64 "*) ;;
|
|
|
|
*) acl_cv_path_LD="$acl_cv_path_LD -b64" ;;
|
|
|
|
esac
|
|
|
|
], [])
|
|
|
|
;;
|
|
|
|
sparc64-*-netbsd*)
|
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_SOURCE(
|
|
|
|
[[#if defined __sparcv9 || defined __arch64__
|
|
|
|
int ok;
|
|
|
|
#else
|
|
|
|
error fail
|
|
|
|
#endif
|
|
|
|
]])],
|
|
|
|
[],
|
|
|
|
[# The compiler produces 32-bit code. Add option '-m elf32_sparc'
|
|
|
|
# so that the linker groks 32-bit object files.
|
|
|
|
case "$acl_cv_path_LD " in
|
|
|
|
*" -m elf32_sparc "*) ;;
|
|
|
|
*) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;;
|
|
|
|
esac
|
|
|
|
])
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
])
|
|
|
|
LD="$acl_cv_path_LD"
|
|
|
|
fi
|
2003-03-26 07:11:35 +08:00
|
|
|
if test -n "$LD"; then
|
2010-07-22 03:58:08 +08:00
|
|
|
AC_MSG_RESULT([$LD])
|
2003-03-26 07:11:35 +08:00
|
|
|
else
|
2010-07-22 03:58:08 +08:00
|
|
|
AC_MSG_RESULT([no])
|
2022-01-21 05:29:34 +08:00
|
|
|
AC_MSG_ERROR([no acceptable ld found in \$PATH])
|
2003-03-26 07:11:35 +08:00
|
|
|
fi
|
|
|
|
AC_LIB_PROG_LD_GNU
|
|
|
|
])
|