s3: fix detection and flags for using pthread