xen/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
If cppcheck is not present, the following warning appears during build:
which: no cppcheck in ([...])
/bin/sh: cppcheck: command not found
Fix this by hiding the error output from which and only try to execute
cppcheck --version if we have a cppcheck.
Reported-by: Julien Grall <julien@xen.org>
Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
xen/Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/xen/Makefile b/xen/Makefile
index 15388703bc..f42be3d0ab 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -694,12 +694,13 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
$(call if_changed,cppcheck_xml)
cppcheck-version:
-ifeq ($(shell which $(CPPCHECK)),)
+ifeq ($(shell which $(CPPCHECK) 2> /dev/null),)
$(error Cannot find cppcheck executable: $(CPPCHECK))
-endif
+else
ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
$(error Please upgrade your cppcheck to version 2.7 or greater)
endif
+endif
# Put this in generated headers this way it is cleaned by include/Makefile
$(objtree)/include/generated/compiler-def.h:
--
2.25.1
Hi Bertrand, On 20/05/2022 11:49, Bertrand Marquis wrote: > If cppcheck is not present, the following warning appears during build: > which: no cppcheck in ([...]) > /bin/sh: cppcheck: command not found > > Fix this by hiding the error output from which and only try to execute > cppcheck --version if we have a cppcheck. > > Reported-by: Julien Grall <julien@xen.org> > Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> This solves the warning so: Acked-by: Julien Grall <jgrall@amazon.com> In the long term, I think using what Jan suggested would be better. Cheers, -- Julien Grall
On 20.05.2022 12:49, Bertrand Marquis wrote:
> --- a/xen/Makefile
> +++ b/xen/Makefile
> @@ -694,12 +694,13 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
> $(call if_changed,cppcheck_xml)
>
> cppcheck-version:
> -ifeq ($(shell which $(CPPCHECK)),)
> +ifeq ($(shell which $(CPPCHECK) 2> /dev/null),)
> $(error Cannot find cppcheck executable: $(CPPCHECK))
> -endif
> +else
> ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
> $(error Please upgrade your cppcheck to version 2.7 or greater)
> endif
> +endif
While I agree this will silence things, I still would prefer if you
switched to $(if ...) inside the rule - there's no need to invoke the
shell while parsing the makefile. Anything like this only needlessly
slows down the build. Not by much, but it sums up.
Jan
Hi Jan,
> On 20 May 2022, at 12:06, Jan Beulich <jbeulich@suse.com> wrote:
>
> On 20.05.2022 12:49, Bertrand Marquis wrote:
>> --- a/xen/Makefile
>> +++ b/xen/Makefile
>> @@ -694,12 +694,13 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
>> $(call if_changed,cppcheck_xml)
>>
>> cppcheck-version:
>> -ifeq ($(shell which $(CPPCHECK)),)
>> +ifeq ($(shell which $(CPPCHECK) 2> /dev/null),)
>> $(error Cannot find cppcheck executable: $(CPPCHECK))
>> -endif
>> +else
>> ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
>> $(error Please upgrade your cppcheck to version 2.7 or greater)
>> endif
>> +endif
>
> While I agree this will silence things, I still would prefer if you
> switched to $(if ...) inside the rule - there's no need to invoke the
> shell while parsing the makefile. Anything like this only needlessly
> slows down the build. Not by much, but it sums up.
I will submit a v2 to solve this properly.
Cheers
Bertrand
>
> Jan
>
© 2016 - 2026 Red Hat, Inc.