fix computation of build directory paths

Not sure how I got away without running into this bug sooner.