Switch to autotools to avoid maintaining ugly Makefile platform hacks.

The existing approach does not work on AIX (and possibly others).