autotools: Rewrite the build targets to use automake and libtool properly.