build system: do not rely on ENV variables, pass root directory as a parameter, fix specs