Add a release script

The Makefiles were mostly filled with a complex shell script written in
m4sh. Moving that out into a separate script helps debugging and
compatibility, and in general makes life better.