bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make 3.82: weird "circular dependency" and missing $< expansion


From: Akim Demaille
Subject: Re: Make 3.82: weird "circular dependency" and missing $< expansion
Date: Tue, 3 May 2011 18:08:01 +0200

Le 3 mai 2011 à 15:03, Edward Welbourne a écrit :

Hi Edward,

Thanks a lot for your detailed explanation.

> Because there are two routes through the dependency graph from %.eps
> to %.dat, one going directly, the other going via %.pdf, make has an
> ambiguity it can't sensibly resolve (if any %.eps is asked for, for
> which a matching %.dat does exist); so "Circular" is the wrong
> complaint, but Akim's rules are ambiguous, and this is the problem.

I really believed that Make would always look for the shortest path.

> Quite likely, Akim's rules' commands will actually end up with the
> same %.eps either way;

Actually, no.  The two true rules are really quite different.  My context is a 
LaTeX document which is natively compiled into PDF.  There are a few images in 
this document, converted from various formats to PDF.

But I also want to compile the document into HTML and I use TeX4HT to this end. 
 Unfortunately it goes via DVI, which in turn requires EPS images.  So I need 
to convert my PDF images into EPS for latex (nor pdflatex) to work with it. 

This is the part that deals with it, using ImageMagick's convert to convert 
from PDF to EPS.

ENSURE_TARGET_DIR = mkdir -p $(dir $@) || true
CONVERT_TO_EPS =                                \
  { $(ENSURE_TARGET_DIR) ; } &&                 \
  $(CONVERT) $< eps:address@hidden &&                   \
  mv address@hidden $@
%.eps: %.pdf
        $(AM_V_GEN)$(CONVERT_TO_EPS)

AM_V_GEN is coming from Automake, it might expand to "@" when I want rules to 
be silent.



Some of my images are generated from some output (*.dat) from a program that I 
feed to GNU Plot.  Now, GNU Plot provides several nice output formats, but for 
LaTeX inclusion, the best one is by far "EPS-LaTeX", which uses EPS for the 
"drawings" and LaTeX for the text.  So it generates two files: a LaTeX file 
(*.pdftex_t in my rules) that includes an eps file (*.eps).  But since I want 
to compile a PDF file, not a DVI one, I also need to convert the EPS file into 
a PDF figure...

## pdftex/pdftex_t combined GNU Plot pictures.
##
## The GNU Plot file needs not set the output file name, nor the terminal:
## set are properly set by default.
##
## A single Make rule with two commands because it simplifies the use:
## depend on one file, not two.
%.pdftex_t %.eps %.pdf: %.dat
        $(AM_V_GEN)$(ENSURE_TARGET_DIR)
# gnuplot creates an output, even if it failed.  Remove it.
        $(AM_V_at)rm -f $*.{tex,eps,pdf,pdftex_t}
# Put the output first, before the plotting command, and before
# requests from the user.  Set the terminal too there for the same
# reasons.
        $(AM_V_at){                                     \
          echo 'set output "$*.tex"';                   \
          echo 'set terminal epslatex color';           \
          echo 'set key off';                           \
          echo 'plot "$<" using 1:2 with linespoints';  \
        } >$*.plt.tmp
        $(AM_V_at)LC_ALL=C $(GNUPLOT) $*.plt.tmp
        $(AM_V_at)mv $*.tex $*.pdftex_t
        $(AM_V_at)$(EPSTOPDF) $*.eps -o $*.pdf
        $(AM_V_at)rm $*.plt.tmp



I have tried to control some of my rules so that there are no multiple matches, 
but it's making the Makefile quite complex.  I find it is already too complex, 
and my colleagues are already quite unhappy with Make, so I'd rather keep it 
simple.

I did try to provide a more specific rule for my "trajectories" (the *.dat 
files), hoping that that would give Make a hint that *this* is the rule to use. 
 But Make hates this.

> $ cat Makefile
> TRAJECTORIES = accel.utraj
> PDF_IMAGES = head.pdf
> EPS_IMAGES = head.eps
> 
> all: $(EPS_IMAGES)
> 
> %.eps: %.pdf
>       echo $< >$@
> 
> output: $(PDF_IMAGES)
> 
> TRAJECTORIES_EPS := $(TRAJECTORIES:.utraj=.eps)
> $(TRAJECTORIES_EPS): %.eps %.pdf: %.dat
>       echo "{$<}"
>       test -n "$<"
> $ LC_ALL=C gmake
> Makefile:13: *** multiple target patterns.  Stop.

So really, you are right, I should filter out.

But thanks to you I found another way out (much less optimized): remove the 
*.eps file that is generated by GNU Plot once it is converted to PDF.

# %.eps removed here.
%.pdftex_t %.pdf: %.dat
        # ...
        # $*.eps now removed.
        $(AM_V_at)rm $*.plt.tmp $.eps

That works.  It makes some additional useless conversions, but I can live with 
that.  At least I think I can :)


> Complaining about ambiguity is the
> robust course of action.

That would be wonderful, indeed.  It would particularly help avoid portability 
issues such as this one (that Makefile has been working for years, but due to 
some limitations of GNU Make 3.81, we _had_ to move to 3.82 where this part 
stopped working).

Again, thanks a lot to both of you.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]