Fix building of external libraries in build system