hds: Enable tuning of v4 vs v5

By default we write v4 files but this can be adjusted either
by setting the HDS_VERSION5 environment variable to a positive
integer or else setting the VERSION5 tuning parameter.
hds: Refactor the wrapper generation code

Now use code refs rather than a long-winded if-then-else that
had got out of control.
hds: Add code generation warning to top of hds_select.c