The latexmk program allows to automatically run
latex and related commands as many times as needed to build the final document. It is an alternative or complement to Makefiles or similar functionality of integrated LaTeX editors.
See the manpage for more information.
There is a similar tool named LaTeX-Mk, which yet is distinct from latexmk.