lib-ld.m4 3.4 KB

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