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