lib-ld.m4 3.5 KB

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