Rework library detection in configure.ac Migrate to AC_CHECK_LIB and AC_SEARCH_LIBS. Don't pollute CPPFLAGS, LDFLAGS and LIBS.