From 547d9f0802d99d131a6ef38e37b95a1008edaae0 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Tue, 20 Nov 2018 11:45:37 +0100 Subject: [PATCH] makefiles/utils: Add a function for checking that a string is not empty. A call to `$(ensure_value x,y)` will fail with message y if x is empty, and otherwise return x. This can be useto write more compact makefiles, while still producing friendly error messages. --- makefiles/utils/checks.mk | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 makefiles/utils/checks.mk diff --git a/makefiles/utils/checks.mk b/makefiles/utils/checks.mk new file mode 100644 index 0000000000..8df6c8435d --- /dev/null +++ b/makefiles/utils/checks.mk @@ -0,0 +1,11 @@ +# Utilities to produce errors inside Make +# Use this functions to produce friendlier error messages. + +# Produce an error if the value is empty +# +# Parameters +# value: a string which should not be empty +# message: The error message to display. +# Returns: +# the first argument, if it is not empty. +ensure_value = $(if $(1),$(1),$(error $(2)))