ast_prog_ld.m4 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # AST_PROG_LD
  2. # ----------
  3. # find the pathname to the GNU or non-GNU linker
  4. AC_DEFUN([AST_PROG_LD],
  5. [AC_ARG_WITH([gnu-ld],
  6. [AS_HELP_STRING([--with-gnu-ld],
  7. [assume the C compiler uses GNU ld @<:@default=no@:>@])],
  8. [test "$withval" = no || with_gnu_ld=yes],
  9. [with_gnu_ld=no])
  10. AC_REQUIRE([AST_PROG_SED])dnl
  11. AC_REQUIRE([AC_PROG_CC])dnl
  12. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  13. AC_REQUIRE([AC_CANONICAL_BUILD])dnl
  14. ac_prog=ld
  15. if test "$GCC" = yes; then
  16. # Check if gcc -print-prog-name=ld gives a path.
  17. AC_MSG_CHECKING([for ld used by $CC])
  18. case $host in
  19. *-*-mingw*)
  20. # gcc leaves a trailing carriage return which upsets mingw
  21. ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
  22. *)
  23. ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
  24. esac
  25. case $ac_prog in
  26. # Accept absolute paths.
  27. [[\\/]]* | ?:[[\\/]]*)
  28. re_direlt='/[[^/]][[^/]]*/\.\./'
  29. # Canonicalize the pathname of ld
  30. ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
  31. while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
  32. ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
  33. done
  34. test -z "$LD" && LD="$ac_prog"
  35. ;;
  36. "")
  37. # If it fails, then pretend we aren't using GCC.
  38. ac_prog=ld
  39. ;;
  40. *)
  41. # If it is relative, then search for the first ld in PATH.
  42. with_gnu_ld=unknown
  43. ;;
  44. esac
  45. elif test "$with_gnu_ld" = yes; then
  46. AC_MSG_CHECKING([for GNU ld])
  47. else
  48. AC_MSG_CHECKING([for non-GNU ld])
  49. fi
  50. AC_CACHE_VAL(lt_cv_path_LD,
  51. [if test -z "$LD"; then
  52. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
  53. for ac_dir in $PATH; do
  54. IFS="$lt_save_ifs"
  55. test -z "$ac_dir" && ac_dir=.
  56. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
  57. lt_cv_path_LD="$ac_dir/$ac_prog"
  58. # Check to see if the program is GNU ld. I'd rather use --version,
  59. # but apparently some variants of GNU ld only accept -v.
  60. # Break only if it was the GNU/non-GNU ld that we prefer.
  61. case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
  62. *GNU* | *'with BFD'*)
  63. test "$with_gnu_ld" != no && break
  64. ;;
  65. *)
  66. test "$with_gnu_ld" != yes && break
  67. ;;
  68. esac
  69. fi
  70. done
  71. IFS="$lt_save_ifs"
  72. else
  73. lt_cv_path_LD="$LD" # Let the user override the test with a path.
  74. fi])
  75. LD="$lt_cv_path_LD"
  76. if test -n "$LD"; then
  77. AC_MSG_RESULT($LD)
  78. else
  79. AC_MSG_RESULT(no)
  80. fi
  81. test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
  82. AST_PROG_LD_GNU
  83. ])# AST_PROG_LD