Tweak test associated with HAVE_LIBIEEE and find library only if needed
Tweak HAVE_LIBRESOLV test and find the library only if needed
Fix style of HAVE_BROKEN_{POSIX_SEMAPHORES/PTHREAD_SIGMASK} cmakedefine
Fix test associated with HAVE_EPOLL by checking for the correct function.
Fix POSIX_SEMAPHORES_NOT_ENABLED and HAVE_BROKEN_SEM_GETVALUE test

The double quote were not escaped and the check state was poped to early
which was preventing the threading library from being associated
with the test.
Tweak test associated with thread and set _REENTRANT when appropriate.