More general -pthread handling.