out of tree builds

This is a first pass at out-of-tree builds. It builds, but the TOC isn't getting written out correctly. I'd love some advice on how to modify this so that it's easier, @aturon . "Hacky" is... charitable.
This may be part of the problem -- IIRC these were supposed to be relative to the src root because they're also used for writing out the target.