lib-ld.m4 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # lib-ld.m4 serial 1 (gettext-0.11)
  2. dnl Copyright (C) 1996-2002 Free Software Foundation, Inc.
  3. dnl This file is free software, distributed under the terms of the GNU
  4. dnl General Public License. As a special exception to the GNU General
  5. dnl Public License, this file may be distributed as part of a program
  6. dnl that contains a configuration script generated by Autoconf, under
  7. dnl the same distribution terms as the rest of that program.
  8. dnl Subroutines of libtool.m4,
  9. dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
  10. dnl with libtool.m4.
  11. dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
  12. AC_DEFUN([AC_LIB_PROG_LD_GNU],
  13. [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
  14. [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
  15. if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
  16. acl_cv_prog_gnu_ld=yes
  17. else
  18. acl_cv_prog_gnu_ld=no
  19. fi])
  20. with_gnu_ld=$acl_cv_prog_gnu_ld
  21. ])
  22. dnl From libtool-1.4. Sets the variable LD.
  23. AC_DEFUN([AC_LIB_PROG_LD],
  24. [AC_ARG_WITH(gnu-ld,
  25. [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
  26. test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
  27. AC_REQUIRE([AC_PROG_CC])dnl
  28. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  29. ac_prog=ld
  30. if test "$GCC" = yes; then
  31. # Check if gcc -print-prog-name=ld gives a path.
  32. AC_MSG_CHECKING([for ld used by GCC])
  33. case $host in
  34. *-*-mingw*)
  35. # gcc leaves a trailing carriage return which upsets mingw
  36. ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
  37. *)
  38. ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
  39. esac
  40. case $ac_prog in
  41. # Accept absolute paths.
  42. [[\\/]* | [A-Za-z]:[\\/]*)]
  43. [re_direlt='/[^/][^/]*/\.\./']
  44. # Canonicalize the path of ld
  45. ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
  46. while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
  47. ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
  48. done
  49. test -z "$LD" && LD="$ac_prog"
  50. ;;
  51. "")
  52. # If it fails, then pretend we aren't using GCC.
  53. ac_prog=ld
  54. ;;
  55. *)
  56. # If it is relative, then search for the first ld in PATH.
  57. with_gnu_ld=unknown
  58. ;;
  59. esac
  60. elif test "$with_gnu_ld" = yes; then
  61. AC_MSG_CHECKING([for GNU ld])
  62. else
  63. AC_MSG_CHECKING([for non-GNU ld])
  64. fi
  65. AC_CACHE_VAL(acl_cv_path_LD,
  66. [if test -z "$LD"; then
  67. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
  68. for ac_dir in $PATH; do
  69. test -z "$ac_dir" && ac_dir=.
  70. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
  71. acl_cv_path_LD="$ac_dir/$ac_prog"
  72. # Check to see if the program is GNU ld. I'd rather use --version,
  73. # but apparently some GNU ld's only accept -v.
  74. # Break only if it was the GNU/non-GNU ld that we prefer.
  75. if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
  76. test "$with_gnu_ld" != no && break
  77. else
  78. test "$with_gnu_ld" != yes && break
  79. fi
  80. fi
  81. done
  82. IFS="$ac_save_ifs"
  83. else
  84. acl_cv_path_LD="$LD" # Let the user override the test with a path.
  85. fi])
  86. LD="$acl_cv_path_LD"
  87. if test -n "$LD"; then
  88. AC_MSG_RESULT($LD)
  89. else
  90. AC_MSG_RESULT(no)
  91. fi
  92. test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
  93. AC_LIB_PROG_LD_GNU
  94. ])