Home | History | Annotate | Download | only in m4
      1 #
      2 # Get the linker version string.
      3 #
      4 # This macro is specific to LLVM.
      5 #
      6 AC_DEFUN([AC_LINK_GET_VERSION],
      7   [AC_CACHE_CHECK([for linker version],[llvm_cv_link_version],
      8   [
      9    version_string="$(${LD:-ld} -v 2>&1 | head -1)"
     10 
     11    # Check for ld64.
     12    if (echo "$version_string" | grep -q "ld64"); then
     13      llvm_cv_link_version=$(echo "$version_string" | sed -e "s#.*ld64-\([^ ]*\)\( (.*)\)\{0,1\}#\1#")
     14    else
     15      llvm_cv_link_version=$(echo "$version_string" | sed -e "s#[^0-9]*\([0-9.]*\).*#\1#")
     16    fi
     17   ])
     18   AC_DEFINE_UNQUOTED([HOST_LINK_VERSION],"$llvm_cv_link_version",
     19                      [Linker version detected at compile time.])
     20 ])
     21 
     22 #
     23 # Determine if the system can handle the -R option being passed to the linker.
     24 #
     25 # This macro is specific to LLVM.
     26 #
     27 AC_DEFUN([AC_LINK_USE_R],
     28 [AC_CACHE_CHECK([for compiler -Wl,-R<path> option],[llvm_cv_link_use_r],
     29 [ AC_LANG_PUSH([C])
     30   oldcflags="$CFLAGS"
     31   CFLAGS="$CFLAGS -Wl,-R."
     32   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
     33     [llvm_cv_link_use_r=yes],[llvm_cv_link_use_r=no])
     34   CFLAGS="$oldcflags"
     35   AC_LANG_POP([C])
     36 ])
     37 if test "$llvm_cv_link_use_r" = yes ; then
     38   AC_DEFINE([HAVE_LINK_R],[1],[Define if you can use -Wl,-R. to pass -R. to the linker, in order to add the current directory to the dynamic linker search path.])
     39   fi
     40 ])
     41 
     42 #
     43 # Determine if the system can handle the -rdynamic option being passed
     44 # to the compiler.
     45 #
     46 # This macro is specific to LLVM.
     47 #
     48 AC_DEFUN([AC_LINK_EXPORT_DYNAMIC],
     49 [AC_CACHE_CHECK([for compiler -rdynamic option],
     50                 [llvm_cv_link_use_export_dynamic],
     51 [ AC_LANG_PUSH([C])
     52   oldcflags="$CFLAGS"
     53   CFLAGS="$CFLAGS -rdynamic"
     54   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
     55     [llvm_cv_link_use_export_dynamic=yes],[llvm_cv_link_use_export_dynamic=no])
     56   CFLAGS="$oldcflags"
     57   AC_LANG_POP([C])
     58 ])
     59 if test "$llvm_cv_link_use_export_dynamic" = yes ; then
     60   AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -rdynamic.])
     61   fi
     62 ])
     63 
     64 #
     65 # Determine if the system can handle the --version-script option being
     66 # passed to the linker.
     67 #
     68 # This macro is specific to LLVM.
     69 #
     70 AC_DEFUN([AC_LINK_VERSION_SCRIPT],
     71 [AC_CACHE_CHECK([for compiler -Wl,--version-script option],
     72                 [llvm_cv_link_use_version_script],
     73 [ AC_LANG_PUSH([C])
     74   oldcflags="$CFLAGS"
     75 
     76   # The following code is from the autoconf manual,
     77   # "11.13: Limitations of Usual Tools".
     78   # Create a temporary directory $tmp in $TMPDIR (default /tmp).
     79   # Use mktemp if possible; otherwise fall back on mkdir,
     80   # with $RANDOM to make collisions less likely.
     81   : ${TMPDIR=/tmp}
     82   {
     83     tmp=`
     84       (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
     85     ` &&
     86     test -n "$tmp" && test -d "$tmp"
     87   } || {
     88     tmp=$TMPDIR/foo$$-$RANDOM
     89     (umask 077 && mkdir "$tmp")
     90   } || exit $?
     91 
     92   echo "{" > "$tmp/export.map"
     93   echo "  global: main;" >> "$tmp/export.map"
     94   echo "  local: *;" >> "$tmp/export.map"
     95   echo "};" >> "$tmp/export.map"
     96 
     97   CFLAGS="$CFLAGS -Wl,--version-script=$tmp/export.map"
     98   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
     99     [llvm_cv_link_use_version_script=yes],[llvm_cv_link_use_version_script=no])
    100   rm "$tmp/export.map"
    101   rmdir "$tmp"
    102   CFLAGS="$oldcflags"
    103   AC_LANG_POP([C])
    104 ])
    105 if test "$llvm_cv_link_use_version_script" = yes ; then
    106   AC_SUBST(HAVE_LINK_VERSION_SCRIPT,1)
    107   fi
    108 ])
    109 
    110