Add autogen.sh to the project and fix other build related issues