[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a few basic doubts
Re: a few basic doubts
Fri, 02 Oct 2009 08:43:48 -0400
On Thu, 2009-10-01 at 06:03 -0700, Payal wrote:
> Thanks Sam & Paul for the efforts. Reply is inline.
> On Wed, Sep 30, 2009 at 08:44:13AM -0400, Paul Smith wrote:
> > > 2) What is the difference in wildcard "%" & "*"?
> > Not sure what you mean: in the $(wildcard ...) function? "%" has no
> > special meaning to $(wildcard ...). That function uses the standard
> > UNIX glob expressions (see "man 7 glob" for example).
> No I mean when to use % and when to use *? I am confused cos'
> obj = *.c
> obj = $(wildcard *.c)
> But in $(patsub ...) or vpath, "%" is used.
"%" is a pattern matching character, and patterns are matched by make.
They are a make feature.
Using *.c or $(wildcard *.c) is using globbing expressions, like your
shell. They use the operating system's file matching library.
> > > 3) How do I define a variable whose value are files abc, "cde xyz" & lmn?
> > I assume you're really asking here, how to handle filenames containing
> > whitespace in make. The short answer is, you cannot do this reliably.
> But I cannot control whether filenames can have spaces or not especially
> when they are from non-Unix world. e.g.
The short answer is still, if you cannot avoid filenames containing
whitespace then make will not work for you. If you absolutely must
support filenames containing whitespace you will need to find a
different build tool.
Make was developed on UNIX back in the 1970's, where files containing
whitespace were allowed, but frowned on: from the command line you had
to quote all whitespace (there was no graphical file chooser that let
you pick files with a mouse) and that was a pain so no one did it, much.
Internally, make works entirely on strings; it doesn't work on arrays of
filenames. The result of "obj = $(wildcard *.c)" is NOT stored
internally as a discrete list of individual filenames, it's a single
string with all the names separated by a space. So, any time make wants
to operate on the individual files in that variable it first chops up
the string into individual file names--by looking for whitespace to
Today, it's not possible to say "this whitespace is a separator between
different files, but that whitespace is actually part of the filename".
That's just the way it is.
Paul D. Smith <address@hidden> Find some GNU make tips at:
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist