views:

377

answers:

1

Is there any difference in the two ways GREP is invoked in my Makefile? Any reason I should use one or the other? Both seem to produce the same result.

define GREP
$(word 3,$(shell echo "#define  FOO     0xfff00100"))
endef

all:
        @echo $(GREP)
        @echo $(call GREP)
+4  A: 

The way you are using it, there is no difference. However, if your GREP macro were a function that took parameters, you would have to use $(call) to pass parameters to it. For example:

define GREP
$(shell grep $1 $2)
endef

FOO:=$(call GREP,abc,words.txt)

This causes $1 to be replaced with "abc", and $2 with "words.txt".

See more in the GNU make manual on user-defined functions here: http://www.gnu.org/software/make/manual/make.html#Call-Function

Hope this helps,

Eric Melski

Eric Melski