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