build: add -pthread to default compiler and linker flags

Suggested by @kneo and @stefan-langenmaier at about the same time.