With the following Makefile, GNU make runs the two commands in parallel. Since the first one takes time to finish, rm *.log
is run before the log
file is created, and fails.
dummy.pdf: dummy.tex
tex dummy.tex &> /dev/null;
rm *.log
The file dummy.tex
one line: \bye
(a short empty file for TeX). Replacing tex dummy.tex
by any other command shows the same behaviour. Removing &> /dev/null
would of course solve the problem, but it is not a very good option in my case, since the Makefile is provided by a third party.
Is it possible to prevent GNU make from doing anything in parallel? (the flag -j 1
does not help).
EDIT: output to the terminal:
bruno@bruno-laptop:~/LaTeX/make-experiment$ make
tex dummy.tex &> /dev/null;
rm *.log
rm: cannot remove `*.log': No such file or directory
make: *** [dummy.pdf] Error 1
bruno@bruno-laptop:~/LaTeX/make-experiment$ This is TeX, Version 3.1415926 (TeX Live 2009/Debian)
(./dummy.tex )
No pages of output.
Transcript written on dummy.log.
Best Answer
Actually, you don't have a problem with make, but with your command:
Runs 'tex' in the background. You don't need to remove '>/dev/null', but '&' is sending 'tex' to the background.
Try this, it must be fine for you:
or run everything in the same subshell, like this:
or less sane, this:
PD: &> is an extension provided by some shells (including bash) to redirect both stdout and stderr to the same destination, but it's not portable, you should use '>/dev/null 2>&1' instead. (Thanks @Gilles)
Cheers