diff options
-rw-r--r-- | Makefile | 155 | ||||
-rw-r--r-- | make/config.mk | 42 | ||||
-rw-r--r-- | make/subdir.mk | 24 |
3 files changed, 0 insertions, 221 deletions
@@ -68,137 +68,6 @@ clean:: test: cd test/Unit && ./test -# Template: Config_template Config -# -# This template is used once per Config at the top-level. -define Config_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveConfig)) -$(call Set,ActiveLibGen,$(ActiveObjPath)/libcompiler_rt.Generic.a) -$(call Set,ActiveLibOpt,$(ActiveObjPath)/libcompiler_rt.Optimized.a) - -# The sublibraries to use for a generic version. -$(call Set,GenericInputs,$(foreach arch,$(TargetArchs),$(ActiveObjPath)/$(arch)/libcompiler_rt.Generic.a)) -# The sublibraries to use for an optimized version. -$(call Set,OptimizedInputs,$(foreach arch,$(TargetArchs),$(ActiveObjPath)/$(arch)/libcompiler_rt.Optimized.a)) - -# Provide top-level fat archive targets. We make sure to not try to lipo if only -# building one target arch. -$(ActiveLibGen): $(GenericInputs) $(ActiveObjPath)/.dir - $(Summary) " UNIVERSAL: $(ActiveConfig): $$@" - -$(Verb) $(RM) $$@ - $(if $(TargetArch), \ - $(Verb) $(CP) $(GenericInputs) $$@, \ - $(Verb) $(Lipo) -create -output $$@ $(GenericInputs)) -$(ActiveLibOpt): $(OptimizedInputs) $(ActiveObjPath)/.dir - $(Summary) " UNIVERSAL: $(ActiveConfig): $$@" - -$(Verb) $(RM) $$@ - $(if $(TargetArch), \ - $(Verb) $(CP) $(GenericInputs) $$@, \ - $(Verb) $(Lipo) -create -output $$@ $(OptimizedInputs)) -.PRECIOUS: $(ActiveObjPath)/.dir - -# Add to default "alias" target. -$(ActiveConfig):: $(ActiveLibGen) $(ActiveLibOpt) - -# Add to target lists. -all:: $(ActiveConfig) $(ActiveLibGen) $(ActiveLibOpt) - -# Remove entire config directory on clean. -clean:: $(ActiveObjPath)/.remove -endef - -# Template: CNA_template Config Arch -# -# This template is used once per Config/Arch at the top-level. -define CNA_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveArch,$2) -$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)) -$(call Set,ActiveLibGen,$(ActiveObjPath)/libcompiler_rt.Generic.a) -$(call Set,ActiveLibOpt,$(ActiveObjPath)/libcompiler_rt.Optimized.a) - -# Initialize inputs lists. This are extended by the CNA_subdir template. The one -# tricky bit is that we need to use these quoted, because they are not complete -# until the entire makefile has been processed. -$(call Set,GenericInputs.$(ActiveConfig).$(ActiveArch),) -$(call Set,OptimizedInputs.$(ActiveConfig).$(ActiveArch),) -# Final.Inputs is created once we have loaded all the subdirectories -# and know what the correct inputs are. - -# Provide top-level archive targets. -$(ActiveLibGen): $(ActiveObjPath)/.dir - $(Summary) " ARCHIVE: $(ActiveConfig)/$(ActiveArch): $$@" - -$(Verb) $(RM) $$@ - $(Verb) $(Archive) $$@ $$(Generic.Inputs.$(ActiveConfig).$(ActiveArch)) - $(Verb) $(Ranlib) $$@ -# FIXME: The dependency on ActiveLibGen is a hack, this picks up the -# dependencies on the generic inputs. -$(ActiveLibOpt): $(ActiveLibGen) $(ActiveObjPath)/.dir - $(Summary) " ARCHIVE: $(ActiveConfig)/$(ActiveArch): $$@" - -$(Verb) $(RM) $$@ - $(Verb) $(Archive) $$@ $$(Final.Inputs.$(ActiveConfig).$(ActiveArch)) - $(Verb) $(Ranlib) $$@ -.PRECIOUS: $(ActiveObjPath)/.dir - -# Provide some default "alias" targets. -$(ActiveConfig):: $(ActiveLibGen) $(ActiveLibOpt) -$(ActiveArch):: $(ActiveLibGen) $(ActiveLibOpt) -$(ActiveConfig)-$(ActiveArch):: $(ActiveLibGen) $(ActiveLibOpt) -endef - -$(foreach config,$(Configs), \ - $(foreach arch,$(Archs), \ - $(eval $(call CNA_template,$(config),$(arch))))) - -$(foreach config,$(Configs), \ - $(eval $(call Config_template,$(config)))) - -### -# How to build things. - -# Define rules for building on each configuration & architecture. This is not -# exactly obvious, but variables inside the template are being expanded during -# the make processing, so automatic variables must be quoted and normal -# assignment cannot be used. - -# Template: CNA_template Config Arch Dir -# Uses: GetArgs, Dependencies, ObjNames -# -# This template is used once per Config/Arch/Dir. -define CNA_subdir_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveArch,$2) -$(call Set,ActiveDir,$3) -$(call Set,ActiveSrcPath,$(ProjSrcRoot)/$(ActiveDir)) -$(call Set,ActiveObjPath,$(ProjObjRoot)/$(ActiveDir)/$(ActiveConfig)/$(ActiveArch)) - -$(call Set,ActiveFlags,$(call GetArgs,$(ActiveConfig),$(ActiveArch))) -$(call Set,ActiveObjects,$(ObjNames:%=$(ActiveObjPath)/%)) - -# Add to the input list for the appropriate library and update the dependency. -$(call Append,$(Implementation).Inputs.$(ActiveConfig).$(ActiveArch),$(ActiveObjects)) -$(ProjObjRoot)/$(ActiveConfig)/$(ActiveArch)/libcompiler_rt.$(Implementation).a: $(ActiveObjects) - -$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.s $(Dependencies) $(ActiveObjPath)/.dir - $(Summary) " ASSEMBLE: $(ActiveConfig)/$(ActiveArch): $$<" - $(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$< -.PRECIOUS: $(ActiveObjPath)/.dir - -$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.S $(Dependencies) $(ActiveObjPath)/.dir - $(Summary) " ASSEMBLE: $(ActiveConfig)/$(ActiveArch): $$<" - $(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$< -.PRECIOUS: $(ActiveObjPath)/.dir - -$(ActiveObjPath)/%.o: $(ActiveSrcPath)/%.c $(Dependencies) $(ActiveObjPath)/.dir - $(Summary) " COMPILE: $(ActiveConfig)/$(ActiveArch): $$<" - $(Verb) $(CC) -c -o $$@ $(ActiveFlags) $$< -.PRECIOUS: $(ActiveObjPath)/.dir - -# Remove entire config directory on clean. -clean:: $(ProjObjRoot)/$(ActiveDir)/$(ActiveConfig)/.remove -endef - ### # Directory handling magic. @@ -217,30 +86,6 @@ endef Dir := . include make/subdir.mk - -### -# Determine the actual inputs for an optimized library. - -# Template: Final_CNA_template Config Arch -# Uses: GetArgs, Dependencies, ObjNames -# -# This template is used once per Config/Arch. -define Final_CNA_template -$(call Set,ActiveConfig,$1) -$(call Set,ActiveArch,$2) - -$(call Set,Final.Inputs.$(ActiveConfig).$(ActiveArch),\ - $(shell make/filter-inputs \ - $(Optimized.Inputs.$(ActiveConfig).$(ActiveArch)) \ - $(Generic.Inputs.$(ActiveConfig).$(ActiveArch)))) -endef - -$(foreach config,$(Configs), \ - $(foreach arch,$(Archs), \ - $(eval $(call Final_CNA_template,$(config),$(arch))))) - -### - include make/lib_info.mk include make/lib_util.mk diff --git a/make/config.mk b/make/config.mk index 903424d01..5dfc74ca1 100644 --- a/make/config.mk +++ b/make/config.mk @@ -8,48 +8,6 @@ OS := $(shell uname) ProjSrcRoot := $(shell pwd) ProjObjRoot := $(ProjSrcRoot) -Configs := Debug Release Profile - -# The full list of architectures we support. -Archs := i386 ppc x86_64 -# armv6 armv7 - -# If TargetArch is defined, only build for that architecture (and don't use -# -arch). -ifeq ($(OS), Darwin) - TargetArch := - TargetArchs := $(Archs) -else - TargetArch := i386 - TargetArchs := $(TargetArch) -endif - -Common.CFLAGS := -Wall -Werror - -# These names must match the configs, see GetArgs function. -Debug.CFLAGS := -g -Release.CFLAGS := -O3 -fomit-frame-pointer -Profile.CFLAGS := -pg -g - -# Function: GetArchArgs arch -# -# Return the compiler flags for the given arch. -ifeq ($(OS), Darwin) - GetArchArgs = -arch $(1) -else - # Check that we are only trying to build the target arch. - GetArchArgs = $(if $(subst $(TargetArch),,$(1)), \ - $(error "Invalid configuration, no -arch support: $(1)"), \ - ) -endif - -# Function: GetArgs config arch -# -# Return the compiler flags for the given config & arch. -GetArgs = $(if $($(1).CFLAGS), \ - $(Common.CFLAGS) $($(1).CFLAGS) $(call GetArchArgs,$(2)), \ - $(error "Invalid configuration: $(1)")) - ### # Tool configuration variables. diff --git a/make/subdir.mk b/make/subdir.mk index 4b1b83e08..b0981dcb6 100644 --- a/make/subdir.mk +++ b/make/subdir.mk @@ -15,30 +15,6 @@ ifeq ($(Dir),) $(error "No Dir variable defined.") endif -# Expand template for each configuration and architecture. -# -# FIXME: This level of logic should be in primary Makefile? -ifeq ($(OnlyConfigs),) - ConfigsToTraverse := $(Configs) -else - ConfigsToTraverse := $(OnlyConfigs) -endif - -ifeq ($(OnlyArchs),) - ArchsToTraverse := $(Archs) -else - ArchsToTraverse := $(OnlyArchs) -endif - -# If we are only targetting a single arch, only traverse that. -ifneq ($(TargetArch),) - ArchsToTraverse := $(filter $(TargetArch), $(ArchsToTraverse)) -endif - -$(foreach config,$(ConfigsToTraverse), \ - $(foreach arch,$(ArchsToTraverse), \ - $(eval $(call CNA_subdir_template,$(config),$(arch),$(Dir))))) - ### # Include child makefile fragments |