Massaging the build process

Preparing ground for further work on build scripts.
I'm not aware of how to get a here-document to work as intended with indented text: bash is looking for "EOF" to terminate the stream, but that won't match with "  EOF". I'll look into this some more.