Home | History | Annotate | Line # | Download | only in config
      1  1.1  christos 
      2  1.1  christos dnl Check if the target supports weak.
      3  1.1  christos AC_DEFUN([GCC_CHECK_ATTRIBUTE_WEAK], [
      4  1.1  christos   AC_CACHE_CHECK([whether the target supports weak],
      5  1.1  christos 		 ac_cv_have_attribute_weak, [
      6  1.1  christos   weakref_m4_saved_CFLAGS="$CFLAGS"
      7  1.1  christos   CFLAGS="$CFLAGS -Werror"
      8  1.1  christos   AC_TRY_COMPILE([void __attribute__((weak)) foo(void) { }],
      9  1.1  christos 		 [], ac_cv_have_attribute_weak=yes,
     10  1.1  christos 		 ac_cv_have_attribute_weak=no)
     11  1.1  christos   CFLAGS="$weakref_m4_saved_CFLAGS"])
     12  1.1  christos   if test x"$ac_cv_have_attribute_weak" = xyes; then
     13  1.1  christos     AC_DEFINE(HAVE_ATTRIBUTE_WEAK, 1,
     14  1.1  christos       [Define to 1 if the target supports __attribute__((weak)).])
     15  1.1  christos   fi])
     16  1.1  christos 
     17  1.1  christos dnl Check whether weak refs work like the ELF ones.
     18  1.1  christos dnl This means that the weak reference works without having to satify 
     19  1.1  christos dnl linkage for the item.
     20  1.1  christos dnl There are targets (at least Darwin) where we have fully functional
     21  1.1  christos dnl weakrefs at runtime, but must supply the referenced item at link time.
     22  1.1  christos AC_DEFUN([GCC_CHECK_ELF_STYLE_WEAKREF], [
     23  1.1  christos   AC_CACHE_CHECK([whether weak refs work like ELF],
     24  1.1  christos                   ac_cv_have_elf_style_weakref, [
     25  1.1  christos   weakref_m4_saved_CFLAGS="$CFLAGS"
     26  1.1  christos   case "${host}" in
     27  1.1  christos     *-apple-darwin*) CFLAGS="$CFLAGS -Wl,-undefined,dynamic_lookup" ;;
     28  1.1  christos     *) ;;
     29  1.1  christos   esac  
     30  1.1  christos   AC_RUN_IFELSE([AC_LANG_SOURCE([[
     31  1.1  christos extern void fNotToBeFound(void) __attribute__((weak));
     32  1.1  christos int main () 
     33  1.1  christos {
     34  1.1  christos   if (fNotToBeFound)
     35  1.1  christos     return 1;
     36  1.1  christos   else
     37  1.1  christos     return 0;
     38  1.1  christos }
     39  1.1  christos ]])], ac_cv_have_elf_style_weakref=yes, ac_cv_have_elf_style_weakref=no, [
     40  1.1  christos case "${host}" in
     41  1.1  christos   *-apple-darwin[[89]]*) ac_cv_have_elf_style_weakref=no ;;
     42  1.1  christos   *) ac_cv_have_elf_style_weakref=yes;;
     43  1.1  christos esac])CFLAGS="$weakref_m4_saved_CFLAGS"])
     44  1.1  christos if test x"$ac_cv_have_elf_style_weakref" = xyes; then
     45  1.1  christos   AC_DEFINE(HAVE_ELF_STYLE_WEAKREF, 1, [Define to 1 if target has a weakref that works like the ELF one.])
     46  1.1  christos fi])
     47  1.1  christos 
     48