1*7c3d14c8STreehugger Robot# This file is intended to be included from each subdirectory makefile. 2*7c3d14c8STreehugger Robot# 3*7c3d14c8STreehugger Robot# Subdirectory makefiles must define: 4*7c3d14c8STreehugger Robot# SubDirs - The subdirectories to traverse. 5*7c3d14c8STreehugger Robot# 6*7c3d14c8STreehugger Robot# Subdirectory makefiles may define: 7*7c3d14c8STreehugger Robot# ModuleName - The library name for objects in that directory. 8*7c3d14c8STreehugger Robot# ObjNames - The objects available in that directory. 9*7c3d14c8STreehugger Robot# Implementation - The library configuration the objects should go in (Generic 10*7c3d14c8STreehugger Robot# or Optimized) 11*7c3d14c8STreehugger Robot# Dependencies - Any dependences for the object files. 12*7c3d14c8STreehugger Robot# OnlyArchs - Only build the objects for the listed archs. 13*7c3d14c8STreehugger Robot# OnlyConfigs - Only build the objects for the listed configurations. 14*7c3d14c8STreehugger Robot 15*7c3d14c8STreehugger Robotifeq ($(Dir),) 16*7c3d14c8STreehugger Robot $(error "No Dir variable defined.") 17*7c3d14c8STreehugger Robotendif 18*7c3d14c8STreehugger Robot 19*7c3d14c8STreehugger Robot### 20*7c3d14c8STreehugger Robot# Include child makefile fragments 21*7c3d14c8STreehugger Robot 22*7c3d14c8STreehugger Robot# The list of variables which are intended to be overridden in a subdirectory 23*7c3d14c8STreehugger Robot# makefile. 24*7c3d14c8STreehugger RobotRequiredSubdirVariables := SubDirs 25*7c3d14c8STreehugger RobotOptionalSubdirVariables := ModuleName OnlyArchs OnlyConfigs \ 26*7c3d14c8STreehugger Robot ObjNames Implementation Dependencies 27*7c3d14c8STreehugger Robot 28*7c3d14c8STreehugger Robot# Template: subdir_traverse_template subdir 29*7c3d14c8STreehugger Robotdefine subdir_traverse_template 30*7c3d14c8STreehugger Robot$(call Set,Dir,$(1)) 31*7c3d14c8STreehugger Robotifneq ($(DEBUGMAKE),) 32*7c3d14c8STreehugger Robot $$(info MAKE: $(Dir): Processing subdirectory) 33*7c3d14c8STreehugger Robotendif 34*7c3d14c8STreehugger Robot 35*7c3d14c8STreehugger Robot# Construct the variable key for this directory. 36*7c3d14c8STreehugger Robot$(call Set,DirKey,SubDir.$(subst .,,$(subst /,__,$(1)))) 37*7c3d14c8STreehugger Robot$(call Append,SubDirKeys,$(DirKey)) 38*7c3d14c8STreehugger Robot$(call Set,$(DirKey).Dir,$(Dir)) 39*7c3d14c8STreehugger Robot 40*7c3d14c8STreehugger Robot# Reset subdirectory specific variables to sentinel value. 41*7c3d14c8STreehugger Robot$$(foreach var,$$(RequiredSubdirVariables) $$(OptionalSubdirVariables),\ 42*7c3d14c8STreehugger Robot $$(call Set,$$(var),UNDEFINED)) 43*7c3d14c8STreehugger Robot 44*7c3d14c8STreehugger Robot# Get the subdirectory variables. 45*7c3d14c8STreehugger Robotinclude $(1)/Makefile.mk 46*7c3d14c8STreehugger Robot 47*7c3d14c8STreehugger Robotifeq ($(DEBUGMAKE),2) 48*7c3d14c8STreehugger Robot$$(foreach var,$(RequiredSubdirVariables) $(OptionalSubdirVariables),\ 49*7c3d14c8STreehugger Robot $$(if $$(call strneq,UNDEFINED,$$($$(var))), \ 50*7c3d14c8STreehugger Robot $$(info MAKE: $(Dir): $$(var) is defined), \ 51*7c3d14c8STreehugger Robot $$(info MAKE: $(Dir): $$(var) is undefined))) 52*7c3d14c8STreehugger Robotendif 53*7c3d14c8STreehugger Robot 54*7c3d14c8STreehugger Robot# Check for undefined required variables, and unset sentinel value from optional 55*7c3d14c8STreehugger Robot# variables. 56*7c3d14c8STreehugger Robot$$(foreach var,$(RequiredSubdirVariables),\ 57*7c3d14c8STreehugger Robot $$(if $$(call strneq,UNDEFINED,$$($$(var))),, \ 58*7c3d14c8STreehugger Robot $$(error $(Dir): variable '$$(var)' was not undefined))) 59*7c3d14c8STreehugger Robot$$(foreach var,$(OptionalSubdirVariables),\ 60*7c3d14c8STreehugger Robot $$(if $$(call strneq,UNDEFINED,$$($$(var))),, \ 61*7c3d14c8STreehugger Robot $$(call Set,$$(var),))) 62*7c3d14c8STreehugger Robot 63*7c3d14c8STreehugger Robot# Collect all subdirectory variables for subsequent use. 64*7c3d14c8STreehugger Robot$$(foreach var,$(RequiredSubdirVariables) $(OptionalSubdirVariables),\ 65*7c3d14c8STreehugger Robot $$(call Set,$(DirKey).$$(var),$$($$(var)))) 66*7c3d14c8STreehugger Robot 67*7c3d14c8STreehugger Robot# Recurse. 68*7c3d14c8STreehugger Robotinclude make/subdir.mk 69*7c3d14c8STreehugger Robot 70*7c3d14c8STreehugger Robot# Restore directory variable, for cleanliness. 71*7c3d14c8STreehugger Robot$$(call Set,Dir,$(1)) 72*7c3d14c8STreehugger Robot 73*7c3d14c8STreehugger Robotifneq ($(DEBUGMAKE),) 74*7c3d14c8STreehugger Robot $$(info MAKE: $$(Dir): Done processing subdirectory) 75*7c3d14c8STreehugger Robotendif 76*7c3d14c8STreehugger Robotendef 77*7c3d14c8STreehugger Robot 78*7c3d14c8STreehugger Robot# Evaluate this now so we do not have to worry about order of evaluation. 79*7c3d14c8STreehugger Robot 80*7c3d14c8STreehugger RobotSubDirsList := $(strip \ 81*7c3d14c8STreehugger Robot $(if $(call streq,.,$(Dir)),\ 82*7c3d14c8STreehugger Robot $(SubDirs),\ 83*7c3d14c8STreehugger Robot $(SubDirs:%=$(Dir)/%))) 84*7c3d14c8STreehugger Robotifeq ($(SubDirsList),) 85*7c3d14c8STreehugger Robotelse 86*7c3d14c8STreehugger Robot ifneq ($(DEBUGMAKE),) 87*7c3d14c8STreehugger Robot $(info MAKE: Descending into subdirs: $(SubDirsList)) 88*7c3d14c8STreehugger Robot endif 89*7c3d14c8STreehugger Robot 90*7c3d14c8STreehugger Robot $(foreach subdir,$(SubDirsList),\ 91*7c3d14c8STreehugger Robot $(eval $(call subdir_traverse_template,$(subdir)))) 92*7c3d14c8STreehugger Robotendif 93