where is the rule to build a $(obj)/subdir target in linux kernel makefile?

147 Views Asked by At

In linux kernel Makefile.build:

`
# To build objects in subdirs, we need to descend into the directories
$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;`

the $(obj)/subdir/built-in.a depends on $(obj)/subdir prereq, but where is the rule to build $(obj)/subdir?

I assume the following rule is only for $(obj)/ directory, and can't apply for the above subdir.

`
# Build
# ---------------------------------------------------------------------------

$(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
     $(if $(KBUILD_MODULES), $(targets-for-modules)) \
     $(subdir-ym) $(always-y)
    @:`

Thanks!

I have looked up the makefile, but have not found any clue.

1

There are 1 best solutions below

0
senlinzh On

I already got the answer from a Linux kernel maintainer, as below:

See around line 500.

$(subdir-ym):
$(Q)$(MAKE) $(build)=$@ \
need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1) \
$(filter $@/%, $(single-subdir-goals))