Re: [PATCH v3 3/5] kbuild: add read-file macro

From: Alexander Lobakin
Date: Mon Dec 12 2022 - 09:38:12 EST


From: Nicolas Schier <nicolas@xxxxxxxxx>
Date: Sat, 10 Dec 2022 22:02:48 +0100

> On Sat, Dec 10, 2022 at 11:10:12PM +0900 Masahiro Yamada wrote:
> > On Thu, Dec 8, 2022 at 1:25 AM Alexander Lobakin
> > <alexandr.lobakin@xxxxxxxxx> wrote:
> > >
> > > From: Alexander Lobakin <alexandr.lobakin@xxxxxxxxx>
> > > Date: Wed, 7 Dec 2022 16:40:44 +0100
> > >
> > > > From: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> > > > Date: Sun, 27 Nov 2022 07:56:22 +0900
> > > >
> > > > > Since GNU Make 4.2, $(file ...) supports the read operater '<', which
> > > > > is useful to read a file without forking any process. No warning is
> > > > > shown even if the input file is missing.
> > >
> > > [...]
> > >
> > > > Great stuff. Used it in my upcoming series to simplify things, works
> > > > as expected.
> > > >
> > > > sed-syms = $(subst $(space),\|,$(foreach file,$(sym-files-y),$(call read-file,$(file))))
> > > >
> > > > The only thing that came to my mind while I was implementing the
> > > > oneliner above: maybe add ability to read multiple files? For now,
> > > > I used a foreach, could it be somehow incorporated into read-file
> > > > already?
> > >
> > > Oh, nevermind. This one also works:
> > >
> > > sed-syms = $(subst $(space),\|,$(call read-file,$(sym-files-y)))
> > >
> > > So I believe read-file works for an arbitrary number of files.
> >
> >
> >
> > Really?
> >
> >
> > In my understanding, $(call read-file, foo bar) reads a single file "foo bar".
> > (a space in the file name).
>
> yes, except for make < 4.2, due to:
>
> read-file = $(shell cat $1 2>/dev/null)

$ make --version
GNU Make 4.3
Built for x86_64-redhat-linux-gnu

But breh, I forgot to port test-ge, so Kbuild was always calling
cat :D :clownface:
Correct, current implementation (as of v3) reads only single file.
Not sure whether read-file should handle multiple at a time.

Thanks,
Olek