Building out-of-tree targets

I'm writing a backend, and trying to build it outside of the source
tree so that it can be compiled without having all of the llvm source.
I've noticed that the list of AsmPrinters and Targets are generated at
config time, so I've written a chunk of __attribute__((constructor))
code that registers the printers and targets when the DSO is loaded.
Is this the right way to do this, or is there some piece I'm missing
out on?