Add a main function

This finally makes the whole thing link.
Add build system

We use Waf. This was a pain to set up.