Autotools

Could we integrate the following changes into the upstream repository?
Most of these changes replace the old Makefile based build system with the GNU autotools build system.

Also commit b973cd6 should fix a potential bug in the graphics library.