[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] build: Fix make warning if there is no cppcheck



If cppcheck is not present, the following warning appears during build:
which: no cppcheck in ([...])
/bin/sh: cppcheck: command not found

Fix the problem by using shell code inside the cppcheck-version rule to
also prevent unneeded call of which when something else than cppcheck is
built.

Reported-by: Julien Grall <julien@xxxxxxx>
Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
---
 xen/Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index 15388703bc..e8d8ed71bc 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -694,12 +694,14 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c 
$(objtree)/include/generated/autoconf.h
        $(call if_changed,cppcheck_xml)
 
 cppcheck-version:
-ifeq ($(shell which $(CPPCHECK)),)
-       $(error Cannot find cppcheck executable: $(CPPCHECK))
-endif
-ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
-       $(error Please upgrade your cppcheck to version 2.7 or greater)
-endif
+       @if ! which $(CPPCHECK) > /dev/null 2>&1; then \
+               echo "Cannot find cppcheck executable: $(CPPCHECK)"; \
+               exit 1; \
+       fi
+       @if [ "$$($(CPPCHECK) --version | awk '{print ($$2 < 2.7)}')" -eq 1 ]; 
then \
+               echo "Please upgrade your cppcheck to version 2.7 or greater"; \
+               exit 1; \
+       fi
 
 # Put this in generated headers this way it is cleaned by include/Makefile
 $(objtree)/include/generated/compiler-def.h:
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.