From 10518de72246276b1708c608e527f8aefafc4f9a Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Tue, 29 May 2018 23:34:33 +0800 Subject: [PATCH] make: add functions for checking build prerequisites This patch introduces the following functions for Makefiles: check_dep_exec Check existence of the executable check_dep_pylib Check existence of the python library Calling and evaluting the functions will create a check_xxx target and add the target to the variable BUILD_DEPS. Thus it is sufficient to add the following to a Makefile for checking a number of build dependencies. include deps.mk $(eval $(call check_dep_exec,python)) $(eval $(call check_dep_pylib,Sphinx)) all: $(BUILD_DEPS) ... v4 -> v5: * No changes. v3 -> v4: * No changes. v2 -> v3: * No changes. v1 -> v2: * New in v2. Signed-off-by: Junjie Mao Reviewed-by: Kevin Tian Reviewed-by: Zhao Yakui --- scripts/deps.mk | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/deps.mk diff --git a/scripts/deps.mk b/scripts/deps.mk new file mode 100644 index 000000000..a2199f066 --- /dev/null +++ b/scripts/deps.mk @@ -0,0 +1,27 @@ +# check the existence of a specific executable +# usage: check_dep_exec +define check_dep_exec = +BUILD_DEPS += check_$(1) +check_$(1): + @if ! which $(1) > /dev/null; then \ + echo "******** Missing prerequisite tool ********"; \ + echo "Cannot find executable *$(1)*"; \ + echo "Please refer to the Getting Started Guide" \ + "for installation instructions"; \ + exit 1; \ + fi +endef + +# check the existence of a specific python library +# usage: check_dep_pylib +define check_dep_pylib = +BUILD_DEPS += check_$(1) +check_$(1): + @if ! pip list 2>/dev/null | grep $(1) > /dev/null 2>&1; then \ + echo "******** Missing prerequisite tool ********"; \ + echo "The python library *$(1)* is not installed"; \ + echo "Please refer to the Getting Started Guide" \ + "for installation instructions"; \ + exit 1; \ + fi +endef