1 # SPDX-License-Identifier: GPL-2.0
2 # ==========================================================================
3 # Generating modules.builtin
4 # ==========================================================================
11 -include include/config/auto.conf
12 # tristate.conf sets tristate variables to uppercase 'Y' or 'M'
13 # That way, we get the list of built-in modules in obj-Y
14 -include include/config/tristate.conf
16 include scripts/Kbuild.include
18 ifneq ($(KBUILD_SRC),)
19 # Create output directory if not already present
20 _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
23 # The filename Kbuild has precedence over Makefile
24 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
25 kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
26 include $(kbuild-file)
28 include scripts/Makefile.lib
29 __subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y)))
30 subdir-Y += $(__subdir-Y)
31 subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m))
32 subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
33 obj-Y := $(addprefix $(obj)/,$(obj-Y))
35 modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym))
36 modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko))
37 modbuiltin-target := $(obj)/modules.builtin
39 __modbuiltin: $(modbuiltin-target) $(subdir-ym)
42 $(modbuiltin-target): $(subdir-ym) FORCE
43 $(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done; \
44 cat /dev/null $(modbuiltin-subdirs)) > $@
51 # ---------------------------------------------------------------------------
55 $(Q)$(MAKE) $(modbuiltin)=$@