1
# lib-ld.m4 serial 3 (gettext-0.13)
2
dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
2
dnl Copyright (C) 1996-2003, 2009-2014 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
7
7
dnl Subroutines of libtool.m4,
8
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
8
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
9
dnl collision with libtool.m4.
11
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
11
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
12
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.
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 lds only accept -v.
15
15
case `$LD -v 2>&1 </dev/null` in
16
16
*GNU* | *'with BFD'*)
17
acl_cv_prog_gnu_ld=yes ;;
17
acl_cv_prog_gnu_ld=yes
19
acl_cv_prog_gnu_ld=no ;;
21
23
with_gnu_ld=$acl_cv_prog_gnu_ld
24
dnl From libtool-1.4. Sets the variable LD.
26
dnl From libtool-2.4. Sets the variable LD.
25
27
AC_DEFUN([AC_LIB_PROG_LD],
27
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
28
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
29
AC_REQUIRE([AC_PROG_CC])dnl
28
[AC_REQUIRE([AC_PROG_CC])dnl
30
29
AC_REQUIRE([AC_CANONICAL_HOST])dnl
32
[AS_HELP_STRING([--with-gnu-ld],
33
[assume the C compiler uses GNU ld [default=no]])],
34
[test "$withval" = no || with_gnu_ld=yes],
31
37
# Prepare PATH_SEPARATOR.
32
38
# The user is always right.
33
39
if test "${PATH_SEPARATOR+set}" != set; then
34
echo "#! /bin/sh" >conf$$.sh
35
echo "exit 0" >>conf$$.sh
37
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
40
# Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
41
# contains only /bin. Note that ksh looks also at the FPATH variable,
42
# so we have to set that as well for the test.
44
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
45
&& { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
45
51
if test "$GCC" = yes; then
46
52
# Check if gcc -print-prog-name=ld gives a path.
47
AC_MSG_CHECKING([for ld used by GCC])
53
AC_MSG_CHECKING([for ld used by $CC])
50
56
# gcc leaves a trailing carriage return which upsets mingw
56
62
# Accept absolute paths.
57
[[\\/]* | [A-Za-z]:[\\/]*)]
58
[re_direlt='/[^/][^/]*/\.\./']
59
# Canonicalize the path of ld
60
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
61
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
62
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
63
[[\\/]]* | ?:[[\\/]]*)
64
re_direlt='/[[^/]][[^/]]*/\.\./'
65
# Canonicalize the pathname of ld
66
ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
67
while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
68
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
64
70
test -z "$LD" && LD="$ac_prog"
78
84
AC_MSG_CHECKING([for non-GNU ld])
80
AC_CACHE_VAL(acl_cv_path_LD,
86
AC_CACHE_VAL([acl_cv_path_LD],
81
87
[if test -z "$LD"; then
82
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
88
acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
83
89
for ac_dir in $PATH; do
84
91
test -z "$ac_dir" && ac_dir=.
85
92
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
86
93
acl_cv_path_LD="$ac_dir/$ac_prog"
87
94
# Check to see if the program is GNU ld. I'd rather use --version,
88
# but apparently some GNU ld's only accept -v.
95
# but apparently some variants of GNU ld only accept -v.
89
96
# Break only if it was the GNU/non-GNU ld that we prefer.
90
case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
97
case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
91
98
*GNU* | *'with BFD'*)
92
test "$with_gnu_ld" != no && break ;;
99
test "$with_gnu_ld" != no && break
94
test "$with_gnu_ld" != yes && break ;;
102
test "$with_gnu_ld" != yes && break
100
109
acl_cv_path_LD="$LD" # Let the user override the test with a path.
102
111
LD="$acl_cv_path_LD"
103
112
if test -n "$LD"; then
108
117
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
109
118
AC_LIB_PROG_LD_GNU