functions/export, export/*, export.sh: refactor; move build tree exporting code to this project.