• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# compiler-rt Configuration Support
2#
3# This should be included following 'lib_util.mk'.
4
5# The simple variables configurations can define.
6PlainConfigVariables := Configs Description
7PerConfigVariables := UniversalArchs Arch $(AvailableOptions)
8RequiredConfigVariables := Configs Description
9
10###
11# Load Platforms
12
13# Template: subdir_traverse_template subdir
14define load_platform_template
15$(call Set,PlatformName,$(basename $(notdir $(1))))
16ifneq ($(DEBUGMAKE),)
17  $$(info MAKE: $(PlatformName): Loading platform)
18endif
19
20# Construct the variable key for this directory.
21$(call Set,PlatformKey,Platform.$(PlatformName))
22$(call Append,PlatformKeys,$(PlatformKey))
23$(call Set,$(PlatformKey).Name,$(PlatformName))
24$(call Set,$(PlatformKey).Path,$(1))
25
26# Reset platform specific variables to sentinel value.
27$$(foreach var,$(PlainConfigVariables) $(PerConfigVariables),\
28  $$(call Set,$$(var),UNDEFINED))
29$$(foreach var,$(PerConfigVariables),\
30  $$(foreach config,$$(Configs),\
31    $$(call Set,$$(var).$$(config),UNDEFINED)))
32$$(foreach var,$(PerConfigVariables),\
33  $$(foreach arch,$(AvailableArchs),\
34    $$(call Set,$$(var).$$(arch),UNDEFINED)))
35
36# Get the platform variables.
37include make/options.mk
38include $(1)
39
40# Check for undefined required variables.
41$$(foreach var,$(RequiredConfigVariables),\
42  $$(if $$(call strneq,UNDEFINED,$$($$(var))),, \
43	$$(error $(Dir): variable '$$(var)' was not undefined)))
44
45# Check that exactly one of UniversalArchs or Arch was defined.
46$$(if $$(and $$(call strneq,UNDEFINED,$$(UniversalArchs)),\
47             $$(call strneq,UNDEFINED,$$(Arch))),\
48    $$(error '$(1)': cannot define both 'UniversalArchs' and 'Arch'))
49$$(if $$(or $$(call strneq,UNDEFINED,$$(UniversalArchs)),\
50            $$(call strneq,UNDEFINED,$$(Arch))),,\
51    $$(error '$(1)': must define one of 'UniversalArchs' and 'Arch'))
52
53# Collect all the platform variables for subsequent use.
54$$(foreach var,$(PlainConfigVariables) $(PerConfigVariables),\
55  $$(if $$(call strneq,UNDEFINED,$$($$(var))),\
56    $$(call CopyVariable,$$(var),$(PlatformKey).$$(var))))
57$$(foreach var,$(PerConfigVariables),\
58  $$(foreach config,$$(Configs),\
59    $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(config))),\
60      $$(call CopyVariable,$$(var).$$(config),$(PlatformKey).$$(var).$$(config))))\
61  $$(foreach arch,$(AvailableArchs),\
62    $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(arch))),\
63      $$(call CopyVariable,$$(var).$$(arch),$(PlatformKey).$$(var).$$(arch))))\
64  $$(foreach config,$$(Configs),\
65    $$(foreach arch,$(AvailableArchs),\
66      $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(config).$$(arch))),\
67        $$(call CopyVariable,$$(var).$$(config).$$(arch),\
68                $(PlatformKey).$$(var).$$(config).$$(arch))))))
69
70ifneq ($(DEBUGMAKE),)
71  $$(info MAKE: $(PlatformName): Done loading platform)
72endif
73endef
74
75# Evaluate this now so we do not have to worry about order of evaluation.
76PlatformFiles := $(wildcard make/platform/*.mk)
77ifneq ($(DEBUGMAKE),)
78 $(info MAKE: Loading platforms: $(PlatformFiles))
79endif
80
81$(foreach file,$(PlatformFiles),\
82  $(eval $(call load_platform_template,$(file))))
83