autotools: add libpthread checks

For using libpthread we need special flags. So check and use them.