blob: eec469b69094d490e55ee8026df44dd400c09292 [file] [log] [blame]
Joey Armstrong99a72d02023-06-09 10:26:42 -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))
19# is-null-var = $(if $($(1)),$(null),$(error $(1)= is undef))
20
21## [origin]
22## foreach: var=automatic, origin=undef
23is-null-var-orig = $(strip \
24 $(foreach varname,$(1),\
25 $(warning ** is-null-var: varname=$(varname), origin=$(origin 1), origin=$(origin var))\
26 )\
27)
28# $(if $(1),$(call is-null-var-indirect,$($(1))),$(error $(1)= is undef)))\
29
30is-null-var-indirect = $(if $(1),$(null),$(error $(1)= is undef))
31
32# origin - undefned
33# default
34# environment
35# environment override
36# automatic
37# null(blah) ? - true
38
39## -----------------------------------------------------------------------
40## Intent: Given an indirect var containing varname of a makefile *_ROOT
41## parent director, derive a *_MKDIR variable and conditionally
42## include the makefile hierarchy.
43## -----------------------------------------------------------------------
44## Given:
45## o var containing OPT_ROOT=path
46## Return:
47## o OPT_MKDIR=$(OPT_ROOT)/makefiles
48## o If exists include $(OPT_MKDIR)/include.mk
49## -----------------------------------------------------------------------
50# library-include := $(call mk-library-include,blah)
51
52mk-library-include=$(strip \
53 $(warning mk-library-include: $$1[$(1)] = [$($(1))]))\
54 $(call is-null-var,1)\
55 $(foreach var,$($(1)),\
56 $(info var=$(var) is-null=$(call is-null-var,var))\
57 $(foreach val,$$(var),\
58 $(info val=$(val))\
59 $(foreach makedir,$(subst _ROOT,_MKDIR,$(var)),\
60$(warning makedir=$(makedir))\
61)\
62)\
63)\
64)
65
66
67# $(warning makedir=$(makedir))\
68 $(if $($(makedir)),$(null),\
69 $(eval $(makedir)=$$$$($(var))/makefiles)\
70$(warning $(makedir) = $($($(makedir))))\
71$(info $$(wildcard $(val)/makefiles/include.mk) = $(wildcard $(val)/makefiles/include.mk))\
72 $(foreach mf,$(wildcard $(wildcard $(val)/makefiles/include.mk)),\
73$(warning $$(eval include $(mf)))\
74 $(eval include $(mf)))\
75))))\
76)
77
78$(if $(DEBUG-bootstrap_mk),$(warning LEAVE))
79
80# [EOF]