help-make
[Top][All Lists]
Advanced

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

Difference between $(call macro) and $(macro)


From: Rakesh Sharma
Subject: Difference between $(call macro) and $(macro)
Date: Tue, 18 Feb 2014 02:14:09 -0800

Hi,

Recently while debugging  a piece of make code I stumbled upon the
following curious mismatch between the behaviors of seemingly identical codes.
viz.,    this    $(call macro)     vs.      just     $(macro)

I am not sure whether this is a known behavior or a bug (to me this is a bug).

###############################################################
COMMA := ,
ns = $(shell od -A n -t x -N 4 /dev/random)
define genn
$(strip \
    $(if $($1),\
        $(call genn,$(join $(addsuffix _,result),$(ns))),\
        $(if $1,\
            $1,\
            $(call genn,$(join $(addsuffix _,result),$(ns)))\
        )\
    )\
)
endef

define -tr-body
$(if $1,$$(subst $(firstword $1),$(call -tr-body,$(wordlist 2,$(words 
$1),$1),$2)),$2)
endef

define -run-tr-body
$(eval $4 := $(call -tr-body,$(join $(addsuffix $(COMMA),$1),$2),$3))$($4)
endef

define tr
$(call -run-tr-body,$1,$2,$3,$(call genn))#<----------this is ok
$(call -run-tr-body,$1,$2,$3,$(genn))#<---------this gives erroneous results 
# $(call -run-tr-body,$1,$2,$3,$(genn,,))#<---------if we must use this 
notation then an additonal
## an empty argument needs to be placed alongside
endef

L := a b c d e
M := A B C D E
S := mixed_CASE

  x := $(call tr,$L,$M,$S)
###########################################################

What's going on here? Apparently,  the construct $(macro) picks up the 
$1/$2/... values from the macro in which it was placed. However, the construct 
$(call macro) picks up the $1/$2 ... values from its' own argument list. And, 
that is also why when we write $(macro,,) this seems to rid the problem of the 
unintentional grabbing of the parent macro's arguments.

I would want some light thrown on this issue.

Thanks,
Rakesh
Sharma

                                          

reply via email to

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