2010-01-14 00:13:01 +08:00
|
|
|
# This file is intended to be included from each subdirectory makefile.
|
2010-01-18 14:48:33 +08:00
|
|
|
#
|
|
|
|
# Subdirectory makefiles must define:
|
|
|
|
# SubDirs - The subdirectories to traverse.
|
|
|
|
# ObjNames - The objects available in that directory.
|
2012-06-15 03:58:46 +08:00
|
|
|
# Implementation - The library configuration the objects should go in (Generic
|
|
|
|
# or Optimized)
|
2010-01-18 14:48:33 +08:00
|
|
|
# Dependencies - Any dependences for the object files.
|
|
|
|
#
|
|
|
|
# Subdirectory makefiles may define:
|
|
|
|
# OnlyArchs - Only build the objects for the listed archs.
|
|
|
|
# OnlyConfigs - Only build the objects for the listed configurations.
|
2009-06-27 00:47:03 +08:00
|
|
|
|
|
|
|
ifeq ($(Dir),)
|
|
|
|
$(error "No Dir variable defined.")
|
|
|
|
endif
|
|
|
|
|
|
|
|
###
|
|
|
|
# Include child makefile fragments
|
|
|
|
|
2010-01-18 14:48:33 +08:00
|
|
|
# The list of variables which are intended to be overridden in a subdirectory
|
|
|
|
# makefile.
|
2011-12-02 10:42:07 +08:00
|
|
|
RequiredSubdirVariables := \
|
|
|
|
ModuleName SubDirs ObjNames Implementation Dependencies
|
2010-01-18 14:48:33 +08:00
|
|
|
OptionalSubdirVariables := OnlyArchs OnlyConfigs
|
|
|
|
|
|
|
|
# Template: subdir_traverse_template subdir
|
|
|
|
define subdir_traverse_template
|
|
|
|
$(call Set,Dir,$(1))
|
|
|
|
ifneq ($(DEBUGMAKE),)
|
|
|
|
$$(info MAKE: $(Dir): Processing subdirectory)
|
|
|
|
endif
|
|
|
|
|
2010-01-18 14:48:40 +08:00
|
|
|
# Construct the variable key for this directory.
|
|
|
|
$(call Set,DirKey,SubDir.$(subst .,,$(subst /,__,$(1))))
|
|
|
|
$(call Append,SubDirKeys,$(DirKey))
|
|
|
|
$(call Set,$(DirKey).Dir,$(Dir))
|
|
|
|
|
2010-01-18 14:48:33 +08:00
|
|
|
# Reset subdirectory specific variables to sentinel value.
|
|
|
|
$$(foreach var,$$(RequiredSubdirVariables) $$(OptionalSubdirVariables),\
|
|
|
|
$$(call Set,$$(var),UNDEFINED))
|
|
|
|
|
|
|
|
# Get the subdirectory variables.
|
|
|
|
include $(1)/Makefile.mk
|
|
|
|
|
|
|
|
ifeq ($(DEBUGMAKE),2)
|
|
|
|
$$(foreach var,$(RequiredSubdirVariables) $(OptionalSubdirVariables),\
|
2010-01-18 14:48:40 +08:00
|
|
|
$$(if $$(call strneq,UNDEFINED,$$($$(var))), \
|
2010-01-18 14:48:33 +08:00
|
|
|
$$(info MAKE: $(Dir): $$(var) is defined), \
|
|
|
|
$$(info MAKE: $(Dir): $$(var) is undefined)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Check for undefined required variables, and unset sentinel value from optional
|
|
|
|
# variables.
|
|
|
|
$$(foreach var,$(RequiredSubdirVariables),\
|
2010-01-18 14:48:40 +08:00
|
|
|
$$(if $$(call strneq,UNDEFINED,$$($$(var))),, \
|
2010-01-18 14:48:33 +08:00
|
|
|
$$(error $(Dir): variable '$$(var)' was not undefined)))
|
|
|
|
$$(foreach var,$(OptionalSubdirVariables),\
|
2010-01-18 14:48:40 +08:00
|
|
|
$$(if $$(call strneq,UNDEFINED,$$($$(var))),, \
|
2010-01-18 14:48:33 +08:00
|
|
|
$$(call Set,$$(var),)))
|
|
|
|
|
2010-01-18 14:48:40 +08:00
|
|
|
# Collect all subdirectory variables for subsequent use.
|
|
|
|
$$(foreach var,$(RequiredSubdirVariables) $(OptionalSubdirVariables),\
|
|
|
|
$$(call Set,$(DirKey).$$(var),$$($$(var))))
|
|
|
|
|
2010-01-18 14:48:33 +08:00
|
|
|
# Recurse.
|
|
|
|
include make/subdir.mk
|
|
|
|
|
2010-01-18 14:48:40 +08:00
|
|
|
# Restore directory variable, for cleanliness.
|
2010-01-18 14:48:33 +08:00
|
|
|
$$(call Set,Dir,$(1))
|
|
|
|
|
|
|
|
ifneq ($(DEBUGMAKE),)
|
|
|
|
$$(info MAKE: $$(Dir): Done processing subdirectory)
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2010-01-14 00:13:01 +08:00
|
|
|
# Evaluate this now so we do not have to worry about order of evaluation.
|
2010-01-18 14:49:33 +08:00
|
|
|
|
|
|
|
SubDirsList := $(strip \
|
|
|
|
$(if $(call streq,.,$(Dir)),\
|
|
|
|
$(SubDirs),\
|
|
|
|
$(SubDirs:%=$(Dir)/%)))
|
2009-06-27 00:47:03 +08:00
|
|
|
ifeq ($(SubDirsList),)
|
|
|
|
else
|
2010-01-18 14:48:33 +08:00
|
|
|
ifneq ($(DEBUGMAKE),)
|
2009-06-27 00:47:03 +08:00
|
|
|
$(info MAKE: Descending into subdirs: $(SubDirsList))
|
|
|
|
endif
|
|
|
|
|
2010-01-18 14:48:33 +08:00
|
|
|
$(foreach subdir,$(SubDirsList),\
|
|
|
|
$(eval $(call subdir_traverse_template,$(subdir))))
|
|
|
|
endif
|