help-make
[Top][All Lists]
Advanced

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

Re: Complex Conditionals


From: Philip Guenther
Subject: Re: Complex Conditionals
Date: Mon, 2 Jun 2008 14:45:26 -0600

On Mon, Jun 2, 2008 at 2:19 PM, EXT-Pennington, Dale K
<address@hidden> wrote:
> I am attempting to have a conditional part of my makefile that is
> performed UNLESS one of 2 conditions is occuring. It used to be one
> condition, and the code was :
>
> ifneq ($(MAKECMDGOALS),clean)
> -include $(DEPFILES)
> endif
>
> But now I have a second make goal for which I do not want to include
> (and force generation of) dependency files.
...
> Now, I figured I could use 2 neqs with null entry for the do not do, but
> I cannot get make to accept the syntax. When I do
>
> ifeq ($(MAKECMDGOALS),clean)
> else ifeq ($(MAKECMDGOALS),IDL)
> else
> -include $(DEPFILES)
> endif
>
> However, when I try this I get a 2 complaints. The first being
> extraneous text after an else directive (the first else). The second is
> only once else per conditional (the second else).
>
> I am running make 3.80. Is the manual in error ?

Issue #1 is that you're reading the manual for 3.81 but using 3.80.
The ability to use the "else if..." syntax was added in 3.81.

The next issue is that your solution, even if you used the right
version of make, isn't 100% correct.  In particular, if you did "make
clean IDL" you wouldn't want to include the dependency files, but the
logic you gave would.  I suggest the following solution, which as
bonus works 3.80 too:

ifneq (,$(if $(MAKECMDGOALS),$(filter-out clean IDL,$(MAKECMDGOALS)),X))
   -include $(DEPFILES)
endif

I.e., if MAKECMDGOALS is non-empty and contains targets _other_ than
'clean' and 'IDL', then include the DEPFILES.


Philip Guenther




reply via email to

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