help-make
[Top][All Lists]
Advanced

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

Re: Testing gnuMake flags


From: pip9ball
Subject: Re: Testing gnuMake flags
Date: Tue, 12 May 2009 07:45:03 -0700 (PDT)

Hello,

Thank you for the information.  It does appear to be a bug but I used your
workaround and everything is running ok now.

Thanks,

Phil


Philip Guenther-2 wrote:
> 
> On Thu, May 7, 2009 at 7:30 PM, pip9ball <address@hidden> wrote:
>> I'm having some difficulty testing for flags used when executing gmake.
>>  In
>> particular, if the user calls gmake with the "-j" parallel flag, I want
>> to
>> set a variable differently.  The reason why I need this is we have a
>> batch
>> system in place where I need to disable interactive jobs when running in
>> parallel so the stdout isn't inter-dispersed.  I've created a small
>> testcase, however I don't understand why this doesn't work.
>>
>> ifeq (,$(filter j, $(MAKEFLAGS)))
>>        NC_RUN_EXE = nc run -I blah ...
>> else
> ...
>> In both cases above, the ifeq ($findstring...) function is taking the
>> 'true'
>> branch.
> 
> Uh, I see a $(filter), not a $(findstring) in that Makefile snippet.
> 
> Even with that fixed, however, it won't work: it appears that make
> doesn't add the -j option to MAKEFLAGS until it starts processing
> rules.  I can't think of a good reason for that (it is _not_ related
> to the .NOTPARALLEL target), so I think it's a bug.
> 
> The workaround is to delay the test to when the rule is processed and
> use $(if).  Here's a makefile that demonstrates the bug and the
> workaround.  Compare the output of "make", "make -j", and "make -t".
> 
> Side-note: I use $(value MAKEFLAGS) instead of just $(MAKEFLAGS)
> because the latter will result in a false positive if there's a
> command line variable assignment that contains a 'j'.
> 
> Philip Guenther
> 
> ------
> $(info MAKEFLAGS = '${MAKEFLAGS}')
> ifneq (,$(findstring j,$(value MAKEFLAGS)))
>   $(info has -j!)
> endif
> ifneq (,$(findstring t,$(value MAKEFLAGS)))
>   $(info has -t!)
> endif
> 
> HAS_J = $(if $(findstring j,$(value MAKEFLAGS)),has -j,no -j)
> 
> all:
>         @echo $(MAKEFLAGS)
>         @echo $(if $(findstring j,$(value MAKEFLAGS)),has -j,no -j)
>         @echo $(HAS_J)
> 
> .PHONY: all
> 
> 
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Testing-gnuMake-flags-tp23439038p23504011.html
Sent from the Gnu - Make - Help mailing list archive at Nabble.com.





reply via email to

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