Improved makefile by adding more generality
Horribly big commit containing todays work on this.