[CI] Fix a bug where CI scripts are not able to build in directories that are not one level below the project root
Summary: See title.
Test Plan:
BUILD_DIR=<toplevel>/build/nestedbuild ./contrib/devtools/build_cmake.sh BUILD_DIR=<toplevel>/build/nestedbuild ./contrib/devtools/build_autotools.sh
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D6718