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