help-make
[Top][All Lists]
Advanced

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

Re: White Space Problems--Again


From: Paul Smith
Subject: Re: White Space Problems--Again
Date: Sat, 28 Mar 2009 22:20:24 -0400

On Sat, 2009-03-28 at 20:54 -0500, Tom Browder wrote:
> > toc2.platform.file_extensions.exe =# no whitespace, please
> >
> > i remember that causing me grief when i had a space after the '=', and
> > added the comment marker to ensure that it stays empty.

This is not necessary.  The rule for make space stripping in variables
is clearly described in the manual, in the section "Setting Variables":

        Whitespace around the variable name and immediately after the
        `=' is ignored.

So, you don't need to worry about whitespace between the "=" and the
value.

The canonical reason to create a variable containing a space is so it
can be used in substitutions.  For example, if you have a list:

        LIST = a b c d e

and you want a colon-separated list, how can you do it?  You want to
substitute : for space, but you can't do it:

        COLONS = $(subst   ,:,$(LIST))

won't work.  Make strips all whitespace between the function name and
the first argument.  You can get around this with:

        E =
        S = $E #<- this is a space

        COLONS = $(subst $S,:,$(LIST))

I admit this is a lame reason for this feature.  It could also be, and I
typically do, implemented like this:

        E =
        S = $E $E

without the preservation of trailing whitespace.

The reality is that make's escaping features are inconsistent at best
and fairly useless at worst.  The trailing whitespace thing is really
only the tip of the iceberg.  But, it's a large iceberg and virtually
any possible solution would mean breaking lots of existing makefiles.
That's the problem with a legacy application like make.

> >> I'm really having a hard time seeing why it would be proscribed in
> >> POSIX, too.
> >
> > Probably for historical reasons, since the standard was written long
> > after make was commonplace. There's a *lot* of makefile code in the
> > world, and changing any given standards-defined behaviour might indeed
> > break 1 or even 2 projects.
> 
> Somehow I believe the POSIX folks had never used Make.  And ABI's are
> broken all the time, albeit without serious consideration.

The people who wrote POSIX have used many, many more various
implementations of make than almost anyone reading this list.  And, make
was commonplace long before POSIX was even a glimmer in someone's eye.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          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




reply via email to

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