xref: /aosp_15_r20/external/libexif/auto-m4/lib-ld.m4 (revision 735d6239c16e246968a03ef6e2db00d67bad6cdc)
1*735d6239SKiyoung Kim# lib-ld.m4 serial 3 (gettext-0.13)
2*735d6239SKiyoung Kimdnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
3*735d6239SKiyoung Kimdnl This file is free software, distributed under the terms of the GNU
4*735d6239SKiyoung Kimdnl General Public License.  As a special exception to the GNU General
5*735d6239SKiyoung Kimdnl Public License, this file may be distributed as part of a program
6*735d6239SKiyoung Kimdnl that contains a configuration script generated by Autoconf, under
7*735d6239SKiyoung Kimdnl the same distribution terms as the rest of that program.
8*735d6239SKiyoung Kim
9*735d6239SKiyoung Kimdnl Subroutines of libtool.m4,
10*735d6239SKiyoung Kimdnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
11*735d6239SKiyoung Kimdnl with libtool.m4.
12*735d6239SKiyoung Kim
13*735d6239SKiyoung Kimdnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
14*735d6239SKiyoung KimAC_DEFUN([AC_LIB_PROG_LD_GNU],
15*735d6239SKiyoung Kim[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
16*735d6239SKiyoung Kim[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
17*735d6239SKiyoung Kimcase `$LD -v 2>&1 </dev/null` in
18*735d6239SKiyoung Kim*GNU* | *'with BFD'*)
19*735d6239SKiyoung Kim  acl_cv_prog_gnu_ld=yes ;;
20*735d6239SKiyoung Kim*)
21*735d6239SKiyoung Kim  acl_cv_prog_gnu_ld=no ;;
22*735d6239SKiyoung Kimesac])
23*735d6239SKiyoung Kimwith_gnu_ld=$acl_cv_prog_gnu_ld
24*735d6239SKiyoung Kim])
25*735d6239SKiyoung Kim
26*735d6239SKiyoung Kimdnl From libtool-1.4. Sets the variable LD.
27*735d6239SKiyoung KimAC_DEFUN([AC_LIB_PROG_LD],
28*735d6239SKiyoung Kim[AC_ARG_WITH(gnu-ld,
29*735d6239SKiyoung Kim[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
30*735d6239SKiyoung Kimtest "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
31*735d6239SKiyoung KimAC_REQUIRE([AC_PROG_CC])dnl
32*735d6239SKiyoung KimAC_REQUIRE([AC_CANONICAL_HOST])dnl
33*735d6239SKiyoung Kim# Prepare PATH_SEPARATOR.
34*735d6239SKiyoung Kim# The user is always right.
35*735d6239SKiyoung Kimif test "${PATH_SEPARATOR+set}" != set; then
36*735d6239SKiyoung Kim  echo "#! /bin/sh" >conf$$.sh
37*735d6239SKiyoung Kim  echo  "exit 0"   >>conf$$.sh
38*735d6239SKiyoung Kim  chmod +x conf$$.sh
39*735d6239SKiyoung Kim  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
40*735d6239SKiyoung Kim    PATH_SEPARATOR=';'
41*735d6239SKiyoung Kim  else
42*735d6239SKiyoung Kim    PATH_SEPARATOR=:
43*735d6239SKiyoung Kim  fi
44*735d6239SKiyoung Kim  rm -f conf$$.sh
45*735d6239SKiyoung Kimfi
46*735d6239SKiyoung Kimac_prog=ld
47*735d6239SKiyoung Kimif test "$GCC" = yes; then
48*735d6239SKiyoung Kim  # Check if gcc -print-prog-name=ld gives a path.
49*735d6239SKiyoung Kim  AC_MSG_CHECKING([for ld used by GCC])
50*735d6239SKiyoung Kim  case $host in
51*735d6239SKiyoung Kim  *-*-mingw*)
52*735d6239SKiyoung Kim    # gcc leaves a trailing carriage return which upsets mingw
53*735d6239SKiyoung Kim    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
54*735d6239SKiyoung Kim  *)
55*735d6239SKiyoung Kim    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
56*735d6239SKiyoung Kim  esac
57*735d6239SKiyoung Kim  case $ac_prog in
58*735d6239SKiyoung Kim    # Accept absolute paths.
59*735d6239SKiyoung Kim    [[\\/]* | [A-Za-z]:[\\/]*)]
60*735d6239SKiyoung Kim      [re_direlt='/[^/][^/]*/\.\./']
61*735d6239SKiyoung Kim      # Canonicalize the path of ld
62*735d6239SKiyoung Kim      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
63*735d6239SKiyoung Kim      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
64*735d6239SKiyoung Kim	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
65*735d6239SKiyoung Kim      done
66*735d6239SKiyoung Kim      test -z "$LD" && LD="$ac_prog"
67*735d6239SKiyoung Kim      ;;
68*735d6239SKiyoung Kim  "")
69*735d6239SKiyoung Kim    # If it fails, then pretend we aren't using GCC.
70*735d6239SKiyoung Kim    ac_prog=ld
71*735d6239SKiyoung Kim    ;;
72*735d6239SKiyoung Kim  *)
73*735d6239SKiyoung Kim    # If it is relative, then search for the first ld in PATH.
74*735d6239SKiyoung Kim    with_gnu_ld=unknown
75*735d6239SKiyoung Kim    ;;
76*735d6239SKiyoung Kim  esac
77*735d6239SKiyoung Kimelif test "$with_gnu_ld" = yes; then
78*735d6239SKiyoung Kim  AC_MSG_CHECKING([for GNU ld])
79*735d6239SKiyoung Kimelse
80*735d6239SKiyoung Kim  AC_MSG_CHECKING([for non-GNU ld])
81*735d6239SKiyoung Kimfi
82*735d6239SKiyoung KimAC_CACHE_VAL(acl_cv_path_LD,
83*735d6239SKiyoung Kim[if test -z "$LD"; then
84*735d6239SKiyoung Kim  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
85*735d6239SKiyoung Kim  for ac_dir in $PATH; do
86*735d6239SKiyoung Kim    test -z "$ac_dir" && ac_dir=.
87*735d6239SKiyoung Kim    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
88*735d6239SKiyoung Kim      acl_cv_path_LD="$ac_dir/$ac_prog"
89*735d6239SKiyoung Kim      # Check to see if the program is GNU ld.  I'd rather use --version,
90*735d6239SKiyoung Kim      # but apparently some GNU ld's only accept -v.
91*735d6239SKiyoung Kim      # Break only if it was the GNU/non-GNU ld that we prefer.
92*735d6239SKiyoung Kim      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
93*735d6239SKiyoung Kim      *GNU* | *'with BFD'*)
94*735d6239SKiyoung Kim	test "$with_gnu_ld" != no && break ;;
95*735d6239SKiyoung Kim      *)
96*735d6239SKiyoung Kim	test "$with_gnu_ld" != yes && break ;;
97*735d6239SKiyoung Kim      esac
98*735d6239SKiyoung Kim    fi
99*735d6239SKiyoung Kim  done
100*735d6239SKiyoung Kim  IFS="$ac_save_ifs"
101*735d6239SKiyoung Kimelse
102*735d6239SKiyoung Kim  acl_cv_path_LD="$LD" # Let the user override the test with a path.
103*735d6239SKiyoung Kimfi])
104*735d6239SKiyoung KimLD="$acl_cv_path_LD"
105*735d6239SKiyoung Kimif test -n "$LD"; then
106*735d6239SKiyoung Kim  AC_MSG_RESULT($LD)
107*735d6239SKiyoung Kimelse
108*735d6239SKiyoung Kim  AC_MSG_RESULT(no)
109*735d6239SKiyoung Kimfi
110*735d6239SKiyoung Kimtest -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
111*735d6239SKiyoung KimAC_LIB_PROG_LD_GNU
112*735d6239SKiyoung Kim])
113