Add autoconf checks for pthreads; fix #340