build: use AM_PROG_AR conditionally

AM_PROG_AR does not exist in automake v0.11 but without it, you can't
build libuv with automake v0.12+ on Darwin.
test: fix fs_fstat test on sunos

The tests are no longer compiled with -D_XOPEN_SOURCE=500 when building
with autotools. Tell the test explicitly that SunOS systems are
expected to have nanosecond fstat(2) granularity.
test: fix fs_chown when running as root

chown(2) to root is expected to fail - unless you're root, of course.
test: fix spawn_setgid_fails and spawn_setuid_fails

Don't try to set a bogus UID or GID and expect to get a meaningful
error. The test expected EPERM but SunOS returns EINVAL because the
id is outside of the range of valid user/group ids.

Try to switch to UID/GID 0. Give up privileges first if we're root,
else the setuid/setgid system call will succeed when it's expected
to fail.
build: use AM_SILENT_RULES conditionally

It's not supported by older automake versions.