I looked at many posts about the use of latexmk, but wasn't able to find what to write in order to satisfy my requirements. Yet I'm sure it is possible, but my skills in Perl amounts to about nothing.
What I would like to do with a file, say mymainfile.tex:
make a format file including the static part of the preamble, named
mymainfile-xelatex.fmtif I usexelatex, and store it in thefmt/ subdirectoryof the directory that containsmymainfile.tex(I can do that just withmylatexformat)regenerate the format if the (static part of the) preamble has changed (loading new packages, defining new commands or modifying existing commands).
Compiling
mymainfile.texwith the customised format file.
The difficulty for me is point 2), and possibly point 1) — that is, not having to write a first macro to make the format, and the launching latexmk, but preferably that everything be done from latexmk.
Moreover I prefer not to write the static part of the preamble in a separate file, but keep it in mymainfile.tex as usual, and use the \endofdump command from the mylatexformat package
I use MiKTeX 2.9 on WinEdt 7.
\jobnamehaving the wrong value in the static preamble. (Maybe the format name can be renamed after the build, haven't tried.)