Refactor the Makefile and add a configure script