Switch to autotools to avoid maintaining ugly Makefile platform hacks.

The existing approach does not work on AIX (and possibly others).
Fix tests on esoteric platforms where gmake is a better choice.