configure.in: Better pthread test

Some operating systems have pthread in the default libraries,
and hence no libpthread proper. Haiku is one of them.

So instead of only searching for sem_open in libpthread,
we use AC_SEARCH_LIBS which first tries without any lib,
then each listed library.

A more correct test would use ACX_PTHREAD.
Fix the network libraries test

The existing test would never work anyway, as AC_CHECK_FUNC would
only check for a function named "socket bind listen inet_ntop".

Instead we use AC_SEARCH_LIBS which tests first without any library,
then iterates over the provided libraries list.

We list the traditionally searched libs, and libnetwork for Haiku
(which must be checked for before libsocket).
configure.in: test for errx(), optionally in libbsd

Haiku requires -lbsd for errx and warnx.