configure: improve detection of out-of-tree builds