05d292b2 (kx 2023-03-24 03:51:10 +0300 1) # lib-ld.m4 serial 6
05d292b2 (kx 2023-03-24 03:51:10 +0300 2) dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc.
05d292b2 (kx 2023-03-24 03:51:10 +0300 3) dnl This file is free software; the Free Software Foundation
05d292b2 (kx 2023-03-24 03:51:10 +0300 4) dnl gives unlimited permission to copy and/or distribute it,
05d292b2 (kx 2023-03-24 03:51:10 +0300 5) dnl with or without modifications, as long as this notice is preserved.
05d292b2 (kx 2023-03-24 03:51:10 +0300 6)
05d292b2 (kx 2023-03-24 03:51:10 +0300 7) dnl Subroutines of libtool.m4,
05d292b2 (kx 2023-03-24 03:51:10 +0300 8) dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
05d292b2 (kx 2023-03-24 03:51:10 +0300 9) dnl collision with libtool.m4.
05d292b2 (kx 2023-03-24 03:51:10 +0300 10)
05d292b2 (kx 2023-03-24 03:51:10 +0300 11) dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
05d292b2 (kx 2023-03-24 03:51:10 +0300 12) AC_DEFUN([AC_LIB_PROG_LD_GNU],
05d292b2 (kx 2023-03-24 03:51:10 +0300 13) [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
05d292b2 (kx 2023-03-24 03:51:10 +0300 14) [# I'd rather use --version here, but apparently some GNU lds only accept -v.
05d292b2 (kx 2023-03-24 03:51:10 +0300 15) case `$LD -v 2>&1 </dev/null` in
05d292b2 (kx 2023-03-24 03:51:10 +0300 16) *GNU* | *'with BFD'*)
05d292b2 (kx 2023-03-24 03:51:10 +0300 17) acl_cv_prog_gnu_ld=yes
05d292b2 (kx 2023-03-24 03:51:10 +0300 18) ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 19) *)
05d292b2 (kx 2023-03-24 03:51:10 +0300 20) acl_cv_prog_gnu_ld=no
05d292b2 (kx 2023-03-24 03:51:10 +0300 21) ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 22) esac])
05d292b2 (kx 2023-03-24 03:51:10 +0300 23) with_gnu_ld=$acl_cv_prog_gnu_ld
05d292b2 (kx 2023-03-24 03:51:10 +0300 24) ])
05d292b2 (kx 2023-03-24 03:51:10 +0300 25)
05d292b2 (kx 2023-03-24 03:51:10 +0300 26) dnl From libtool-2.4. Sets the variable LD.
05d292b2 (kx 2023-03-24 03:51:10 +0300 27) AC_DEFUN([AC_LIB_PROG_LD],
05d292b2 (kx 2023-03-24 03:51:10 +0300 28) [AC_REQUIRE([AC_PROG_CC])dnl
05d292b2 (kx 2023-03-24 03:51:10 +0300 29) AC_REQUIRE([AC_CANONICAL_HOST])dnl
05d292b2 (kx 2023-03-24 03:51:10 +0300 30)
05d292b2 (kx 2023-03-24 03:51:10 +0300 31) AC_ARG_WITH([gnu-ld],
05d292b2 (kx 2023-03-24 03:51:10 +0300 32) [AS_HELP_STRING([--with-gnu-ld],
05d292b2 (kx 2023-03-24 03:51:10 +0300 33) [assume the C compiler uses GNU ld [default=no]])],
05d292b2 (kx 2023-03-24 03:51:10 +0300 34) [test "$withval" = no || with_gnu_ld=yes],
05d292b2 (kx 2023-03-24 03:51:10 +0300 35) [with_gnu_ld=no])dnl
05d292b2 (kx 2023-03-24 03:51:10 +0300 36)
05d292b2 (kx 2023-03-24 03:51:10 +0300 37) # Prepare PATH_SEPARATOR.
05d292b2 (kx 2023-03-24 03:51:10 +0300 38) # The user is always right.
05d292b2 (kx 2023-03-24 03:51:10 +0300 39) if test "${PATH_SEPARATOR+set}" != set; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 40) # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
05d292b2 (kx 2023-03-24 03:51:10 +0300 41) # contains only /bin. Note that ksh looks also at the FPATH variable,
05d292b2 (kx 2023-03-24 03:51:10 +0300 42) # so we have to set that as well for the test.
05d292b2 (kx 2023-03-24 03:51:10 +0300 43) PATH_SEPARATOR=:
05d292b2 (kx 2023-03-24 03:51:10 +0300 44) (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
05d292b2 (kx 2023-03-24 03:51:10 +0300 45) && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
05d292b2 (kx 2023-03-24 03:51:10 +0300 46) || PATH_SEPARATOR=';'
05d292b2 (kx 2023-03-24 03:51:10 +0300 47) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 48) fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 49)
05d292b2 (kx 2023-03-24 03:51:10 +0300 50) ac_prog=ld
05d292b2 (kx 2023-03-24 03:51:10 +0300 51) if test "$GCC" = yes; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 52) # Check if gcc -print-prog-name=ld gives a path.
05d292b2 (kx 2023-03-24 03:51:10 +0300 53) AC_MSG_CHECKING([for ld used by $CC])
05d292b2 (kx 2023-03-24 03:51:10 +0300 54) case $host in
05d292b2 (kx 2023-03-24 03:51:10 +0300 55) *-*-mingw*)
05d292b2 (kx 2023-03-24 03:51:10 +0300 56) # gcc leaves a trailing carriage return which upsets mingw
05d292b2 (kx 2023-03-24 03:51:10 +0300 57) ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 58) *)
05d292b2 (kx 2023-03-24 03:51:10 +0300 59) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 60) esac
05d292b2 (kx 2023-03-24 03:51:10 +0300 61) case $ac_prog in
05d292b2 (kx 2023-03-24 03:51:10 +0300 62) # Accept absolute paths.
05d292b2 (kx 2023-03-24 03:51:10 +0300 63) [[\\/]]* | ?:[[\\/]]*)
05d292b2 (kx 2023-03-24 03:51:10 +0300 64) re_direlt='/[[^/]][[^/]]*/\.\./'
05d292b2 (kx 2023-03-24 03:51:10 +0300 65) # Canonicalize the pathname of ld
05d292b2 (kx 2023-03-24 03:51:10 +0300 66) ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
05d292b2 (kx 2023-03-24 03:51:10 +0300 67) while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
05d292b2 (kx 2023-03-24 03:51:10 +0300 68) ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
05d292b2 (kx 2023-03-24 03:51:10 +0300 69) done
05d292b2 (kx 2023-03-24 03:51:10 +0300 70) test -z "$LD" && LD="$ac_prog"
05d292b2 (kx 2023-03-24 03:51:10 +0300 71) ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 72) "")
05d292b2 (kx 2023-03-24 03:51:10 +0300 73) # If it fails, then pretend we aren't using GCC.
05d292b2 (kx 2023-03-24 03:51:10 +0300 74) ac_prog=ld
05d292b2 (kx 2023-03-24 03:51:10 +0300 75) ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 76) *)
05d292b2 (kx 2023-03-24 03:51:10 +0300 77) # If it is relative, then search for the first ld in PATH.
05d292b2 (kx 2023-03-24 03:51:10 +0300 78) with_gnu_ld=unknown
05d292b2 (kx 2023-03-24 03:51:10 +0300 79) ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 80) esac
05d292b2 (kx 2023-03-24 03:51:10 +0300 81) elif test "$with_gnu_ld" = yes; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 82) AC_MSG_CHECKING([for GNU ld])
05d292b2 (kx 2023-03-24 03:51:10 +0300 83) else
05d292b2 (kx 2023-03-24 03:51:10 +0300 84) AC_MSG_CHECKING([for non-GNU ld])
05d292b2 (kx 2023-03-24 03:51:10 +0300 85) fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 86) AC_CACHE_VAL([acl_cv_path_LD],
05d292b2 (kx 2023-03-24 03:51:10 +0300 87) [if test -z "$LD"; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 88) acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
05d292b2 (kx 2023-03-24 03:51:10 +0300 89) for ac_dir in $PATH; do
05d292b2 (kx 2023-03-24 03:51:10 +0300 90) IFS="$acl_save_ifs"
05d292b2 (kx 2023-03-24 03:51:10 +0300 91) test -z "$ac_dir" && ac_dir=.
05d292b2 (kx 2023-03-24 03:51:10 +0300 92) if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 93) acl_cv_path_LD="$ac_dir/$ac_prog"
05d292b2 (kx 2023-03-24 03:51:10 +0300 94) # Check to see if the program is GNU ld. I'd rather use --version,
05d292b2 (kx 2023-03-24 03:51:10 +0300 95) # but apparently some variants of GNU ld only accept -v.
05d292b2 (kx 2023-03-24 03:51:10 +0300 96) # Break only if it was the GNU/non-GNU ld that we prefer.
05d292b2 (kx 2023-03-24 03:51:10 +0300 97) case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
05d292b2 (kx 2023-03-24 03:51:10 +0300 98) *GNU* | *'with BFD'*)
05d292b2 (kx 2023-03-24 03:51:10 +0300 99) test "$with_gnu_ld" != no && break
05d292b2 (kx 2023-03-24 03:51:10 +0300 100) ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 101) *)
05d292b2 (kx 2023-03-24 03:51:10 +0300 102) test "$with_gnu_ld" != yes && break
05d292b2 (kx 2023-03-24 03:51:10 +0300 103) ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 104) esac
05d292b2 (kx 2023-03-24 03:51:10 +0300 105) fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 106) done
05d292b2 (kx 2023-03-24 03:51:10 +0300 107) IFS="$acl_save_ifs"
05d292b2 (kx 2023-03-24 03:51:10 +0300 108) else
05d292b2 (kx 2023-03-24 03:51:10 +0300 109) acl_cv_path_LD="$LD" # Let the user override the test with a path.
05d292b2 (kx 2023-03-24 03:51:10 +0300 110) fi])
05d292b2 (kx 2023-03-24 03:51:10 +0300 111) LD="$acl_cv_path_LD"
05d292b2 (kx 2023-03-24 03:51:10 +0300 112) if test -n "$LD"; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 113) AC_MSG_RESULT([$LD])
05d292b2 (kx 2023-03-24 03:51:10 +0300 114) else
05d292b2 (kx 2023-03-24 03:51:10 +0300 115) AC_MSG_RESULT([no])
05d292b2 (kx 2023-03-24 03:51:10 +0300 116) fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 117) test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
05d292b2 (kx 2023-03-24 03:51:10 +0300 118) AC_LIB_PROG_LD_GNU
05d292b2 (kx 2023-03-24 03:51:10 +0300 119) ])