blob: d8264a123a61b9cfd9c8781a2fdc4dd428df3194 [file] [log] [blame]
Joey Armstronga6890342023-06-01 17:07:51 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Intent: Dependency-free macros used to source library makefiles
4# and define the build environment.
5# -----------------------------------------------------------------------
6
7$(if $(DEBUG-bootstrap_mk),$(warning ENTER))
8
9##---------------------##
10##---] CONSTANTS [---##
11##---------------------##
12is-false = $(if $(1),true,$(null))
13is-true = $(if $(1),$(null),true)
14
15##--------------------------##
16##---] LIBRARY MACROS [---##
17##--------------------------##
18is-null = $(if $(1),$(null),$(error $(1)= is undef))
Joey Armstrongd26858f2023-07-08 15:52:16 -040019is-null-var = $(if $$(1),$(null),$(error $(1)= is undef))
Joey Armstronga6890342023-06-01 17:07:51 -040020
21## -----------------------------------------------------------------------
22## Intent: Given an indirect var containing varname of a makefile *_ROOT
23## parent director, derive a *_MKDIR variable and conditionally
24## include the makefile hierarchy.
25## -----------------------------------------------------------------------
26## Given:
27## o var containing OPT_ROOT=path
28## Return:
29## o OPT_MKDIR=$(OPT_ROOT)/makefiles
30## o If exists include $(OPT_MKDIR)/include.mk
31## -----------------------------------------------------------------------
Joey Armstronga6890342023-06-01 17:07:51 -040032mk-library-include=$(strip \
Joey Armstrongd26858f2023-07-08 15:52:16 -040033 $(warning mk-library-include: $(1) = $($(1)))\
Joey Armstronga6890342023-06-01 17:07:51 -040034 $(call is-null-var,1)\
Joey Armstrongd26858f2023-07-08 15:52:16 -040035 $(foreach var,$$(1),\
Joey Armstronga6890342023-06-01 17:07:51 -040036 $(info var=$(var) is-null=$(call is-null-var,var))\
37 $(foreach val,$$(var),\
Joey Armstrongd26858f2023-07-08 15:52:16 -040038 $(info val=$(val))\
Joey Armstronga6890342023-06-01 17:07:51 -040039 $(foreach makedir,$(subst _ROOT,_MKDIR,$(var)),\
40$(warning makedir=$(makedir))\
Joey Armstronga6890342023-06-01 17:07:51 -040041 $(if $($(makedir)),$(null),\
42 $(eval $(makedir)=$$$$($(var))/makefiles)\
43$(warning $(makedir) = $($($(makedir))))\
44$(info $$(wildcard $(val)/makefiles/include.mk) = $(wildcard $(val)/makefiles/include.mk))\
45 $(foreach mf,$(wildcard $(wildcard $(val)/makefiles/include.mk)),\
46$(warning $$(eval include $(mf)))\
47 $(eval include $(mf)))\
Joey Armstronga6890342023-06-01 17:07:51 -040048)
49
50$(if $(DEBUG-bootstrap_mk),$(warning LEAVE))
51
52# [EOF]