Commit ac7e73532242ce350764d8aa8dcddcbd47c0fb71

Authored by Masahiro Yamada
Committed by Tom Rini
1 parent 4810400ec9

Makefile: support descending down to subdirectories

This patch tweaks scripts/Makefile.build to allow
the build system to descend into subdirectories like Kbuild.

To use this feature, use "obj-y += foo/" syntax.

Example:
    obj-$(CONFIG_FOO) += foo/

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Simon Glass <sjg@chromium.org>

Showing 1 changed file with 15 additions and 0 deletions Side-by-side Diff

scripts/Makefile.build
... ... @@ -19,6 +19,11 @@
19 19 extra-y := $(sort $(extra-y))
20 20 lib-y := $(sort $(lib-y))
21 21  
  22 +subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
  23 +obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
  24 +subdir-obj-y := $(filter %/built-in.o, $(obj-y))
  25 +subdir-obj-y := $(addprefix $(obj),$(subdir-obj-y))
  26 +
22 27 SRCS += $(COBJS:.o=.c) $(SOBJS:.o=.S) \
23 28 $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) $(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S))
24 29 OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS) $(obj-y))
... ... @@ -37,6 +42,14 @@
37 42 $(call cmd_link_o_target, $(LGOBJS))
38 43 endif
39 44  
  45 +ifneq ($(subdir-obj-y),)
  46 +# Descending
  47 +$(subdir-obj-y): $(subdir-y)
  48 +
  49 +$(subdir-y): FORCE
  50 + $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
  51 +endif
  52 +
40 53 #########################################################################
41 54  
42 55 # defines $(obj).depend target
... ... @@ -46,4 +59,6 @@
46 59 sinclude $(obj).depend
47 60  
48 61 #########################################################################
  62 +
  63 +.PHONY: FORCE