build: use -pthread on sunos

When building on sunos with autoconf make sure to specify -pthread
otherwise there will be race conditions with errno and etc