Toplevel Makefile refactoring

This patch allows to only build a particular project: for example `make libextensions` or `make testcpp`, and it only compiles the useful dependencies.