868b2b66 (kx 2024-12-20 16:11:07 +0300 1) # lib-ld.m4 serial 9
868b2b66 (kx 2024-12-20 16:11:07 +0300 2) dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc.
868b2b66 (kx 2024-12-20 16:11:07 +0300 3) dnl This file is free software; the Free Software Foundation
868b2b66 (kx 2024-12-20 16:11:07 +0300 4) dnl gives unlimited permission to copy and/or distribute it,
868b2b66 (kx 2024-12-20 16:11:07 +0300 5) dnl with or without modifications, as long as this notice is preserved.
868b2b66 (kx 2024-12-20 16:11:07 +0300 6)
868b2b66 (kx 2024-12-20 16:11:07 +0300 7) dnl Subroutines of libtool.m4,
868b2b66 (kx 2024-12-20 16:11:07 +0300 8) dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
868b2b66 (kx 2024-12-20 16:11:07 +0300 9) dnl collision with libtool.m4.
868b2b66 (kx 2024-12-20 16:11:07 +0300 10)
868b2b66 (kx 2024-12-20 16:11:07 +0300 11) dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
868b2b66 (kx 2024-12-20 16:11:07 +0300 12) AC_DEFUN([AC_LIB_PROG_LD_GNU],
868b2b66 (kx 2024-12-20 16:11:07 +0300 13) [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
868b2b66 (kx 2024-12-20 16:11:07 +0300 14) [# I'd rather use --version here, but apparently some GNU lds only accept -v.
868b2b66 (kx 2024-12-20 16:11:07 +0300 15) case `$LD -v 2>&1 </dev/null` in
868b2b66 (kx 2024-12-20 16:11:07 +0300 16) *GNU* | *'with BFD'*)
868b2b66 (kx 2024-12-20 16:11:07 +0300 17) acl_cv_prog_gnu_ld=yes
868b2b66 (kx 2024-12-20 16:11:07 +0300 18) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 19) *)
868b2b66 (kx 2024-12-20 16:11:07 +0300 20) acl_cv_prog_gnu_ld=no
868b2b66 (kx 2024-12-20 16:11:07 +0300 21) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 22) esac])
868b2b66 (kx 2024-12-20 16:11:07 +0300 23) with_gnu_ld=$acl_cv_prog_gnu_ld
868b2b66 (kx 2024-12-20 16:11:07 +0300 24) ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 25)
868b2b66 (kx 2024-12-20 16:11:07 +0300 26) dnl From libtool-2.4. Sets the variable LD.
868b2b66 (kx 2024-12-20 16:11:07 +0300 27) AC_DEFUN([AC_LIB_PROG_LD],
868b2b66 (kx 2024-12-20 16:11:07 +0300 28) [AC_REQUIRE([AC_PROG_CC])dnl
868b2b66 (kx 2024-12-20 16:11:07 +0300 29) AC_REQUIRE([AC_CANONICAL_HOST])dnl
868b2b66 (kx 2024-12-20 16:11:07 +0300 30)
868b2b66 (kx 2024-12-20 16:11:07 +0300 31) AC_ARG_WITH([gnu-ld],
868b2b66 (kx 2024-12-20 16:11:07 +0300 32) [AS_HELP_STRING([--with-gnu-ld],
868b2b66 (kx 2024-12-20 16:11:07 +0300 33) [assume the C compiler uses GNU ld [default=no]])],
868b2b66 (kx 2024-12-20 16:11:07 +0300 34) [test "$withval" = no || with_gnu_ld=yes],
868b2b66 (kx 2024-12-20 16:11:07 +0300 35) [with_gnu_ld=no])dnl
868b2b66 (kx 2024-12-20 16:11:07 +0300 36)
868b2b66 (kx 2024-12-20 16:11:07 +0300 37) # Prepare PATH_SEPARATOR.
868b2b66 (kx 2024-12-20 16:11:07 +0300 38) # The user is always right.
868b2b66 (kx 2024-12-20 16:11:07 +0300 39) if test "${PATH_SEPARATOR+set}" != set; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 40) # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
868b2b66 (kx 2024-12-20 16:11:07 +0300 41) # contains only /bin. Note that ksh looks also at the FPATH variable,
868b2b66 (kx 2024-12-20 16:11:07 +0300 42) # so we have to set that as well for the test.
868b2b66 (kx 2024-12-20 16:11:07 +0300 43) PATH_SEPARATOR=:
868b2b66 (kx 2024-12-20 16:11:07 +0300 44) (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
868b2b66 (kx 2024-12-20 16:11:07 +0300 45) && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
868b2b66 (kx 2024-12-20 16:11:07 +0300 46) || PATH_SEPARATOR=';'
868b2b66 (kx 2024-12-20 16:11:07 +0300 47) }
868b2b66 (kx 2024-12-20 16:11:07 +0300 48) fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 49)
868b2b66 (kx 2024-12-20 16:11:07 +0300 50) if test -n "$LD"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 51) AC_MSG_CHECKING([for ld])
868b2b66 (kx 2024-12-20 16:11:07 +0300 52) elif test "$GCC" = yes; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 53) AC_MSG_CHECKING([for ld used by $CC])
868b2b66 (kx 2024-12-20 16:11:07 +0300 54) elif test "$with_gnu_ld" = yes; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 55) AC_MSG_CHECKING([for GNU ld])
868b2b66 (kx 2024-12-20 16:11:07 +0300 56) else
868b2b66 (kx 2024-12-20 16:11:07 +0300 57) AC_MSG_CHECKING([for non-GNU ld])
868b2b66 (kx 2024-12-20 16:11:07 +0300 58) fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 59) if test -n "$LD"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 60) # Let the user override the test with a path.
868b2b66 (kx 2024-12-20 16:11:07 +0300 61) :
868b2b66 (kx 2024-12-20 16:11:07 +0300 62) else
868b2b66 (kx 2024-12-20 16:11:07 +0300 63) AC_CACHE_VAL([acl_cv_path_LD],
868b2b66 (kx 2024-12-20 16:11:07 +0300 64) [
868b2b66 (kx 2024-12-20 16:11:07 +0300 65) acl_cv_path_LD= # Final result of this test
868b2b66 (kx 2024-12-20 16:11:07 +0300 66) ac_prog=ld # Program to search in $PATH
868b2b66 (kx 2024-12-20 16:11:07 +0300 67) if test "$GCC" = yes; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 68) # Check if gcc -print-prog-name=ld gives a path.
868b2b66 (kx 2024-12-20 16:11:07 +0300 69) case $host in
868b2b66 (kx 2024-12-20 16:11:07 +0300 70) *-*-mingw*)
868b2b66 (kx 2024-12-20 16:11:07 +0300 71) # gcc leaves a trailing carriage return which upsets mingw
868b2b66 (kx 2024-12-20 16:11:07 +0300 72) acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 73) *)
868b2b66 (kx 2024-12-20 16:11:07 +0300 74) acl_output=`($CC -print-prog-name=ld) 2>&5` ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 75) esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 76) case $acl_output in
868b2b66 (kx 2024-12-20 16:11:07 +0300 77) # Accept absolute paths.
868b2b66 (kx 2024-12-20 16:11:07 +0300 78) [[\\/]]* | ?:[[\\/]]*)
868b2b66 (kx 2024-12-20 16:11:07 +0300 79) re_direlt='/[[^/]][[^/]]*/\.\./'
868b2b66 (kx 2024-12-20 16:11:07 +0300 80) # Canonicalize the pathname of ld
868b2b66 (kx 2024-12-20 16:11:07 +0300 81) acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'`
868b2b66 (kx 2024-12-20 16:11:07 +0300 82) while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do
868b2b66 (kx 2024-12-20 16:11:07 +0300 83) acl_output=`echo $acl_output | sed "s%$re_direlt%/%"`
868b2b66 (kx 2024-12-20 16:11:07 +0300 84) done
868b2b66 (kx 2024-12-20 16:11:07 +0300 85) # Got the pathname. No search in PATH is needed.
868b2b66 (kx 2024-12-20 16:11:07 +0300 86) acl_cv_path_LD="$acl_output"
868b2b66 (kx 2024-12-20 16:11:07 +0300 87) ac_prog=
868b2b66 (kx 2024-12-20 16:11:07 +0300 88) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 89) "")
868b2b66 (kx 2024-12-20 16:11:07 +0300 90) # If it fails, then pretend we aren't using GCC.
868b2b66 (kx 2024-12-20 16:11:07 +0300 91) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 92) *)
868b2b66 (kx 2024-12-20 16:11:07 +0300 93) # If it is relative, then search for the first ld in PATH.
868b2b66 (kx 2024-12-20 16:11:07 +0300 94) with_gnu_ld=unknown
868b2b66 (kx 2024-12-20 16:11:07 +0300 95) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 96) esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 97) fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 98) if test -n "$ac_prog"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 99) # Search for $ac_prog in $PATH.
868b2b66 (kx 2024-12-20 16:11:07 +0300 100) acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
868b2b66 (kx 2024-12-20 16:11:07 +0300 101) for ac_dir in $PATH; do
868b2b66 (kx 2024-12-20 16:11:07 +0300 102) IFS="$acl_save_ifs"
868b2b66 (kx 2024-12-20 16:11:07 +0300 103) test -z "$ac_dir" && ac_dir=.
868b2b66 (kx 2024-12-20 16:11:07 +0300 104) if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 105) acl_cv_path_LD="$ac_dir/$ac_prog"
868b2b66 (kx 2024-12-20 16:11:07 +0300 106) # Check to see if the program is GNU ld. I'd rather use --version,
868b2b66 (kx 2024-12-20 16:11:07 +0300 107) # but apparently some variants of GNU ld only accept -v.
868b2b66 (kx 2024-12-20 16:11:07 +0300 108) # Break only if it was the GNU/non-GNU ld that we prefer.
868b2b66 (kx 2024-12-20 16:11:07 +0300 109) case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
868b2b66 (kx 2024-12-20 16:11:07 +0300 110) *GNU* | *'with BFD'*)
868b2b66 (kx 2024-12-20 16:11:07 +0300 111) test "$with_gnu_ld" != no && break
868b2b66 (kx 2024-12-20 16:11:07 +0300 112) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 113) *)
868b2b66 (kx 2024-12-20 16:11:07 +0300 114) test "$with_gnu_ld" != yes && break
868b2b66 (kx 2024-12-20 16:11:07 +0300 115) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 116) esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 117) fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 118) done
868b2b66 (kx 2024-12-20 16:11:07 +0300 119) IFS="$acl_save_ifs"
868b2b66 (kx 2024-12-20 16:11:07 +0300 120) fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 121) case $host in
868b2b66 (kx 2024-12-20 16:11:07 +0300 122) *-*-aix*)
868b2b66 (kx 2024-12-20 16:11:07 +0300 123) AC_COMPILE_IFELSE(
868b2b66 (kx 2024-12-20 16:11:07 +0300 124) [AC_LANG_SOURCE(
868b2b66 (kx 2024-12-20 16:11:07 +0300 125) [[#if defined __powerpc64__ || defined _ARCH_PPC64
868b2b66 (kx 2024-12-20 16:11:07 +0300 126) int ok;
868b2b66 (kx 2024-12-20 16:11:07 +0300 127) #else
868b2b66 (kx 2024-12-20 16:11:07 +0300 128) error fail
868b2b66 (kx 2024-12-20 16:11:07 +0300 129) #endif
868b2b66 (kx 2024-12-20 16:11:07 +0300 130) ]])],
868b2b66 (kx 2024-12-20 16:11:07 +0300 131) [# The compiler produces 64-bit code. Add option '-b64' so that the
868b2b66 (kx 2024-12-20 16:11:07 +0300 132) # linker groks 64-bit object files.
868b2b66 (kx 2024-12-20 16:11:07 +0300 133) case "$acl_cv_path_LD " in
868b2b66 (kx 2024-12-20 16:11:07 +0300 134) *" -b64 "*) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 135) *) acl_cv_path_LD="$acl_cv_path_LD -b64" ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 136) esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 137) ], [])
868b2b66 (kx 2024-12-20 16:11:07 +0300 138) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 139) sparc64-*-netbsd*)
868b2b66 (kx 2024-12-20 16:11:07 +0300 140) AC_COMPILE_IFELSE(
868b2b66 (kx 2024-12-20 16:11:07 +0300 141) [AC_LANG_SOURCE(
868b2b66 (kx 2024-12-20 16:11:07 +0300 142) [[#if defined __sparcv9 || defined __arch64__
868b2b66 (kx 2024-12-20 16:11:07 +0300 143) int ok;
868b2b66 (kx 2024-12-20 16:11:07 +0300 144) #else
868b2b66 (kx 2024-12-20 16:11:07 +0300 145) error fail
868b2b66 (kx 2024-12-20 16:11:07 +0300 146) #endif
868b2b66 (kx 2024-12-20 16:11:07 +0300 147) ]])],
868b2b66 (kx 2024-12-20 16:11:07 +0300 148) [],
868b2b66 (kx 2024-12-20 16:11:07 +0300 149) [# The compiler produces 32-bit code. Add option '-m elf32_sparc'
868b2b66 (kx 2024-12-20 16:11:07 +0300 150) # so that the linker groks 32-bit object files.
868b2b66 (kx 2024-12-20 16:11:07 +0300 151) case "$acl_cv_path_LD " in
868b2b66 (kx 2024-12-20 16:11:07 +0300 152) *" -m elf32_sparc "*) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 153) *) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 154) esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 155) ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 156) ;;
868b2b66 (kx 2024-12-20 16:11:07 +0300 157) esac
868b2b66 (kx 2024-12-20 16:11:07 +0300 158) ])
868b2b66 (kx 2024-12-20 16:11:07 +0300 159) LD="$acl_cv_path_LD"
868b2b66 (kx 2024-12-20 16:11:07 +0300 160) fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 161) if test -n "$LD"; then
868b2b66 (kx 2024-12-20 16:11:07 +0300 162) AC_MSG_RESULT([$LD])
868b2b66 (kx 2024-12-20 16:11:07 +0300 163) else
868b2b66 (kx 2024-12-20 16:11:07 +0300 164) AC_MSG_RESULT([no])
868b2b66 (kx 2024-12-20 16:11:07 +0300 165) AC_MSG_ERROR([no acceptable ld found in \$PATH])
868b2b66 (kx 2024-12-20 16:11:07 +0300 166) fi
868b2b66 (kx 2024-12-20 16:11:07 +0300 167) AC_LIB_PROG_LD_GNU
868b2b66 (kx 2024-12-20 16:11:07 +0300 168) ])