weakref.m4 1.7 KB

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