A few enhancments to the new makefile infrastructure

I did some work on the new makefile stuff discussed on the mailing list. See the commit message for exactly what.

I started trying to update some of the examples that used this, but couldn't get them to build; they seemed to be referencing a directory not in the source tree, unless I'm mistaken. The diff for those is here:

https://gist.github.com/zenhack/8167562

I didn't want to start committing changes to code I can't run, but I did try this on a small example of my own.