blob: 4a8f78b41d2f6f8254164dccf5fe375b193dc957 [file] [log] [blame]
Joey Armstrong449ce7a2023-07-18 18:32:24 -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),\
Joey Armstrongb5a5e8c2023-09-20 12:05:03 -040051 $(eval $(makedir)=$$$$($(var))/makefiles-orig)\
Joey Armstrong449ce7a2023-07-18 18:32:24 -040052$(warning $(makedir) = $($($(makedir))))\
Joey Armstrongb5a5e8c2023-09-20 12:05:03 -040053$(info $$(wildcard $(val)/makefiles-orig/include.mk) = $(wildcard $(val)/makefiles-orig/include.mk))\
54 $(foreach mf,$(wildcard $(wildcard $(val)/makefiles-orig/include.mk)),\
Joey Armstrong449ce7a2023-07-18 18:32:24 -040055$(warning $$(eval include $(mf)))\
56 $(eval include $(mf)))\
57)
58
59$(if $(DEBUG-bootstrap_mk),$(warning LEAVE))
60
61# [EOF]