configure.ac: rework/fix the NEEDS_RESOLV and NEEDS_LIBGEN tests