help-make
[Top][All Lists]
Advanced

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

Re: A question on implicit rules


From: Paolo Gai
Subject: Re: A question on implicit rules
Date: Wed, 11 Feb 2004 16:16:12 +0100

> [...]
> > begin----------------------------
> > A%: B/C%D
> >         @echo A$*
> > 
> > B/C%D:
> >         @echo B/C$*D
> > end----------------------------
> ['make A2' does what you'd expect. But if you delete
> the command for the A% rule, it says:]
> > make: *** No rule to make target `A2'.  Stop.
> I think this is equivalent to the simpler case of
> a makefile that contains only this line:
> A%:
> when no file 'A2' exists.

> Then shouldn't 'make A2' fail, because there's no command
> for make to update file 'A2'? What behavior would be better?

In general, I think the rule "A2" with no prerequisites and no commands
should fail.

Actually I'm using the rule A% like a phony target, the thing is that I
cannot declare it as ".PHONY". the A% has a prerequisite, and I would
like that it executes it in some way...


I'll try to explain better:

consider this makefile:

-------------------------------------------------------
OPTIONLIST_A = opt_a1 opt_a1
OPTIONLIST_B = opt_b1 opt_b2

MYLIST = OPTIONLIST_A OPTIONLIST_B
MYLIST_WITHPREFIX = $(addprefix prefix_, $(MYLIST))
                                                                                
all: $(MYLIST_WITHPREFIX)
                                                                                
prefix_% : myfile_%
        @echo why??
                                                                                
myfile_% :
        echo command with parameter $($*) > $@
-------------------------------------------------------

Typing "make", I would expect rule "all" would be executed .

To make "all", rules prefix_OPTIONLIST_A and prefix_OPTIONLIST_B would
be considered.

finally, to make for example prefix_OPTIONLIST_A, the rule
myfile_OPTIONLIST_A should be executed

The outputs on my machine are the following:

if I run just "make", I obtain:

-----------------------------------------------------------------
address@hidden m]$ make
echo command with parameter opt_a1 opt_a1 > myfile_OPTIONLIST_A
why??
echo command with parameter opt_b1 opt_b2 > myfile_OPTIONLIST_B
why??
rm myfile_OPTIONLIST_A myfile_OPTIONLIST_B
address@hidden m]$
-----------------------------------------------------------------

anyone can explain why "rm myfile_OPTIONLIST_A myfile_OPTIONLIST_B",
since no "rm" statements are inside the makefile?

with the line "@echo why??" commented with an "#", I have:

------------------
address@hidden m]$ make
make: *** No rule to make target `prefix_OPTIONLIST_A', needed by
`all'.  Stop.
address@hidden m]$
------------------

I initally had this spurius "rm", and I thought that the problem was
related to the use of "%", as said in the first mail. But probably it is
something else?

Thanks for all,

Paolo

-- 
-----------------------------------------------------------------------
Paolo Gai - ReTiS Lab - PhD Student

Scuola Superiore S. Anna        Tel       : +39 050 883 031 
Polo S. Anna Valdera            Fax       : +39 050 883 452
viale Rinaldo Piaggio 34        e-mail    : address@hidden
56025 - Pontedera (PI) - ITALY  home page : http://feanor.sssup.it/~pj
------------------------------------------------------------------------
Per favore non mandatemi allegati in Word o PowerPoint.
(Please avoid sending me Word or PowerPoint attachments.)
Si veda (See) http://www.fsf.org/philosophy/no-word-attachments.html
------------------------------------------------------------------------





reply via email to

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