Message ID | CAL1ky9r9FutN2baRhV_WO-stV1FHKq-par4uv-VfCdofcGhSVg@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | lib/raid6: Let $(UNROLL) rules work with BSD userland. | expand |
On Mon, Dec 14, 2020 at 5:21 PM John Millikin <jmillikin@gmail.com> wrote: > > BSD awk is fussy about the order of '-v' and '-f' flags, and it requires > a space after the flag name. GNU awk is fine with both forms, so the > definition of 'cmd_unroll' can be trivially tweaked to let the lib/raid6 > Makefile work with either awk. Does it depend on the awk version? I tried this in FreeBSD 12. masahiro@:~ $ cat test.awk BEGIN { print N } masahiro@:~ $ awk --version awk version 20121220 (FreeBSD) masahiro@:~ $ awk -ftest.awk -vN=1 1 It worked for me. > Signed-off-by: John Millikin <john@john-millikin.com> > --- > lib/raid6/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile > index b4c0df6d706d..c770570bfe4f 100644 > --- a/lib/raid6/Makefile > +++ b/lib/raid6/Makefile > @@ -48,7 +48,7 @@ endif > endif > > quiet_cmd_unroll = UNROLL $@ > - cmd_unroll = $(AWK) -f$(srctree)/$(src)/unroll.awk -vN=$* < $< > $@ > + cmd_unroll = $(AWK) -v N=$* -f $(srctree)/$(src)/unroll.awk < $< > $@ > > targets += int1.c int2.c int4.c int8.c int16.c int32.c > $(obj)/int%.c: $(src)/int.uc $(src)/unroll.awk FORCE > -- > 2.24.3 (Apple Git-128)
On Wed, Dec 16, 2020 at 2:46 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > Does it depend on the awk version? > > I tried this in FreeBSD 12. > > masahiro@:~ $ cat test.awk > BEGIN { print N } > masahiro@:~ $ awk --version > awk version 20121220 (FreeBSD) > masahiro@:~ $ awk -ftest.awk -vN=1 > 1 > > It worked for me. > Yes, it appears to be version dependent. Apologies for the confusion -- I didn't realize there were multiple dialects of BSD awk. On FreeBSD and OpenBSD awk works with the existing command. On NetBSD and macOS awk fails with the following error: $ touch unroll.awk input.c $ awk -f./unroll.awk -vN=0 < input.c awk: can't open file -vN=0 source line number 1 source file -vN=0 context is >>> <<< $ My patch lets the $(UNROLL) command support the NetBSD/macOS variant -- this is needed to support building the Linux kernel on a macOS host machine.
On Wed, Dec 23, 2020 at 1:24 PM John Millikin <jmillikin@gmail.com> wrote: > > On Wed, Dec 16, 2020 at 2:46 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > Does it depend on the awk version? > > > > I tried this in FreeBSD 12. > > > > masahiro@:~ $ cat test.awk > > BEGIN { print N } > > masahiro@:~ $ awk --version > > awk version 20121220 (FreeBSD) > > masahiro@:~ $ awk -ftest.awk -vN=1 > > 1 > > > > It worked for me. > > > > Yes, it appears to be version dependent. Apologies for the confusion > -- I didn't realize there were multiple dialects of BSD awk. > > On FreeBSD and OpenBSD awk works with the existing command. On NetBSD > and macOS awk fails with the following error: > > $ touch unroll.awk input.c > $ awk -f./unroll.awk -vN=0 < input.c > awk: can't open file -vN=0 > source line number 1 source file -vN=0 > context is > >>> <<< > $ > > My patch lets the $(UNROLL) command support the NetBSD/macOS variant > -- this is needed to support building the Linux kernel on a macOS host > machine. I see, the default awk on macOS is quite old. $ awk --version awk version 20070501 Please update the commit description to mention this issue happens on NetBSD/macOS.
diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile index b4c0df6d706d..c770570bfe4f 100644 --- a/lib/raid6/Makefile +++ b/lib/raid6/Makefile @@ -48,7 +48,7 @@ endif endif quiet_cmd_unroll = UNROLL $@ - cmd_unroll = $(AWK) -f$(srctree)/$(src)/unroll.awk -vN=$* < $< > $@ + cmd_unroll = $(AWK) -v N=$* -f $(srctree)/$(src)/unroll.awk < $< > $@ targets += int1.c int2.c int4.c int8.c int16.c int32.c $(obj)/int%.c: $(src)/int.uc $(src)/unroll.awk FORCE
BSD awk is fussy about the order of '-v' and '-f' flags, and it requires a space after the flag name. GNU awk is fine with both forms, so the definition of 'cmd_unroll' can be trivially tweaked to let the lib/raid6 Makefile work with either awk. Signed-off-by: John Millikin <john@john-millikin.com> --- lib/raid6/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)