Autotools

Could we integrate the following changes into the upstream repository?
Most of these changes replace the old Makefile based build system to the GNU autotools build system.

Also commit b973cd6 (Fix conditionals in src/graphics/graphics.cpp) should fix a potential bug in the graphics library.