Blame m4/lib-ld.m4

Packit 3ff1e7
# lib-ld.m4 serial 4 (gettext-0.18)
Packit 3ff1e7
dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc.
Packit 3ff1e7
dnl This file is free software; the Free Software Foundation
Packit 3ff1e7
dnl gives unlimited permission to copy and/or distribute it,
Packit 3ff1e7
dnl with or without modifications, as long as this notice is preserved.
Packit 3ff1e7
Packit 3ff1e7
dnl Subroutines of libtool.m4,
Packit 3ff1e7
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
Packit 3ff1e7
dnl with libtool.m4.
Packit 3ff1e7
Packit 3ff1e7
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
Packit 3ff1e7
AC_DEFUN([AC_LIB_PROG_LD_GNU],
Packit 3ff1e7
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
Packit 3ff1e7
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
Packit 3ff1e7
case `$LD -v 2>&1 
Packit 3ff1e7
*GNU* | *'with BFD'*)
Packit 3ff1e7
  acl_cv_prog_gnu_ld=yes ;;
Packit 3ff1e7
*)
Packit 3ff1e7
  acl_cv_prog_gnu_ld=no ;;
Packit 3ff1e7
esac])
Packit 3ff1e7
with_gnu_ld=$acl_cv_prog_gnu_ld
Packit 3ff1e7
])
Packit 3ff1e7
Packit 3ff1e7
dnl From libtool-1.4. Sets the variable LD.
Packit 3ff1e7
AC_DEFUN([AC_LIB_PROG_LD],
Packit 3ff1e7
[AC_ARG_WITH([gnu-ld],
Packit 3ff1e7
[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
Packit 3ff1e7
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
Packit 3ff1e7
AC_REQUIRE([AC_PROG_CC])dnl
Packit 3ff1e7
AC_REQUIRE([AC_CANONICAL_HOST])dnl
Packit 3ff1e7
# Prepare PATH_SEPARATOR.
Packit 3ff1e7
# The user is always right.
Packit 3ff1e7
if test "${PATH_SEPARATOR+set}" != set; then
Packit 3ff1e7
  echo "#! /bin/sh" >conf$$.sh
Packit 3ff1e7
  echo  "exit 0"   >>conf$$.sh
Packit 3ff1e7
  chmod +x conf$$.sh
Packit 3ff1e7
  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
Packit 3ff1e7
    PATH_SEPARATOR=';'
Packit 3ff1e7
  else
Packit 3ff1e7
    PATH_SEPARATOR=:
Packit 3ff1e7
  fi
Packit 3ff1e7
  rm -f conf$$.sh
Packit 3ff1e7
fi
Packit 3ff1e7
ac_prog=ld
Packit 3ff1e7
if test "$GCC" = yes; then
Packit 3ff1e7
  # Check if gcc -print-prog-name=ld gives a path.
Packit 3ff1e7
  AC_MSG_CHECKING([for ld used by GCC])
Packit 3ff1e7
  case $host in
Packit 3ff1e7
  *-*-mingw*)
Packit 3ff1e7
    # gcc leaves a trailing carriage return which upsets mingw
Packit 3ff1e7
    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
Packit 3ff1e7
  *)
Packit 3ff1e7
    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
Packit 3ff1e7
  esac
Packit 3ff1e7
  case $ac_prog in
Packit 3ff1e7
    # Accept absolute paths.
Packit 3ff1e7
    [[\\/]* | [A-Za-z]:[\\/]*)]
Packit 3ff1e7
      [re_direlt='/[^/][^/]*/\.\./']
Packit 3ff1e7
      # Canonicalize the path of ld
Packit 3ff1e7
      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
Packit 3ff1e7
      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
Packit 3ff1e7
        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
Packit 3ff1e7
      done
Packit 3ff1e7
      test -z "$LD" && LD="$ac_prog"
Packit 3ff1e7
      ;;
Packit 3ff1e7
  "")
Packit 3ff1e7
    # If it fails, then pretend we aren't using GCC.
Packit 3ff1e7
    ac_prog=ld
Packit 3ff1e7
    ;;
Packit 3ff1e7
  *)
Packit 3ff1e7
    # If it is relative, then search for the first ld in PATH.
Packit 3ff1e7
    with_gnu_ld=unknown
Packit 3ff1e7
    ;;
Packit 3ff1e7
  esac
Packit 3ff1e7
elif test "$with_gnu_ld" = yes; then
Packit 3ff1e7
  AC_MSG_CHECKING([for GNU ld])
Packit 3ff1e7
else
Packit 3ff1e7
  AC_MSG_CHECKING([for non-GNU ld])
Packit 3ff1e7
fi
Packit 3ff1e7
AC_CACHE_VAL([acl_cv_path_LD],
Packit 3ff1e7
[if test -z "$LD"; then
Packit 3ff1e7
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
Packit 3ff1e7
  for ac_dir in $PATH; do
Packit 3ff1e7
    test -z "$ac_dir" && ac_dir=.
Packit 3ff1e7
    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
Packit 3ff1e7
      acl_cv_path_LD="$ac_dir/$ac_prog"
Packit 3ff1e7
      # Check to see if the program is GNU ld.  I'd rather use --version,
Packit 3ff1e7
      # but apparently some GNU ld's only accept -v.
Packit 3ff1e7
      # Break only if it was the GNU/non-GNU ld that we prefer.
Packit 3ff1e7
      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
Packit 3ff1e7
      *GNU* | *'with BFD'*)
Packit 3ff1e7
        test "$with_gnu_ld" != no && break ;;
Packit 3ff1e7
      *)
Packit 3ff1e7
        test "$with_gnu_ld" != yes && break ;;
Packit 3ff1e7
      esac
Packit 3ff1e7
    fi
Packit 3ff1e7
  done
Packit 3ff1e7
  IFS="$ac_save_ifs"
Packit 3ff1e7
else
Packit 3ff1e7
  acl_cv_path_LD="$LD" # Let the user override the test with a path.
Packit 3ff1e7
fi])
Packit 3ff1e7
LD="$acl_cv_path_LD"
Packit 3ff1e7
if test -n "$LD"; then
Packit 3ff1e7
  AC_MSG_RESULT([$LD])
Packit 3ff1e7
else
Packit 3ff1e7
  AC_MSG_RESULT([no])
Packit 3ff1e7
fi
Packit 3ff1e7
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
Packit 3ff1e7
AC_LIB_PROG_LD_GNU
Packit 3ff1e7
])