[GNU Make] Stem for phony target - Unix

This is a discussion on [GNU Make] Stem for phony target - Unix ; Hi, 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 ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: [GNU Make] Stem for phony target

  1. [GNU Make] Stem for phony target

    Hi,

    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). I tried the following but it didn't
    work:

    -------------------------------------------
    Make%Juice: %.in.source
    make_juice $*.in.source $*.in.condition
    -------------------------------------------

    Please help.

    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


  2. Re: [GNU Make] Stem for phony target

    * * Tong * [2007.03.21 21:05]:
    > I tried the following but it didn't work:
    >
    > -------------------------------------------
    > Make%Juice: %.in.source
    > make_juice $*.in.source $*.in.condition
    > -------------------------------------------


    Though a bit different, this works and may get on you the
    right track:

    all: something else

    ..PHONY: AppleJuice OrangeJuice TomatoJuice

    %Juice: %.in.source
    make_juice $? $(addsuffix .in.condition, $(patsubst %.in.source,%,$?))

    info make --index='File Name Functions'
    info make --index='Pattern Rules'
    info make --index='Automatic Variables'

    --
    JR

  3. Re: [GNU Make] Stem for phony target

    On Wed, 21 Mar 2007 19:46:40 -0500, Jean-Rene David wrote:

    > * * Tong * [2007.03.21 21:05]:
    >> I tried the following but it didn't work:
    >>
    >> -------------------------------------------
    >> Make%Juice: %.in.source
    >> make_juice $*.in.source $*.in.condition
    >> -------------------------------------------

    >
    > Though a bit different, this works and may get on you the
    > right track:
    >
    > all: something else
    >
    > .PHONY: AppleJuice OrangeJuice TomatoJuice
    >
    > %Juice: %.in.source
    > make_juice $? $(addsuffix .in.condition, $(patsubst %.in.source,%,$?))


    thanks for the reply, hmm...

    Have you tried your make file?

    $ make AppleJuice
    make: Nothing to be done for `AppleJuice'.

    Which shouldn't be, because AppleJuice is a phony target.

    --
    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


  4. Re: [GNU Make] Stem for phony target

    * * Tong * [2007.03.22 01:12]:
    > On Wed, 21 Mar 2007 19:46:40 -0500, Jean-Rene David wrote:
    >> all: something else
    >>
    >> .PHONY: AppleJuice OrangeJuice TomatoJuice
    >>
    >> %Juice: %.in.source
    >> make_juice $? $(addsuffix .in.condition, $(patsubst %.in.source,%,$?))

    >
    > thanks for the reply, hmm...
    >
    > Have you tried your make file?


    I did what one should never do: change one small thing
    *after* having tested it.

    > $ make AppleJuice
    > make: Nothing to be done for `AppleJuice'.


    I looked into it a little (did you?) and I learned
    something. Pattern rules and phonies don't play well. You
    can't have a rule like this:

    ..PHONY: %.o

    Also, it seems when you define:

    ..PHONY: AppleJuice

    Then make looks for an *explicit* rule to make "AppleJuice".
    It doesn't do the pattern rule.

    Interestingly, I haven't seen this anywhere in the
    documentation.

    > 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.

    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

    And your original command line works.

    info make --index='force'

    --
    JR

  5. Re: [GNU Make] Stem for phony target

    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 ' 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.

    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


  6. [GNU Make] Generic phony rules

    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 ' 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...#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


  7. Re: [GNU Make] Stem for phony target

    * * Tong * [2007.03.22 12:47]:
    > 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'.


    This is basically the same makefile as before.

    The "FORCE" trick is meant to *replace* the .PHONY rule.
    It's not exactly the same thing, but in your case it will
    allow you to do what you want with a similar overall effect
    (only performance is affected).

    >>> 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 '
    > as the make rule?


    No. I mean delete the .PHONY *rule* from your makefile.

    % cat Makefile
    all: something else

    FORCE:
    Make%Juice: %.in.source FORCE
    @echo $*.in.source $*.in.condition

    % ls *.in.source
    Apple.in.source
    Orange.in.source
    Tomato.in.source

    % make MakeAppleJuice
    Apple.in.source Apple.in.condition

    % touch MakeAppleJuice
    % make MakeAppleJuice
    Apple.in.source Apple.in.condition

    Without "FORCE":

    % cat Makefile
    all: something else

    Make%Juice: %.in.source
    @echo $*.in.source $*.in.condition

    % touch MakeAppleJuice
    % make MakeAppleJuice
    make: `MakeAppleJuice' is up to date.

    --
    JR

  8. Re: [GNU Make] Stem for phony target

    On Thu, 22 Mar 2007 11:09:36 -0500, Jean-Rene David wrote:

    > % make MakeAppleJuice [...]


    Thanks a LOT!

    --
    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


  9. [GNU Make] Generic phony rules

    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 ' 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...#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


+ Reply to Thread