- AC_TRY_LINK(PSI_INCLUDES, [
- void (*fn)(void) = (void (*)(void)) $psi_symbol; (*fn)()
- ], [
- psi_symbol_redirect=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
- ])
- [psi_cv_fn_]PSI_VAR_NAME($1)=$psi_symbol_redirect
+ for lib in "" $4; do
+ decl_save_LIBS=$LIBS
+ LIBS=$lib
+ AC_TRY_LINK(PSI_INCLUDES, [
+ void (*fn)(void) = (void (*)(void)) $psi_symbol; (*fn)()
+ ], [
+ psi_symbol_redirect=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
+ ])
+ LIBS=$decl_save_LIBS
+
+ if test -n "$psi_symbol_redirect"; then
+ if test -n "$lib"; then
+ psi_decl_check="$psi_symbol_redirect in $lib"
+ else
+ psi_decl_check="$psi_symbol_redirect"
+ fi
+ break
+ fi
+ done
+ [psi_cv_fn_]PSI_VAR_NAME($1)=$psi_decl_check