fix various build issues and allow to pass in path to mongodb build tree.