Running pdflatex ONCE on
\documentclass{elsarticle}%%% version 3.1 from CTAN
\begin{document}
\begin{frontmatter}
\author[1]{Johann Sebastian Bach}
\author[2]{Ludwig van Beethoven\corref{cor2}}
\cortext[cor2]{Corresponding author}%
\address[1]{Thomaskirche, Leipzig}
\address[2]{Zentralfriedhof Wien}
\end{frontmatter}
\end{document}
produces the following output:
As you see, the labels of both authors are 1, and the superscript star after Mr. Beethoven is missing. You need the second run of pdflatex to correct this issue.
However, running pdflatex ALWAYS at least twice is not what you want: it eats up your time, especially on large papers, whereas running pdflatex once might sometimes suffice if the right .aux files are available from a prior run. I looked into the .log file and the console output in an attempt to discover some hints on whether a second rerun is needed, but I could not find anything usable. My prior approach to checking whether a rerun is needed is saying something like
MESSAGE_FOR_RERUN := '(LaTeX Warning: Label\(s\) may have changed\. Rerun to get cross\-references right\.)|(LaTeX Warning: There were undefined references\.)|(LaTeX Warning: Citation [^[:cntrl:]]* on page [0-9]* undefined on)|(Package natbib Warning: There were undefined citations\.)|(\(mparhack\) *Rerun to get them right\.)'
in the beginning of a makefile and
for i in $(SOURCES); do \
$(PDFLATEX) $$i ; \
done
if (egrep $(MESSAGE_FOR_RERUN) $(OBJECTS)); then \
for i in $(SOURCES); do $(PDFLATEX) $$i ; done; \
fi
(where the variables are defined appropriately) in a rule of the makefile. (Of course, in a non-MWE, you might also need to run some choice of sed, awk, rm, bibtex, bibtex8, biber, makeglossaries, makeindex, xindy, dvi2ps, zip, chmod or god-knows-what in addition, but such details on other programs are all off-topic here.)
Of course, you can have latexmk or \usepackage[mainaux]{rerunfilecheck} do the job, but I wonder: can you continue doing it the previous way via makefiles, and if so, which string to search for in the log files?

arara. It has a lot of tools to automate. – Sigur Mar 14 '19 at 02:01.logfile parsing alone can not be guaranteed to be enough to detect necessary reruns. The code you show here is a prime example of that. The only difference in the.logfile between the two runs (on a clean directory) is the absence of the.aux(and.spl, no idea what that does) in the first run. You could detect the relevant message (No file <\jobname>.aux.) and rerun if it is found, that might give you false positives if the.auxfile is not used for anything, but you can probably live with that. Now suppose you have run your document once or twice and the.auxis present ... – moewe Mar 14 '19 at 06:48\address. So you add\author[3]{...}and\address[3]{...}. You compile once to get a "1" for the their footnote instead of "c". The .log is identical (except for time and date and memory usage info) to the previous run. But still you need another run for the marker come out as "c". In this situation no amount of.logparsing can help you. It would have helped to compare the.auxfiles since they differ. IIRClatexmkactually compares all.aux-like files and reruns LaTeX and friends until they are stable... – moewe Mar 14 '19 at 07:07rerunfilecheckwould be step in the same direction and you could parse its.logmessages and act accordingly, so I think this would even fit your requirement of being able to continue using makefiles. Just search forPackage rerunfilecheck Warning: File ... has changed. Rerun.– moewe Mar 14 '19 at 07:08