Unix Programming - [GNU Make] Generic phony rules

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2007 > [GNU Make] Generic phony rules





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [GNU Make] Generic phony rules
* Tong *

2007-03-22, 1:27 pm

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:
>
>
> 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
>
>
> 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/autocon...l#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

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com