Sujet : Re: Long filenames in DOS/Windows and Unix/Linux
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.programmerDate : 04. Sep 2024, 15:30:06
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240904071628.892@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-09-04, Keith Thompson <Keith.S.Thompson+
u@gmail.com> wrote:
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
On Tue, 03 Sep 2024 16:38:06 -0700, Keith Thompson wrote:
The make utility has no support for paths with spaces.
Looks like you're right.
>
I have some Makefiles with spaces in the dependency names, of the form:
>
target\ name\ with\ space : source\ name\ with\ space
>
I'd be interested in knowing how you do that.
>
$ cat Makefile
foo\ bar: foo\ bar.c
$ make
cc foo bar.c -o foo bar
cc: fatal error: input file ‘foo’ is the same as output file
compilation terminated.
make: *** [<builtin>: foo bar] Error 1
If you write your own rule in which $@ is quoted as '$@', it will
work, provided it doesn't contain ' characters.
It looks like there is limited support in GNU Make for backslash
escapes: they can be used on the prerequisite and target names
in a rule.
Elsewhere, other than backslash-newline continuations, backslashes
are literal.
So we can do:
FOOBAR := foo\ bar # literal backslash here
$(FOOBAR) : ... # backslash from variable interpolates here
Once the backslash is interpolated into the rule head, it becomes
active, so a single target "foo bar" is specified.
(Unfortunately, what GNU Make should be arguably be doing here is not
just treating foo\ bar as the single target foo bar but also
preserving the backslash so that the item is foo\ bar. Then it would
be possible for the implicit rule to work, because $@ would produce
foo\ bar which would be passed on to the shell, where the backslash
would do its job. One slight problem with that, though, is that the
interpreter for processing recipes is configurable; it doesn't have
to be a POSIX-like shell.)
Anyway, the FOOBAR variable is understood to contain two words, {foo\}
and {bar}. If we do a patsubst on it, it will match separately against
the two. Or foreach will iterate over two items. None of the text
processing stuff in GNU Make will recognize the backslash escape
as preventing word splitting.
Nontrivial Makefiles almost always work with lists, like at the
very least OBJS, SRCS and whatnot.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca