Convert Erlang build steps to tools.mk.

This will help with the automated builds, specifically it adds appropriate `dialyzer` and `xref` targets.

NB: you *should* see this branch failing. There are lots of dialyzer warnings and xref has not been tuned.