help-make
[Top][All Lists]
Advanced

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

Re: differences between define and '='


From: Paul D. Smith
Subject: Re: differences between define and '='
Date: Tue, 14 Dec 2004 12:41:02 -0500

%% "Dill, John" <address@hidden> writes:

  dj> What is the intent of writing a 'define' function?

The only real difference between define and = is that a value created by
define can have embedded newline characters, while a value created by =
cannot.

  dj> I have the Mecklenburg book and it appears that you use 'define'
  dj> for writing a shell script which can be called as a makefile
  dj> function,

That's one use, but not the only one (especially in GNU make 3.80, where
the $(eval ...) function is often used with define variables).

  dj> whereas using '=' appears to use more makefile specific
  dj> functionality.  Can someone explain what they use 'define' for
  dj> writing functions vs using '='?

As I said, the only reason to use define is if you want embedded newlines.

  dj> What is the impact of whitespace when using 'define' vs '='?  Any
  dj> whitespace in '=' gets carried to the output,

Not always true, but I know what you mean.

  dj> which has been one of my pet peeves, which ends up making my
  dj> makefile functions difficult to read due to $(...)$(...)$(...) all
  dj> being bunched up rather than on separate lines.  How is whitespace
  dj> expanded when doing $(call) with a function defined from 'define'?

There is no difference whatsoever here.

  dj> I want some of my functions to have a zero whitespace footprint
  dj> since I use them as tab-commands.

I don't follow this: why does using something as a "tab-command" (I
assume you mean in a command script?) require zero whitespace footprint?

  dj> Does that mean I have to $(strip) every single one of my
  dj> functions?

You need to use $(strip ...) where you want to remove extra whitespace,
yes.  I typically use $(strip ...) in the command script itself rather
than in the functions but YMMV.

  dj> If I use 'define' instead, does that gain me anything?

No.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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