lib-ld.m4 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # lib-ld.m4 serial 2 (gettext-0.12)
  2. dnl Copyright (C) 1996-2003 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. # Prepare PATH_SEPARATOR.
  30. # The user is always right.
  31. if test "${PATH_SEPARATOR+set}" != set; then
  32. echo "#! /bin/sh" >conf$$.sh
  33. echo "exit 0" >>conf$$.sh
  34. chmod +x conf$$.sh
  35. if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
  36. PATH_SEPARATOR=';'
  37. else
  38. PATH_SEPARATOR=:
  39. fi
  40. rm -f conf$$.sh
  41. fi
  42. ac_prog=ld
  43. if test "$GCC" = yes; then
  44. # Check if gcc -print-prog-name=ld gives a path.
  45. AC_MSG_CHECKING([for ld used by GCC])
  46. case $host in
  47. *-*-mingw*)
  48. # gcc leaves a trailing carriage return which upsets mingw
  49. ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
  50. *)
  51. ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
  52. esac
  53. case $ac_prog in
  54. # Accept absolute paths.
  55. [[\\/]* | [A-Za-z]:[\\/]*)]
  56. [re_direlt='/[^/][^/]*/\.\./']
  57. # Canonicalize the path of ld
  58. ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
  59. while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
  60. ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
  61. done
  62. test -z "$LD" && LD="$ac_prog"
  63. ;;
  64. "")
  65. # If it fails, then pretend we aren't using GCC.
  66. ac_prog=ld
  67. ;;
  68. *)
  69. # If it is relative, then search for the first ld in PATH.
  70. with_gnu_ld=unknown
  71. ;;
  72. esac
  73. elif test "$with_gnu_ld" = yes; then
  74. AC_MSG_CHECKING([for GNU ld])
  75. else
  76. AC_MSG_CHECKING([for non-GNU ld])
  77. fi
  78. AC_CACHE_VAL(acl_cv_path_LD,
  79. [if test -z "$LD"; then
  80. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
  81. for ac_dir in $PATH; do
  82. test -z "$ac_dir" && ac_dir=.
  83. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
  84. acl_cv_path_LD="$ac_dir/$ac_prog"
  85. # Check to see if the program is GNU ld. I'd rather use --version,
  86. # but apparently some GNU ld's only accept -v.
  87. # Break only if it was the GNU/non-GNU ld that we prefer.
  88. if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
  89. test "$with_gnu_ld" != no && break
  90. else
  91. test "$with_gnu_ld" != yes && break
  92. fi
  93. fi
  94. done
  95. IFS="$ac_save_ifs"
  96. else
  97. acl_cv_path_LD="$LD" # Let the user override the test with a path.
  98. fi])
  99. LD="$acl_cv_path_LD"
  100. if test -n "$LD"; then
  101. AC_MSG_RESULT($LD)
  102. else
  103. AC_MSG_RESULT(no)
  104. fi
  105. test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
  106. AC_LIB_PROG_LD_GNU
  107. ])