Try make -f and.mk A=22 B=44. ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Murphy Sent: Tuesday, June 17, 2008 09:31 To: bug-make@gnu.org Subject: Re: Help : how to use $(or condition ) & $(and condition ) inmakefile Hi,
I have amended an example of how to use $(and) that I posted earlier for Rakesh. I have tested this on Linux with make 3.81. It shows a crude way and a slightly more sophisticated way to use $(and) in an if statement to determine if two variables have equal values: A=2 B=4 # do "equal" by seeing if a subst returns the empty string: A_is_2:=$(if $(subst 2,,$(A)),,T) B_is_4:=$(if $(subst 4,,$(B)),,T) AandB:=$(and $(A_is_2),$(B_is_4)) # then you could do something based on this: $(info Crude AND Demo: ) ifneq ($(AandB),) $(info TRUE: A is 2, B is 4) else $(info FALSE: A is $(A), B is $(B)) endif # One could make it look nicer by making an equals macro: define eq $(if $(1:$(2)=),,$(if $(2:$(1)=),,T)) endef # which you could use as follows: $(info Macro-based AND Demo: ) ifneq ($(and $(call eq,$(A),2),$(call eq,$(B),4)),) $(info TRUE: A is 2, B is 4) # do what you want to do when A=2 and B=4 else $(info FALSE: A is $(A), B is $(B)) endif The output looks like this: [EMAIL PROTECTED] base]make -f and.mk A=1 B=5 Crude AND Demo: FALSE: A is 1, B is 5 Macro-based AND Demo: FALSE: A is 1, B is 5 make: *** No targets. Stop. [EMAIL PROTECTED] base]make -f and.mk A=2 B=4 Crude AND Demo: TRUE: A is 2, B is 4 Macro-based AND Demo: TRUE: A is 2, B is 4 make: *** No targets. Stop. [EMAIL PROTECTED] base]make -f and.mk A=2 B=3 Crude AND Demo: FALSE: A is 2, B is 3 Macro-based AND Demo: FALSE: A is 2, B is 3 make: *** No targets. Stop. 2008/6/6 Paul Smith <[EMAIL PROTECTED]>: On Fri, 2008-06-06 at 05:05 -0700, rakesh aggarwal wrote: > But still there is some problem. I haven't looked at your example. But, the very first thing to check is the version of GNU make you're using (make --version). If it's not 3.81, then the manual you're reading is not the right one for the version of GNU make you're using. -- ------------------------------------------------------------------------ ------- Paul D. Smith <[EMAIL PROTECTED]> Find some GNU make tips at: http://www.gnu.org http://make.mad-scientist.us "Please remain calm...I may be mad, but I am a professional." --Mad Scientist -- You could help some brave and decent people to have access to uncensored news by making a donation at: http://www.thezimbabwean.co.uk/
_______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make