diff --git a/Rules.make b/Rules.make index b4d5f2f84457994cc26a2d5a47edd24a2b44da0b..291c9f81c682fc87e70361b87bf50e8ed1801f21 100644 --- a/Rules.make +++ b/Rules.make @@ -43,6 +43,27 @@ obj-m := $(filter-out $(obj-y),$(obj-m)) # first_rule: all_targets +# Handle objects in subdirs +# --------------------------------------------------------------------------- +# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o +# and add the directory to the list of dirs to descend into: $(subdir-y) +# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) +# and add the directory to the list of dirs to descend into: $(subdir-m) + +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +__subdir-n := $(patsubst %/,%,$(filter %/, $(obj-n))) +subdir-n += $(__subdir-n) +__subdir- := $(patsubst %/,%,$(filter %/, $(obj-))) +subdir- += $(__subdir-) +obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) +obj-m := $(filter-out %/, $(obj-m)) + +# If a dir is selected in $(subdir-y) and also mentioned in $(mod-subdirs), +# add it to $(subdir-m) + both-m := $(filter $(mod-subdirs), $(subdir-y)) SUB_DIRS := $(subdir-y) MOD_SUB_DIRS := $(sort $(subdir-m) $(both-m))