Use -pthread for configuration too

This is necessary for some thread-related configuration tests to do
the right thing in some cases (and in general it's desirable for
configuration to use an environment similar the actual build).