Skip to content

Commit 9f9f536

Browse files
committed
build: fix CHECK_VERSION macro not working
The CHECK_VERSION macro sometimes produced false negatives due to the redirection from stderr to /dev/null. Make sure that the package exists before calling --version and only redirect stdout in CHECK_VERSION.
1 parent 41fa12d commit 9f9f536

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,17 @@ define newline
109109

110110
endef
111111

112+
# Make sure that a package exists on the build system (i.e. an executable)
113+
define CHECK_PACKAGE
114+
if ! which $(1) > /dev/null ; then \
115+
echo "error: $(1): package not found" >&2; \
116+
exit 1; \
117+
fi
118+
endef
119+
112120
define CHECK_VERSION
113-
if ! $(1) --version | grep '$(2)' &> /dev/null; then \
121+
$(call CHECK_PACKAGE,$(1)); \
122+
if ! $(1) --version | grep '$(2)' > /dev/null; then \
114123
echo "error: $(1): invalid version (expected $(2))" >&2; \
115124
exit 1; \
116125
fi

0 commit comments

Comments
 (0)