help-make
[Top][All Lists]
Advanced

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

differences between define and '='


From: Dill, John
Subject: differences between define and '='
Date: Tue, 14 Dec 2004 10:18:51 -0600

I currently write all my functions using the '=' operator.  However, it is also 
possible to write them using define afaik.  I don't know however what the 
differences between using define and '='.  Can someone answer these questions?

What is the intent of writing a 'define' function?  I have the Mecklenburg book 
and it appears that you use 'define' for writing a shell script which can be 
called as a makefile function, whereas using '=' appears to use more makefile 
specific functionality.  Can someone explain what they use 'define' for writing 
functions vs using '='?

What is the impact of whitespace when using 'define' vs '='?  Any whitespace in 
'=' gets carried to the output, which has been one of my pet peeves, which ends 
up making my makefile functions difficult to read due to $(...)$(...)$(...) all 
being bunched up rather than on separate lines.  How is whitespace expanded 
when doing $(call) with a function defined from 'define'?

If I want to define a makefile function using '=', can I define it in this way 
and have a method of removing its whitespace footprint?

my_function=$(if $(call assert_argument,$1,$0,first),\
                  $(if $(call assert_argument,$3,$0,third),\
                    $(foreach iter,$2,\
                      $(shell echo '$2' 1>&2))))

Instead, how I usually define it is like this:

my_function=$(if $(call assert_argument,$1,$0,first),$(if $(call 
assert_argument,$3,$0,third),$(foreach iter,$2,$(shell echo '$2' 1>&2))))

which is alright for me, but quite confusing for others and myself to read and 
understand my functions, especially when it gets to about 6-8 consecutive 
wrapped lines.

I want some of my functions to have a zero whitespace footprint since I use 
them as tab-commands.  Does that mean I have to $(strip) every single one of my 
functions?  If I use 'define' instead, does that gain me anything?

Thanks for any info.
John




reply via email to

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