Skip to content

Commit 10518de

Browse files
junjiemao1lijinxia
authored andcommitted
make: add functions for checking build prerequisites
This patch introduces the following functions for Makefiles: check_dep_exec <exe> Check existence of the executable <exe> check_dep_pylib <lib> Check existence of the python library <lib> 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 <junjie.mao@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
1 parent bce7ed1 commit 10518de

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

scripts/deps.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# check the existence of a specific executable
2+
# usage: check_dep_exec <executable name>
3+
define check_dep_exec =
4+
BUILD_DEPS += check_$(1)
5+
check_$(1):
6+
@if ! which $(1) > /dev/null; then \
7+
echo "******** Missing prerequisite tool ********"; \
8+
echo "Cannot find executable *$(1)*"; \
9+
echo "Please refer to the Getting Started Guide" \
10+
"for installation instructions"; \
11+
exit 1; \
12+
fi
13+
endef
14+
15+
# check the existence of a specific python library
16+
# usage: check_dep_pylib <library name>
17+
define check_dep_pylib =
18+
BUILD_DEPS += check_$(1)
19+
check_$(1):
20+
@if ! pip list 2>/dev/null | grep $(1) > /dev/null 2>&1; then \
21+
echo "******** Missing prerequisite tool ********"; \
22+
echo "The python library *$(1)* is not installed"; \
23+
echo "Please refer to the Getting Started Guide" \
24+
"for installation instructions"; \
25+
exit 1; \
26+
fi
27+
endef

0 commit comments

Comments
 (0)