blob: a072a4267746513c04d05688ac1535f12a687bbc [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Michal Marekbc081dd2009-12-07 16:38:33 +01002# ==========================================================================
3# Generating modules.builtin
4# ==========================================================================
5
6src := $(obj)
7
8PHONY := __modbuiltin
9__modbuiltin:
10
Dirk Goudersb5cdca72018-08-02 15:47:08 +020011include include/config/auto.conf
Michal Marekbc081dd2009-12-07 16:38:33 +010012# tristate.conf sets tristate variables to uppercase 'Y' or 'M'
13# That way, we get the list of built-in modules in obj-Y
Dirk Goudersb5cdca72018-08-02 15:47:08 +020014include include/config/tristate.conf
Michal Marekbc081dd2009-12-07 16:38:33 +010015
16include scripts/Kbuild.include
17
Michal Marek607b30f2010-06-10 12:23:08 +020018ifneq ($(KBUILD_SRC),)
19# Create output directory if not already present
20_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
21endif
22
Michal Marekbc081dd2009-12-07 16:38:33 +010023# The filename Kbuild has precedence over Makefile
24kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
25kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
26include $(kbuild-file)
27
28include scripts/Makefile.lib
29__subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y)))
30subdir-Y += $(__subdir-Y)
31subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m))
32subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
33obj-Y := $(addprefix $(obj)/,$(obj-Y))
34
35modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym))
36modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko))
37modbuiltin-target := $(obj)/modules.builtin
38
39__modbuiltin: $(modbuiltin-target) $(subdir-ym)
40 @:
41
42$(modbuiltin-target): $(subdir-ym) FORCE
43 $(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done; \
44 cat /dev/null $(modbuiltin-subdirs)) > $@
45
46PHONY += FORCE
47
48FORCE:
49
50# Descending
51# ---------------------------------------------------------------------------
52
53PHONY += $(subdir-ym)
54$(subdir-ym):
55 $(Q)$(MAKE) $(modbuiltin)=$@
56
Michal Marekbc081dd2009-12-07 16:38:33 +010057.PHONY: $(PHONY)