2
dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc.
1
# lib-ld.m4 serial 4 (gettext-0.18)
2
dnl Copyright (C) 1996-2003, 2009-2010 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/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
9
dnl collision with libtool.m4.
8
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
11
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
11
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
12
12
AC_DEFUN([AC_LIB_PROG_LD_GNU],
13
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.
14
[# I'd rather use --version here, but apparently some GNU ld's 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 ;;
23
21
with_gnu_ld=$acl_cv_prog_gnu_ld
26
dnl From libtool-2.4. Sets the variable LD.
24
dnl From libtool-1.4. Sets the variable LD.
27
25
AC_DEFUN([AC_LIB_PROG_LD],
28
[AC_REQUIRE([AC_PROG_CC])dnl
26
[AC_ARG_WITH([gnu-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
29
30
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],
37
31
# Prepare PATH_SEPARATOR.
38
32
# The user is always right.
39
33
if test "${PATH_SEPARATOR+set}" != set; 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 \
34
echo "#! /bin/sh" >conf$$.sh
35
echo "exit 0" >>conf$$.sh
37
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
50
if test -n "$LD"; then
51
AC_MSG_CHECKING([for ld])
52
elif test "$GCC" = yes; then
53
AC_MSG_CHECKING([for ld used by $CC])
45
if test "$GCC" = yes; then
46
# Check if gcc -print-prog-name=ld gives a path.
47
AC_MSG_CHECKING([for ld used by GCC])
50
# gcc leaves a trailing carriage return which upsets mingw
51
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
53
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
56
# 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%/%"`
64
test -z "$LD" && LD="$ac_prog"
67
# If it fails, then pretend we aren't using GCC.
71
# If it is relative, then search for the first ld in PATH.
54
75
elif test "$with_gnu_ld" = yes; then
55
76
AC_MSG_CHECKING([for GNU ld])
57
78
AC_MSG_CHECKING([for non-GNU ld])
59
if test -n "$LD"; then
60
# Let the user override the test with a path.
80
AC_CACHE_VAL([acl_cv_path_LD],
81
[if test -z "$LD"; then
82
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
83
for ac_dir in $PATH; do
84
test -z "$ac_dir" && ac_dir=.
85
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
86
acl_cv_path_LD="$ac_dir/$ac_prog"
87
# Check to see if the program is GNU ld. I'd rather use --version,
88
# but apparently some GNU ld's only accept -v.
89
# 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
92
test "$with_gnu_ld" != no && break ;;
94
test "$with_gnu_ld" != yes && break ;;
63
AC_CACHE_VAL([acl_cv_path_LD],
65
acl_cv_path_LD= # Final result of this test
66
ac_prog=ld # Program to search in $PATH
67
if test "$GCC" = yes; then
68
# Check if gcc -print-prog-name=ld gives a path.
71
# gcc leaves a trailing carriage return which upsets mingw
72
acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
74
acl_output=`($CC -print-prog-name=ld) 2>&5` ;;
77
# Accept absolute paths.
78
[[\\/]]* | ?:[[\\/]]*)
79
re_direlt='/[[^/]][[^/]]*/\.\./'
80
# Canonicalize the pathname of ld
81
acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'`
82
while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do
83
acl_output=`echo $acl_output | sed "s%$re_direlt%/%"`
85
# Got the pathname. No search in PATH is needed.
86
acl_cv_path_LD="$acl_output"
90
# If it fails, then pretend we aren't using GCC.
93
# If it is relative, then search for the first ld in PATH.
98
if test -n "$ac_prog"; then
99
# Search for $ac_prog in $PATH.
100
acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
101
for ac_dir in $PATH; do
103
test -z "$ac_dir" && ac_dir=.
104
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
105
acl_cv_path_LD="$ac_dir/$ac_prog"
106
# Check to see if the program is GNU ld. I'd rather use --version,
107
# but apparently some variants of GNU ld only accept -v.
108
# Break only if it was the GNU/non-GNU ld that we prefer.
109
case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
110
*GNU* | *'with BFD'*)
111
test "$with_gnu_ld" != no && break
114
test "$with_gnu_ld" != yes && break
125
[[#if defined __powerpc64__ || defined _ARCH_PPC64
131
[# The compiler produces 64-bit code. Add option '-b64' so that the
132
# linker groks 64-bit object files.
133
case "$acl_cv_path_LD " in
135
*) acl_cv_path_LD="$acl_cv_path_LD -b64" ;;
142
[[#if defined __sparcv9 || defined __arch64__
149
[# The compiler produces 32-bit code. Add option '-m elf32_sparc'
150
# so that the linker groks 32-bit object files.
151
case "$acl_cv_path_LD " in
152
*" -m elf32_sparc "*) ;;
153
*) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;;
100
acl_cv_path_LD="$LD" # Let the user override the test with a path.
161
103
if test -n "$LD"; then
162
104
AC_MSG_RESULT([$LD])
164
106
AC_MSG_RESULT([no])
165
AC_MSG_ERROR([no acceptable ld found in \$PATH])
108
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
167
109
AC_LIB_PROG_LD_GNU