🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3714

[GNU Make] Generic phony rules

#3714
From: * Tong *
Date: Thu, 22 Mar 2007 14:50
114 lines
4270 bytes
My OP:

I have the following make file:

-------------------------------------------
all: something else

.PHONY: MakeAppleJuice MakeOrangeJuice MakeTomatoJuice

MakeAppleJuice:
	make_juice Apple.in.source  Apple.in.condition
				                    
MakeOrangeJuice:		                    
	make_juice Orange.in.source Orange.in.condition 
				                    
MakeTomatoJuice:		                    
	make_juice Tomato.in.source Tomato.in.condition 
-------------------------------------------

Is there anyway to combine the 3 rules into one? I hope there is, because
the 3 rules only different in what files they use and what juices then make
(but I still need the 3 phony targets). 

On Thu, 22 Mar 2007 12:47:15 +0000, * Tong * wrote:

> On Wed, 21 Mar 2007 23:33:30 -0500, Jean-Rene David wrote:
> 
>> If you want to get the effect of .PHONY, there's another
>> trick:
>> 
>> FORCE:
>> Make%Juice: %.in.source FORCE
>> 	make_juice $*.in.source $*.in.condition
> 
> Thanks for the reply. I still can't get it working:
> 
> $ cat Makefile 
> make_juice := echo
> 
> all: something else
> 
> .PHONY: MakeAppleJuice MakeOrangeJuice MakeTomatoJuice
> 
> FORCE:
> Make%Juice: %.in.source FORCE
>         make_juice $*.in.source $*.in.condition 
> 
> #MakeAppleJuice:
> 
> $ make MakeAppleJuice
> make: Nothing to be done for `MakeAppleJuice'.
> 
> If the last "MakeAppleJuice:" is uncommented, It still won't work. My make
> is:
> 
> $ make --version
> GNU Make 3.81
> 
>>> Which shouldn't be, because AppleJuice is a phony target.
>> 
>> Quite the opposite. In light of the above, if you remove the
>> target from the phonies, it works.
> 
> I don't quite understand this. You mean do a 'rm <target>' as the make rule? 
> 
> This is what I tried also:
> 
> $ rm -v Apple.in.*
> removed `Apple.in.condition'
> removed `Apple.in.source'
> 
> $ make MakeAppleJuice
> make: Nothing to be done for `MakeAppleJuice'.
> 
> I read quite a lot, but just can't apprehend enough to make it works.

I just tried "Empty Target Files" trick, 
http://www.gnu.org/software/autoconf/manual/make/Empty-Targets.html#Empty-Targets

-----------------------------------------------------------
$ cat Makefile 
make_juice := echo

all: something else

MakeJuice: $(wildcard *.in.source)
        $(make_juice) $? $(addsuffix .in.condition, $(patsubst %.in.source,%,$?))
        touch MakeJuice

$ make MakeJuice
echo Orange.in.source Tomato.in.source Orange.in.condition Tomato.in.condition
Orange.in.source Tomato.in.source Orange.in.condition Tomato.in.condition
touch MakeJuice

$ make MakeJuice
make: `MakeJuice' is up to date.
-----------------------------------------------------------

But that's different than my OP, because I need to deal with each juice
explicitly, and the command format is strictly 

 make_juice $*.in.source $*.in.condition 

So, is it possible to have such generic phony rule?

Thanks

-- 
Tong (remove underscore(s) to reply)
  http://xpt.sf.net/techdocs/
  http://xpt.sf.net/tools/

-- 
Posted via a free Usenet account from http://www.teranews.com
Technical Details
Message-ID: <460297c8$0$16351$88260bb3@free.teranews.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!nntpserver.com!zeus.nntpserver.com!10.1.1.41.MISMATCH!pfilter-v0.1!not-for-mail
References: <46019e01$0$16388$88260bb3@free.teranews.com> <et6dnRIrZottTJzbnZ2dnUVZ_ragnZ2d@magma.ca> <4601d80e$0$16388$88260bb3@free.teranews.com> <GpudnStEOcSHmp_bnZ2dnUVZ_s-rnZ2d@magma.ca> <46027ad3$0$16371$88260bb3@free.teranews.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: fc89c,a0c39f8de3604803
X-Google-Thread: f8c9b,b9378e6bdc89f2c,start
X-Google-Thread: 109f73,a0c39f8de3604803
X-Google-Attributes: gidfc89c,gidf8c9b,gid109f73,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!nntpserver.com!zeus.nntpserver.com!10.1.1.41.MISMATCH!pfilter-v0.1!not-for-mail
From: * Tong * <sun_tong_001@users.sourceforge.net>
Subject: [GNU Make] Generic phony rules
Newsgroups: comp.unix.programmer,comp.unix.questions,gnu.utils.help
References: <46019e01$0$16388$88260bb3@free.teranews.com>
 <et6dnRIrZottTJzbnZ2dnUVZ_ragnZ2d@magma.ca>
 <4601d80e$0$16388$88260bb3@free.teranews.com>
 <GpudnStEOcSHmp_bnZ2dnUVZ_s-rnZ2d@magma.ca>
 <46027ad3$0$16371$88260bb3@free.teranews.com>
User-Agent: pan 0.119 (Karma Hunters)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 22 Mar 2007 14:50:48 GMT
Lines: 111
Message-ID: <460297c8$0$16351$88260bb3@free.teranews.com>
NNTP-Posting-Date: 22 Mar 2007 14:50:48 GMT
X-Complaints-To: abuse@teranews.com