shiblon / latex-makefile

A Makefile for LaTeX - drop it in, type make, and magic happens.
Other
186 stars 30 forks source link

Makefile should consider mtime and not rebuild with LaTeX every time #104

Closed shiblon closed 8 years ago

shiblon commented 8 years ago

Originally reported on Google Code with ID 91

Description of the problem:

  The makefile is supposed to check for input file mtime
  before calling any generation rule.

  This test case examine an incorrect behaviour.

  The makefile is called several times and each time
  the generation rules are launched. Input file does 
  not change.

Platform:

  Debian Lenny i386

Short test case:

  Download attached file and put it there: /tmp/toto.tex

$ cd /tmp

$ export TERM=dumb # to prevent colors in output

$ alias umake='make -f {path to uber Makefile}/Makefile'

$ umake
NOTE: You may ignore warnings about the following files:

     toto.d

{path to uber Makefile}/Makefile:2220: toto.d: Aucun fichier ou répertoire de ce type
= toto.tex --> toto.d toto.pdf.1st.make (0-1) =
Success!  Wrote 1 page, 12037 bytes to toto.pdf

$ umake
= toto.tex --> toto.d toto.pdf.1st.make (0-1) =
Success!  Wrote 1 page, 12037 bytes to toto.pdf

$ umake
= toto.tex --> toto.d toto.pdf.1st.make (0-1) =
Success!  Wrote 1 page, 12037 bytes to toto.pdf

$ umake
= toto.tex --> toto.d toto.pdf.1st.make (0-1) =
Success!  Wrote 1 page, 12037 bytes to toto.pdf

$ umake VERBOSE=1
echo "= toto.tex --> toto.d toto.pdf.1st.make (0-1) ="
= toto.tex --> toto.d toto.pdf.1st.make (0-1) =
\
    pdflatex --interaction=batchmode --recorder toto.tex > /dev/null || :; \
    cp -f 'toto.log' 'toto.0-1.log'; \
    if egrep -q ' LaTeX Error: File .*\.dot_t.* not found' toto.log; then echo "Missing
dot_t file(s)"; echo "Please run"; echo "  make all-dot2tex"; echo "before proceeding.";
exit 1; fi; \
    if [ ! -e 'toto.aux' ]; then sed -e '$ b para' -e '/^$/b para' -e 'H' -e 'd' -e ':para'
-e 'x' -e '/^$/d' -e 's/^\n*//' -e '/^! LaTeX Error: File /{' -e '  s/^/::DOUBLE_PARAGRAPH::/'
-e '  h' -e '  d' -e '}' -e 's/^::DOUBLE_PARAGRAPH:://' -e '/could not locate the file
with any of these extensions:/d' -e '/Missing .begin.document/{' -e '  h' -e '  s/.*/Are
you trying to build an include file?/' -e '  x' -e '  G' -e '}' -e '/ LaTeX Error:
Cannot determine size/d' -e 's/.* LaTeX Error .*/&/p' -e 's/Error: pdflatex (file .*/&
- try specifying it without an extension/p' -e '/.*\*hyperref using.*driver \(.*\)\*.*/{'
-e '  s//\1/' -e '  /^hpdf.*$/!{' -e '    s/.*//' -e '    p' -e '    s/.*/--- Using
incorrect driver for hyperref! ---/' -e '    p' -e '    s/.*/Using pdflatex: specify
pdftex in the hyperref options (or leave it blank)./' -e '    p' -e '  }' -e '  d'
-e '}' -e '/ LaTeX Error: Unknown graphics extension/{' -e '  s/^/     /' -e '  h'
-e '  s/.*/--- Graphics extension error:/' -e '  G' -e '  h' -e '  s/.*/--- If you
specified the extension explicitly in your .tex file, try removing it./' -e '  H' -e
'  g' -e '  s/.*/&/' -e '  p' -e '  s/.*//' -e '  h' -e '  b' -e '}' -e 's/.*\(\n\{2,\}![[:space:]][^[:space:]]*[[:space:]]Error
.*\)/\1/p' -e 'd' toto.log; exit 1; fi; \
    sed -e '/\\@input{\(.*\)}/{' -e     's//\1/' -e     's![.:]!\\&!g' -e     'h' -e 
   's!.*!\\:\\\\@input{&}:{!' -e     'p' -e     'x' -e     's/\\././g' -e     's/.*/r
&/p' -e     's/.*/d/p' -e     's/.*/}/p' -e     'd' -e '}' -e 'd' 'toto.aux' > "toto.aux.$$.sed.make";
sed -f "toto.aux.$$.sed.make" 'toto.aux' > "toto.aux.$$.make"; sed -e '/^\\relax/d'
-e '/^\\bibcite/d' -e 's/^\(\\newlabel{[^}]\{1,\}}\).*/\1/' "toto.aux.$$.make" | sort
> 'toto.aux.make'; rm -f toto.aux.$$.make toto.aux.$$.sed.make; \
    echo "# vim: ft=make" > toto.d; \
    echo ".PHONY: toto._graphics" >> toto.d; \
    sed -e '/^INPUT/!d' -e 's!^INPUT \(\./\)\{0,1\}!!' -e 's/[[:space:]]/\\ /g' -e 's/\(.*\)\.aux$/\1.tex/'
-e '/\.tex$/b addtargets' -e '/\.cls$/b addtargets' -e '/\.sty$/b addtargets' -e '/\.pstex_t$/b
addtargets' -e '/\.dot_t$/b addtargets' -e 'd' -e ':addtargets' -e 's/^/toto.aux toto.aux.make
toto.d toto.pdf: /' toto.fls | sort | uniq >> toto.d; \
    sed -e '$ b para' -e '/^$/b para' -e 'H' -e 'd' -e ':para' -e 'x' -e '/^$/d' -e 's/^\n*//'
-e '/^! LaTeX Error: File /{' -e '  s/^/::DOUBLE_PARAGRAPH::/' -e '  h' -e '  d' -e
'}' -e 's/^::DOUBLE_PARAGRAPH:://' -e '/Default extension: /!d' -e 's/[[:space:]]\{1,\}/
/g' -e 's/\n\{1,\}/ /g' -e 's/^.*File `//' -e 's/'"'"' not found\..*//' -e '/\.tex/!s/$/.tex/'
-e 's/[[:space:]]/\\ /g' -e 'h' -e 's/.*/# MISSING input "&" - (presence of comment
affects build)/' -e 'p' -e 's/.*//' -e 'x' -e 's/^/toto.aux toto.aux.make toto.d toto.pdf:
/' toto.log | sort | uniq >> toto.d; \
    echo ".SECONDEXPANSION:" >> toto.d; \
    sed -e '$ b para' -e '/^$/b para' -e 'H' -e 'd' -e ':para' -e 'x' -e '/^$/d' -e 's/^\n*//'
-e '/^! LaTeX Error: File `/{' -e '  s/^/::DOUBLE_PARAGRAPH::/' -e '  h' -e '  d' -e
'}' -e 's/^::DOUBLE_PARAGRAPH:://' -e '/could not locate the file with any of these
extensions:/{' -e '  s/\n\{1,\}/ /g' -e '  s/[[:space:]]\{1,\}/ /g' -e '  s/^.*File
`//' -e '  s/'"'"' not found\..*//' -e '  h' -e '  s/.*/# MISSING stem "&" - (presence
of comment affects build)/' -e '  p' -e '  g' -e '  b addtargets' -e '}' -e '/.*File:
\(.*\) Graphic file (type [^)]*).*/{' -e '  s//\1/' -e '  b addtargets' -e '}' -e 'd'
-e ':addtargets' -e 's/[[:space:]]/\\\\\\&/g' -e 'h' -e 's/.*/-include &.gpi.d/' -e
'p' -e 'g' -e 's/.*/toto.d: $$(call graphics-source,&)/' -e 'p' -e 's/.*//' -e 'x'
-e 's/.*/toto.pdf toto._graphics: $$(call graphics-target,&)/' -e 'p' -e 'd' toto.log
>> toto.d; \
    sed -e 's/^No file \(.*\.ind\)\.$/TARGETS=\1/' -e 's/^No file \(.*\.[gn]ls\)\.$/TARGETS=\1/'
-e 's/[[:space:]]/\\&/g' -e '/^TARGETS=/{' -e '  h' -e '  s/^TARGETS=/toto.d toto.aux
toto.aux.make: /p' -e '  g' -e '  s/^TARGETS=\(.*\)/\1: toto.tex/p' -e '}' -e 'd' 'toto.log'
| sort | uniq >> toto.d; \
    sed -e '/^\\bibdata/!d' -e 's/\\bibdata{\([^}]*\)}/\1,/' -e 's/,\{2,\}/,/g' -e 's/[[:space:]]/\\&/g'
-e 's/,/.bib /g' -e 's/ \{1,\}$//' toto.aux.make | xargs kpsewhich '#######' | sed
-e 's/^/toto.bbl toto.aux toto.aux.make: /' | \sort | uniq >> toto.d; \
    egrep -q "# MISSING" toto.d && sleep 1 && rm -f toto.pdf; \
    [ -e 'toto.pdf' ] && mv -f 'toto.pdf' 'toto.pdf.1st.make'; \
    for s in toc out lot lof lol nav; do \
        if [ -e "toto.$s" ]; then \
            if ! diff -q toto.$s toto.$s.make >/dev/null 2>&1; then \
                touch toto.run.cookie; \
            fi; \
            cp -f toto.$s toto.$s.make; \
        fi; \
    done
\
    sed -e '/^\\newlabel/d' toto.aux.make > toto.auxbbl.make.temp; \
    ! diff -q 'toto.auxbbl.make.temp' 'toto.auxbbl.make' >/dev/null 2>&1 && mv -f 'toto.auxbbl.make.temp'
'toto.auxbbl.make' || :
\
     \
    if egrep -q 'bibstyle.(apacann|chcagoa|[^}]*annot)' 'toto.aux'; then \
        echo "= ** annotated extra latex ** --> output ignored (0-1) ="; \
        pdflatex --interaction=batchmode  toto > /dev/null; \
        cp -f 'toto.log' 'toto.0-annotated.log'; \
         \
        echo "= ** annotated extra latex ** --> output ignored (0-2) ="; \
        pdflatex --interaction=batchmode  toto > /dev/null; \
    fi
\
    fatal=`sed -e '$ b para' -e '/^$/b para' -e 'H' -e 'd' -e ':para' -e 'x' -e '/^$/d'
-e 's/^\n*//' -e '/^! LaTeX Error: File /{' -e '  s/^/::DOUBLE_PARAGRAPH::/' -e ' 
h' -e '  d' -e '}' -e 's/^::DOUBLE_PARAGRAPH:://' -e '/could not locate the file with
any of these extensions:/d' -e '/Missing .begin.document/{' -e '  h' -e '  s/.*/Are
you trying to build an include file?/' -e '  x' -e '  G' -e '}' -e '/ LaTeX Error:
Cannot determine size/d' -e 's/.* LaTeX Error .*/&/p' -e 's/Error: pdflatex (file .*/&
- try specifying it without an extension/p' -e '/.*\*hyperref using.*driver \(.*\)\*.*/{'
-e '  s//\1/' -e '  /^hpdf.*$/!{' -e '    s/.*//' -e '    p' -e '    s/.*/--- Using
incorrect driver for hyperref! ---/' -e '    p' -e '    s/.*/Using pdflatex: specify
pdftex in the hyperref options (or leave it blank)./' -e '    p' -e '  }' -e '  d'
-e '}' -e '/ LaTeX Error: Unknown graphics extension/{' -e '  s/^/     /' -e '  h'
-e '  s/.*/--- Graphics extension error:/' -e '  G' -e '  h' -e '  s/.*/--- If you
specified the extension explicitly in your .tex file, try removing it./' -e '  H' -e
'  g' -e '  s/.*/&/' -e '  p' -e '  s/.*//' -e '  h' -e '  b' -e '}' -e 's/.*\(\n\{2,\}![[:space:]][^[:space:]]*[[:space:]]Error
.*\)/\1/p' -e 'd' toto.log`; \
    if [ x"$fatal" != x"" ]; then \
        echo "$fatal"; \
        exit 1; \
    fi; \
    sed -e '/^\\newlabel/!d' toto.aux.make > toto.auxtarget.cookie; \
    run=0; \
    for i in 1; do \
        if [ -e 'toto.bbl.cookie' ]; then \
            run=1; \
            break; \
        fi; \
        if [ -e 'toto.run.cookie' ]; then \
            run=1; \
                break; \
        fi; \
        if [ -e 'toto.auxtarget.make' ] && ! diff -q 'toto.auxtarget.cookie' 'toto.auxtarget.make'
>/dev/null 2>&1;\
        then \
            run=1; \
            break; \
        fi; \
        if sed -e '/^No file toto\.aux\./d' toto.log | egrep -q '^(.*Rerun .*|No file toto\.[^.]+\.|No
file .+\.tex\.|LaTeX Warning: File.*)$'; then \
            run=1; \
            break; \
        fi; \
    done; \
    rm -f toto.bbl.cookie toto.run.cookie; \
    mv -f toto.auxtarget.cookie toto.auxtarget.make; \
    if [ x"$run" = x"1" ]; then \
        :; \
        for i in 2 3 4 5; do \
             echo "= toto.tex --> toto.pdf (0-$i) =" ; \
            pdflatex --interaction=batchmode  toto > /dev/null; \
            cp -f 'toto.log' 'toto.'0-$i'.log'; \
            egrep -q '^(.*Rerun .*|No file toto\.[^.]+\.)$' toto.log || break; \
        done; \
    else \
        mv -f 'toto.pdf.1st.make' 'toto.pdf'; \
    fi; \
    if [ -d '_out_/' ]; then if cp -f 'toto.pdf' '_out_/'; then echo "Copied 'toto.pdf'
to '_out_/'"; else echo "Failed to copy 'toto.pdf' to '_out_/'"; fi; fi; \
    sed -e '${' -e '  /^$/!{' -e '    H' -e '    s/.*//' -e '  }' -e '}' -e '/^$/!{' -e
'  H' -e '  d' -e '}' -e '/^$/{' -e '  x' -e '  s/^\n//' -e '  /Output written on /{'
-e '    s/.*Output written on \([^(]*\) (\([^)]\{1,\}\)).*/Success!  Wrote \2 to \1/'
-e '    s/[[:digit:]]\{1,\}/&/g' -e '    s/Success!/&/g' -e '    s/to \(.*\)$/to \1/'
-e '    b end' -e '  }' -e '  / *LaTeX Error:.*/{' -e '    s/.*\( *LaTeX Error:.*\)/\1/'
-e '    b end' -e '  }' -e '  /.*Warning:.*/{' -e '    s//&/' -e '    b end' -e ' 
}' -e '  /Underfull.*/{' -e '    s/.*\(Underfull.*\)/\1/' -e '    b end' -e '  }' -e
'  /Overfull.*/{' -e '    s/.*\(Overfull.*\)/\1/' -e '    b end' -e '  }'  -e '  :end'
-e '  G' -e '}'  toto.log
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) (format=pdflatex 2010.6.28)
 23 JUL 2010 18:53
entering extended mode
 %&-line parsing enabled.
**toto.tex
(./toto.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, ukrainian, russian, bulgarian, basque, french, latin, loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo
File: size10.clo 2005/09/16 v1.4f Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) (/usr/share/texmf-texlive/tex/generic/babel/babel.sty
Package: babel 2005/11/23 v3.8h The Babel package
(/usr/share/texmf-texlive/tex/generic/babel/frenchb.ldf
Language: french 2005/02/06 v1.6g French support from the babel system
(/usr/share/texmf-texlive/tex/generic/babel/babel.def
File: babel.def 2005/11/23 v3.8h Babel common definitions
\babel@savecnt=\count87
\U@D=\dimen103
)
Package babel Info: Making : an active character on input line 219.
Package babel Info: Making ; an active character on input line 220.
Package babel Info: Making ! an active character on input line 221.
Package babel Info: Making ? an active character on input line 222.
LaTeX Font Info:    Redeclaring font encoding T1 on input line 299.
\parindentFFN=\dimen104
\std@mcc=\count88
\dec@mcc=\count89
*************************************
* Local config file frenchb.cfg used
*
(/usr/share/texmf-texlive/tex/generic/babel/frenchb.cfg))) (/usr/share/texmf-te
xlive/tex/latex/base/fontenc.sty
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package
(/usr/share/texmf-texlive/tex/latex/base/t1enc.def
File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 43.
)) (/usr/share/texmf-texlive/tex/latex/base/inputenc.sty
Package: inputenc 2006/05/05 v1.1b Input encoding file
\inpenc@prehook=\toks14
\inpenc@posthook=\toks15
(/usr/share/texmf-texlive/tex/latex/base/latin1.def
File: latin1.def 2006/05/05 v1.1b Input encoding file
)) (/usr/share/texmf-texlive/tex/latex/fancyvrb/fancyvrb.sty
Package: fancyvrb 1998/07/17
Style option: `fancyvrb' v2.6, with DG/SPQR fixes <1998/07/17> (tvz) (/usr/shar
e/texmf-texlive/tex/latex/graphics/keyval.sty
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
\KV@toks@=\toks16
)
\FV@CodeLineNo=\count90
\FV@InFile=\read1
\FV@TabBox=\box26
\c@FancyVerbLine=\count91
\FV@StepNumber=\count92
\FV@OutFile=\write3
No file fancyvrb.cfg.
) (./toto.aux)
\openout1 = `toto.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for T1/lmr/m/n on input line 16.
LaTeX Font Info:    Try loading font information for T1+lmr on input line 16.
(/usr/share/texmf/tex/latex/lm/t1lmr.fd
File: t1lmr.fd 2007/01/14 v1.3 Font defs for Latin Modern
)
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 16.
LaTeX Font Info:    ... okay on input line 16.
LaTeX Info: Redefining \dots on input line 16.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <12> on input line 18.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <8> on input line 18.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <6> on input line 18.
[1

Success!  Wrote 1 page, 12037 bytes to toto.pdf

Reported by couannette on 2010-07-23 16:59:09


shiblon commented 8 years ago
Bumping down the priority per our email conversation, marking as Type-Other (inconvenience?).
 I agree that this is an annoying problem, though.

Reported by shiblon on 2010-07-28 14:02:10

shiblon commented 8 years ago
Bumping down the priority per our email conversation, marking as Type-Other (inconvenience?).
 I agree that this is an annoying problem, though.

Reported by shiblon on 2010-07-28 14:02:11

shiblon commented 8 years ago
I have this same problem with version 2.2.0-rc5.  Version 2.1.43 doesn't have the problem.

Reported by onion.avenger on 2010-08-05 18:03:04

shiblon commented 8 years ago
Yes, that's been the case because of the switch to using pdflatex.  It removes some
of the middle build steps, which slowed things down just enough for make to realize
that things were already built (and I don't just mean wall time, I mean "distance from
source to target in the dependency chain").  Shortening the dependency chain exposed
a make bug.  I can't fix it.  What's amazing is that I got it to work at all, and believe
me, in order to avoid *infinite* rebuilds, I had to do some really weird make tricks
that are pretty brittle.

Sorry I don't have a better answer for you.

Reported by shiblon on 2010-08-08 19:56:49

shiblon commented 8 years ago
Changing to "Accepted", but not planning to work on this right now.  I'm not even sure
that my theory is 100% correct.

Reported by shiblon on 2010-08-12 20:23:51

shiblon commented 8 years ago

Reported by shiblon on 2011-01-04 16:14:12