Autotools

Complete rewrite of the build system using autotools.