configure: rework pthread handling to allow for user defined flags