help-gnu-utils
[Top][All Lists]
Advanced

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

Re: make: target-depending prerequisites?


From: Henrik Carlqvist
Subject: Re: make: target-depending prerequisites?
Date: Sun, 25 May 2008 02:41:35 +0200
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

Yves <grazhopper+ng@gmail.com> wrote:

>> But maybe you have some other reason to have your variable main_depend not
>> shown in your example?
> 
> The main reason for trying to do what I am trying to do is the situation 
> where I have multiple main-documents, each with its own dependencies.

Again, do you really need those variables?

> If one of the depending files is updated, I only want the relevant 
> main-documents to be recompiled, and not all of them.

Thats what make is good for.
 
> The following solution does the job, however, this means duplication of 
> the commands inside the main1.pdf and main2.pdf block. My intent was 
> thus to try to avoid this and parametrize into a single %.pdf block.
> 
> -8<-----------------------------------------
> texfiles = main1.tex main2.tex
> 
> main1_depend = section1.tex section3.tex
> main2_depend = section2.tex section1.tex
> 
> all_pdf = $(texfiles:.tex=.pdf)
> 
> all: $(all_pdf)
> 
> main1.pdf: main1.tex $(main1_depend)
>       @echo "All prerequisites:" $^
>       touch $@
> 
> main2.pdf: main2.tex $(main2_depend)
>       @echo "All prerequisites:" $^
>       touch $@
> -8<-----------------------------------------
> 
> Maybe there exist better solutions to achieve the desired effect?

I think it would be a cleaner solution if you skipped those variables
and instead wrote something like this:

-8<-----------------------------------------
texfiles = main1.tex main2.tex

all_pdf = $(texfiles:.tex=.pdf)

all: $(all_pdf)

main1.pdf: section1.tex section3.tex

main2.pdf: section2.tex section1.tex

$(all_pdf): main%.pdf: main%.tex
        @echo "All prerequisites:" $^
        touch $@
-8<-----------------------------------------

regards Henrik
-- 
The address in the header is only to prevent spam. My real address is:
hc3(at)poolhem.se Examples of addresses which go to spammers:
root@localhost postmaster@localhost



reply via email to

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