Home | History | Annotate | Download | only in make
      1 # compiler-rt Configuration Support
      2 #
      3 # This should be included following 'lib_util.mk'.
      4 
      5 # The simple variables configurations can define.
      6 PlainConfigVariables := Configs Description
      7 PerConfigVariables := UniversalArchs Arch $(AvailableOptions)
      8 RequiredConfigVariables := Configs Description
      9 
     10 ###
     11 # Load Platforms
     12 
     13 # Template: subdir_traverse_template subdir
     14 define load_platform_template
     15 $(call Set,PlatformName,$(basename $(notdir $(1))))
     16 ifneq ($(DEBUGMAKE),)
     17   $$(info MAKE: $(PlatformName): Loading platform)
     18 endif
     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.
     37 include make/options.mk
     38 include $(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 
     70 ifneq ($(DEBUGMAKE),)
     71   $$(info MAKE: $(PlatformName): Done loading platform)
     72 endif
     73 endef
     74 
     75 # Evaluate this now so we do not have to worry about order of evaluation.
     76 PlatformFiles := $(wildcard make/platform/*.mk)
     77 ifneq ($(DEBUGMAKE),)
     78  $(info MAKE: Loading platforms: $(PlatformFiles))
     79 endif
     80 
     81 $(foreach file,$(PlatformFiles),\
     82   $(eval $(call load_platform_template,$(file))))
     83