summaryrefslogtreecommitdiff
path: root/make/lib_platforms.mk
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-01-18 06:49:33 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-01-18 06:49:33 +0000
commit48464e0ee1c2de5bcbf0d609348f55d0c301085d (patch)
treeba4925beb5fbba97626df7306b3c452ffe52ceae /make/lib_platforms.mk
parentba990c4981acfa55893e809e5c72de2800e6bf0c (diff)
downloadcompiler-rt-48464e0ee1c2de5bcbf0d609348f55d0c301085d.tar.gz
compiler-rt-48464e0ee1c2de5bcbf0d609348f55d0c301085d.tar.bz2
compiler-rt-48464e0ee1c2de5bcbf0d609348f55d0c301085d.tar.xz
Add support for "platform" configurations, which define a suite of compiler-rt
libraries to generate. - Each library may be built with different flags and for different architectures, and there is support for building Darwin style fat archives. - Uses an ambituous amount of make programming, but should be hidden to users and developers. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@93720 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'make/lib_platforms.mk')
-rw-r--r--make/lib_platforms.mk82
1 files changed, 82 insertions, 0 deletions
diff --git a/make/lib_platforms.mk b/make/lib_platforms.mk
new file mode 100644
index 00000000..55573747
--- /dev/null
+++ b/make/lib_platforms.mk
@@ -0,0 +1,82 @@
+# compiler-rt Configuration Support
+#
+# This should be included following 'lib_util.mk'.
+
+# The simple variables configurations can define.
+PlainConfigVariables := Configs UniversalArchs Description
+PerConfigVariables := Arch $(AvailableOptions)
+RequiredConfigVariables := Configs Description
+
+###
+# Load Platforms
+
+# Template: subdir_traverse_template subdir
+define load_platform_template
+$(call Set,PlatformName,$(basename $(notdir $(1))))
+ifneq ($(DEBUGMAKE),)
+ $$(info MAKE: $(PlatformName): Loading platform)
+endif
+
+# Construct the variable key for this directory.
+$(call Set,PlatformKey,Platform.$(PlatformName))
+$(call Append,PlatformKeys,$(PlatformKey))
+$(call Set,$(PlatformKey).Name,$(PlatformName))
+$(call Set,$(PlatformKey).Path,$(1))
+
+# Reset platform specific variables to sentinel value.
+$$(foreach var,$(PlainConfigVariables) $(PerConfigVariables),\
+ $$(call Set,$$(var),UNDEFINED))
+$$(foreach var,$(PerConfigVariables),\
+ $$(foreach config,$$(Configs),\
+ $$(call Set,$$(var).$$(config),UNDEFINED)))
+$$(foreach var,$(PerConfigVariables),\
+ $$(foreach arch,$(AvailableArchs),\
+ $$(call Set,$$(var).$$(arch),UNDEFINED)))
+
+# Get the platform variables.
+include make/options.mk
+include $(1)
+
+# Check for undefined required variables.
+$$(foreach var,$(RequiredConfigVariables),\
+ $$(if $$(call strneq,UNDEFINED,$$($$(var))),, \
+ $$(error $(Dir): variable '$$(var)' was not undefined)))
+
+# Check that exactly one of UniversalArchs or Arch was defined.
+$$(if $$(and $$(call strneq,UNDEFINED,$$(UniversalArchs)),\
+ $$(call strneq,UNDEFINED,$$(Arch))),\
+ $$(error '$(1)': cannot define both 'UniversalArchs' and 'Arch'))
+$$(if $$(or $$(call strneq,UNDEFINED,$$(UniversalArchs)),\
+ $$(call strneq,UNDEFINED,$$(Arch))),,\
+ $$(error '$(1)': must define one of 'UniversalArchs' and 'Arch'))
+
+# Collect all the platform variables for subsequent use.
+$$(foreach var,$(PlainConfigVariables) $(PerConfigVariables),\
+ $$(if $$(call strneq,UNDEFINED,$$($$(var))),\
+ $$(call CopyVariable,$$(var),$(PlatformKey).$$(var))))
+$$(foreach var,$(PerConfigVariables),\
+ $$(foreach config,$$(Configs),\
+ $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(config))),\
+ $$(call CopyVariable,$$(var).$$(config),$(PlatformKey).$$(var).$$(config))))\
+ $$(foreach arch,$(AvailableArchs),\
+ $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(arch))),\
+ $$(call CopyVariable,$$(var).$$(arch),$(PlatformKey).$$(var).$$(arch))))\
+ $$(foreach config,$$(Configs),\
+ $$(foreach arch,$(AvailableArchs),\
+ $$(if $$(call strneq,UNDEFINED,$$($$(var).$$(config).$$(arch))),\
+ $$(call CopyVariable,$$(var).$$(config).$$(arch),\
+ $(PlatformKey).$$(var).$$(config).$$(arch))))))
+
+ifneq ($(DEBUGMAKE),)
+ $$(info MAKE: $(PlatformName): Done loading platform)
+endif
+endef
+
+# Evaluate this now so we do not have to worry about order of evaluation.
+PlatformFiles := $(wildcard make/platform/*.mk)
+ifneq ($(DEBUGMAKE),)
+ $(info MAKE: Loading platforms: $(PlatformFiles))
+endif
+
+$(foreach file,$(PlatformFiles),\
+ $(eval $(call load_platform_template,$(file))))