[klibc] [PATCH] klcc: Remove the need for bash

Greg Thelen gthelen at google.com
Tue Sep 8 12:35:58 PDT 2020


Ben Hutchings <ben at decadent.org.uk> wrote:

> On Sat, 2020-07-25 at 10:59 +0200, Olliver Schinagl wrote:
>> Currently, in the entire klibc bash is only used to identify the path of
>> the perl binary. It is doing so using the bash built-in 'type' function,
>> which is POSIX compliant according to [0], but the option -c is not.
>> 
>> By using `command -v` instead, we achieve the same result, in a POSIX
>> compliant manor [1], potentially removing the unneeded bash dependency.
>> 
>> 0 https://www.unix.com/man-page/posix/1p/type/
>> 1 https://www.unix.com/man-page/posix/1p/command/
>> 
>> Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
>
> Applied, thanks.
>
> Ben.
>
>> ---
>>  klcc/Kbuild | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/klcc/Kbuild b/klcc/Kbuild
>> index eae753ff..0e625802 100644
>> --- a/klcc/Kbuild
>> +++ b/klcc/Kbuild
>> @@ -35,7 +35,7 @@ targets := $(KLIBCCROSS)klcc
>>  quiet_cmd_klcc = GEN     $@
>>        cmd_klcc = $(PERL) $< $(srctree)/$(src)/klcc.in \
>>                              $(obj)/$(KLIBCCROSS)klibc.config \
>> -                            $(shell bash -c 'type -p $(PERL)') \
>> +                            $(shell command -v $(PERL)) \
>>  			      > $@ || ( rm -f $@ ; exit 1 ) && \
>>  			      chmod a+x $@
>>  $(obj)/$(KLIBCCROSS)klcc: $(src)/makeklcc.pl $(src)/klcc.in \

This doesn't work with older versions of make.  make 4.2.1 seems common
now and does not support $(shell command).

$ cat Makefile
$(info take1: $(shell command -v ls))
$(info take2: $(shell bash -c 'type -p ls'))

all:
        @true

$ make-3.81/make
make: command: Command not found
take1:
take2: /bin/ls

$ make-4.2.1/make
make: command: Command not found
take1:
take2: /bin/ls

$ make-4.3/make
take1: /bin/ls
take2: /bin/ls

https://git.savannah.gnu.org/cgit/make.git/commit/?id=1af314465e5dfe3e8baa839a32a72e83c04f26ef
looks to be required and is in make 4.2.90+.

The kernel went with
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=913ab9780fc021298949cc5514d6255a008e69f9

So we might want:
  $(shell command -v $(PERL) 2> /dev/null)



More information about the klibc mailing list