help-make
[Top][All Lists]
Advanced

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

Re: Choosing between several rules for a single targed based on prerequi


From: John Graham-Cumming
Subject: Re: Choosing between several rules for a single targed based on prerequisites avaibility
Date: Tue, 07 Jun 2005 13:18:27 -0400

On Tue, 2005-06-07 at 11:31 +0200, Yannick Patois wrote:
> I have a target (A) that can be build either by applying a given rule on
> a prerequisites (P1) or another rule on another prerequisites (P2).
> 
> I would like a Makefile that does:
> - If only one of P1 or P2 exists, use the available rule to build it
> - If both exists, use P1

If P1/P2 are _not_ being built by the Makefile (i.e. they are files
whose existence is determined before you type Make) then you could do
this:

ifeq ($(wildcard p1),p1)
a: p1
        @echo Making a from p1
else
ifeq ($(wildcard p2),p2)
a: p2
        @echo Making a from p2
else
$(warning Both p1 and p2 missing)
endif
endif

Which will define a rule making a from p1 if p1 (or both p1 and p2)
exists and a rule for making a from p2 if only p2 exists (or outputs a
warning if both are missing).

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/






reply via email to

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