Fix build script for nested directories