[configure.ac] Fix configure checks for Mono.Native (#13395)
When the configure checks were ported from configure.cmake in corefx
a couple of mistakes happened:
- Using AC_TRY_COMPILE instead of AC_TRY_LINK:
CMake's check_c_source_compiles() function compiles *and* links while
AC_TRY_COMPILE only does the former. This hides potential linking issues
which should fail the configure check.
- Using CFLAGS="-Werror -W....":
This works in CMake but autoconf always appends the previously defined
CFLAGS and since we set e.g. `-Wno-undefined` some configure checks
would fail due to an unrelated warning being treated as an error.
We need to only promot specific warnings to errors instead.
While looking at this I also found that we were setting CFLAGS after
we already AC_SUBST() it, we need to do this very close to the end of configure.ac.
Moved some code into that last block.
Finally, Android has special cases for sendfile and arc4random_buf where
they're defined in the header but aren't actually there for certain API profiles.
For now we disable arc4random_buf on Android and add a special check for sendfile.
* Fix sendfile with 6 parameters being misdetected
We need to make sure to actually prevent the implicit prototype since
in this case sendfile with different set of parameters actually exists
so the linker wouldn't fail.
Also fixed a few other cases of wrong configure checks due to missing headers.
* Move GSS checks into the Mono.Native checks section
This allows us to have a 1:1 mapping of the checks from configure.cmake