Deutsch   English   Français   Italiano  
<20240904071628.892@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.unix.programmer
Subject: Re: Long filenames in DOS/Windows and Unix/Linux
Date: Wed, 4 Sep 2024 14:30:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <20240904071628.892@kylheku.com>
References: <9e7a4bd1-bfbb-4df7-af1a-27ca9625e50bn@googlegroups.com>
 <ubg6o7$3jrsn$1@news.xmission.com> <ubg853$2ssj8$1@dont-email.me>
 <ubg8a8$2t20l$1@dont-email.me> <vaubbo$1d324$1@news.xmission.com>
 <vauknd$uvji$1@dont-email.me> <20240903084440.0000663d@gmail.com>
 <20240903103327.395@kylheku.com> <20240903113937.000008a3@gmail.com>
 <20240903130000.933@kylheku.com> <20240903132547.00000656@gmail.com>
 <87seug1iyj.fsf@nosuchdomain.example.com> <20240903155649.659@kylheku.com>
 <87jzfs1f6p.fsf@nosuchdomain.example.com> <vb87o7$3h6uk$2@dont-email.me>
 <87frqg1da2.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 04 Sep 2024 16:30:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2b69e3d83e73f0011c7c1e15634565f6";
	logging-data="4062119"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18cHpAmaoCeLa3V+EHqOpOr44zWVLehD8Q="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:ObuJdO3j0gwIJon+V2v8kWsQKjM=
Bytes: 3917

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/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca