var := 'C:/some/path here' labas
all:
@echo $(words $(var))
This returns 3
.
How to make it return 2
? Or make does not work the way I think??
var := 'C:/some/path here' labas
all:
@echo $(words $(var))
This returns 3
.
How to make it return 2
? Or make does not work the way I think??
Make definitely doesn't work the way you think, if you think that make has any interest in quotes of any type :). Make ignores (i.e., treats as normal characters like any other) both single- and double-quote characters in virtually every situation, and all make functions work in simple whitespace delimiters without regard to quote characters.
In general, it's not practical to use make with any system that requires spaces in target names. It just doesn't work: too much of make is based on whitespace as a separator character and there's no general, common way to escape the whitespace that works everywhere.
In your very particular case you can play a trick like this:
E :=
S := $E $E
path := C:/some/path here
xpath := $(subst $S,^,$(path))
var := $(xpath) labas
all:
@echo $(words $(var))
@echo $(subst ^,$S,$(var))
Basically, this creates a variable $S
which contains a space, then it substitutes all spaces in the variable path
with some other, non-space character (here I chose ^
but you can pick what you like, just note it has to be a character which is guaranteed to not appear in the path).
Now this path doesn't contain whitespace so you can use it with make functions.
This has major downsides: not only the complexity visible here, but note these paths cannot be used in target names since they won't actually exist on disk.
In general, you should simply not use paths containing whitespace with make. If you must use paths containing whitespace, then very likely make is not the right tool for you to be using.