summaryrefslogtreecommitdiffstats
path: root/rules/pre
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2021-02-12 08:41:58 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2021-02-12 09:44:21 +0100
commit80d19e055622e87116dfd651d76d2355ad54eec0 (patch)
tree693e04dd1621060a7177f793a8358fb5e2493b0c /rules/pre
parent7ec4e30642d7ac7e044447ca54465e8ed09655e7 (diff)
downloadptxdist-80d19e055622e87116dfd651d76d2355ad54eec0.tar.gz
ptxdist-80d19e055622e87116dfd651d76d2355ad54eec0.tar.xz
rules: new macros ptx/config-version and ptx/config-md5
There are several packages that get the version/md5 from the ptxconfig variables PTXCONF_<PKG>_VERSION / PTXCONF_<PKG>_MD5. These new new macros can be used for this and add basic sanity checking: If the package is enable, then the version and md5 must not be empty. Otherwise the string 'undefined' is returned to make it obvious that the version is currently not available. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'rules/pre')
-rw-r--r--rules/pre/000-option-disabled.make40
1 files changed, 40 insertions, 0 deletions
diff --git a/rules/pre/000-option-disabled.make b/rules/pre/000-option-disabled.make
index 41a1b8af4..fa8f35828 100644
--- a/rules/pre/000-option-disabled.make
+++ b/rules/pre/000-option-disabled.make
@@ -145,4 +145,44 @@ define ptx/yesno
$(call ptx/ifdef, $(1), yes, no)
endef
+
+define ptx/config-foo
+$(strip $(if $($(strip $(1))),
+ $(if $(call remove_quotes,$($(2))),
+ $(call remove_quotes,$($(2))),
+ $(error $(2) is undefined or empty)),
+ undefined))
+endef
+
+#
+# $(call ptx/config-version, PTXCONF_SYMBOL,PTXCONF_SYMBOL2) returns:
+# - if PTXCONF_SYMBOL is defined:
+# - $(PTXCONF_SYMBOL2_VERSION) without quotes if it's not empty
+# - fails with an error otherwise
+# - 'undefined if PTXCONF_SYMBOL is not defined
+# If PTXCONF_SYMBOL2 is empty then PTXCONF_SYMBOL_VERSION is used instead.
+#
+# This makes it easy to ensure, that the version of a package is defined if
+# the package is enabled.
+#
+define ptx/config-version
+$(call ptx/config-foo,$(strip $(1)),$(if $(strip $(2)),$(strip $(2))_VERSION,$(strip $(1))_VERSION))
+endef
+
+
+#
+# $(call ptx/config-md5, PTXCONF_SYMBOL,PTXCONF_SYMBOL2) returns:
+# - if PTXCONF_SYMBOL is defined:
+# - $(PTXCONF_SYMBOL2_MD5) without quotes if it's not empty
+# - fails with an error otherwise
+# - 'undefined if PTXCONF_SYMBOL is not defined
+# If PTXCONF_SYMBOL2 is empty then PTXCONF_SYMBOL_MD5 is used instead.
+#
+# This makes it easy to ensure, that the md5 sum of a package is defined if
+# the package is enabled.
+#
+define ptx/config-md5
+$(call ptx/config-foo,$(strip $(1)),$(if $(strip $(2)),$(strip $(2))_MD5,$(strip $(1))_MD5))
+endef
+
# vim: syntax=make