help-make
[Top][All Lists]
Advanced

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

Re: How to test if a variable is something or empty?


From: Peng Yu
Subject: Re: How to test if a variable is something or empty?
Date: Sat, 25 Oct 2008 08:31:42 -0500

On Sat, Oct 25, 2008 at 2:29 AM, Sam Ravnborg <address@hidden> wrote:
> On Fri, Oct 24, 2008 at 07:00:41PM -0500, Peng Yu wrote:
>> On Fri, Oct 24, 2008 at 4:37 PM, Philip Guenther <address@hidden> wrote:
>> > On Fri, Oct 24, 2008 at 1:59 PM, Peng Yu <address@hidden> wrote:
>> >> I have the following code. I'm wondering how to put them together into
>> >> one if statement?
>> >>
>> >> ifeq ($(MAKECMDGOALS), all)
>> >> -include .dep
>> >> endif
>> >>
>> >> ifeq ($(MAKECMDGOALS), )
>> >> -include .dep
>> >> endif
>> >
>> > Don't you _really_ want to test whether they are doing a "make clean"?  If 
>> > so:
>> >
>> > # don't include .dep if they're doing a make clean
>> > ifeq ($(filter clean,$(MAKECMDGOALS)),)
>> >  -include .dep
>> > endif
>> >
>> > If there are other fake targets that should disable .dep inclusion,
>> > just include them in the first argument to $(filter)
>>
>> No. I'm not asking how to make clean. I just want to know how to
>> combine the two if statements. The commands inside each if statements
>> can be anything, but they are the same.
>>
>> ifeq ($(MAKECMDGOALS), all)
>> some command
>> endif
>>
>> ifeq ($(MAKECMDGOALS), )
>> same as above command
>> endif
>
> Like this:
>
> ifeq ($(filter all, $(MAKECMDGOALS)),)
> #bla
> endif
>
> You just filter out the "all" target so the result is
> empty if all was specified.
>
> But as Philip said consider what you try to do. Do the right
> thing happen when you do "make foo" also where foo is some random
> target?

I didn't quite catch Philip's point.

What I want my Makefile to do is the following. There could be three
make file goals, 'c', 'g' and 'o', specified in the command line. If I
don't specify anything in the command line, I want gmake choose the
goal 'c' by default. Did Philip suggest not do this?

Thanks,
Peng




reply via email to

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