TS-1768: prefer AC_SEARCH_LIBS to AC_CHECK_LIB

AC_SEARCH_LIB should be preferred to AC_CHECK_LIB because the former
does not link the library under test the symbol is already present.
AC_SEARCH_LIBS conveniently appends the library to LIBS which makes
the Makefile.am simpler.

Unfortunately, our check for libresolv depends on the AC_CHECK_LIB
behavior. I didn't change this because the extensive use of macros
to rename API in libresolv makes the configuration tests more complex
that I wanted to deal with in this bug.
TS-1879: make Ptr conversion constructor explicit
TS-1872: minor cleanup to compiler flag handling

  - Prefer AS_IF to the case statement.
  - Test for directories before adding them to the linker path.
  - Error out if we are building on Darwin with a non-clang compiler.
  That's almost certainly an ancient version of gcc that won't work.