[texhax] Makefile dependencies for complex documents

Piotr Zielinski Piotr.Zielinski at cl.cam.ac.uk
Mon Mar 22 22:32:29 CET 2004


The problem of using make to compile latex documents has been
discussed here before, but the only solutions I know of (latexmake,
latexmk, texi2dvi) are basically designed to run
latex/bibtex/makeindex sufficiently many times to resolve all
_internal_ dependencies of a latex document.  I am after automatic
generation of a Makefile with _external_ dependencies, such as files
included by \includegraphics, \input, etc.

A little internet search revealed that there is a program called
makelatex, which generates these dependencies. However, it does this
by scanning the input file and all files that are explicitly included
with the \input command.  This approach works with simple cases but
fails, for example, when the input command is hidden inside a macro.

I think, the better way would be to redefine \input so that it would
write the name of the file-to-be-included to a special auxiliary file,
say \jobname.dep.  This file would then be processed by another
program, which would resolve all file names and produce a proper
Makefile entry.

So far, I haven't found anything like this, so I've written a couple
of tex macros and a very crude filename resolution program.  Because
this program currently looks for files only in the current directory,
I haven't redefined \input yet.  Instead, macro \dep used in front of
\input causes the latter command to log the filename into

\expandafter\ifx\csname dep\endcsname\relax

I'm looking for comments, esp. about how to write a file-name
resolution program that would work in most cases (i.e., that would
search not only the current directory but also the texmf tree).  Any
suggestions for improving the above piece of code are also welcome
(I'm not really an experienced tex programmer and don't know much
about latex internals, which would probably make the code simpler).


More information about the texhax mailing list