blob: 0ac15051bb411473a7e2f3a6ca9d46ed14dfa3f6 [file] [log] [blame]
Leonardo Sandoval667fd722020-09-11 12:50:19 -05001#
2# Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7# Convenience function for adding build definitions
8# $(eval $(call add_define,BAR_DEFINES,FOO)) will have:
9# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
10# inside the BAR_DEFINES variable.
11define add_define
12$(1) += -D$(2)$(if $(value $(2)),=$(value $(2)),)
13endef
14
15# Convenience function for verifying option has a boolean value
16# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1
17define assert_boolean
18$(and $(patsubst 0,,$(value $(1))),$(patsubst 1,,$(value $(1))),$(error $(1) must be boolean))
19endef
20
21# CREATE_SEQ is a recursive function to create sequence of numbers from 1 to
22# $(2) and assign the sequence to $(1)
23define CREATE_SEQ
24$(if $(word $(2), $($(1))),\
25 $(eval $(1) += $(words $($(1))))\
26 $(eval $(1) := $(filter-out 0,$($(1)))),\
27 $(eval $(1) += $(words $($(1))))\
28 $(call CREATE_SEQ,$(1),$(2))\
29)
30endef