Swapped HAVE_LIBPTHREAD for HAVE_PTHREAD_H as nothing uses HAVE_LIBPTHREAD
Added if statement around if NO_THREADS should be defined or not.