Fix build dir detection