TS-1717: static library build fails with duplicate symbols

Fix the static build as much as possible. Add common plugin build
variables so we don't repeat automake fragments everywhere.