Makefile.modbuiltin 1.7 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
M
Michal Marek 已提交
2 3 4 5 6 7 8 9 10
# ==========================================================================
# Generating modules.builtin
# ==========================================================================

src := $(obj)

PHONY := __modbuiltin
__modbuiltin:

11
include include/config/auto.conf
M
Michal Marek 已提交
12 13
# tristate.conf sets tristate variables to uppercase 'Y' or 'M'
# That way, we get the list of built-in modules in obj-Y
14
include include/config/tristate.conf
M
Michal Marek 已提交
15 16 17

include scripts/Kbuild.include

18
ifneq ($(srctree),.)
19 20 21 22
# Create output directory if not already present
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
endif

M
Michal Marek 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
include $(kbuild-file)

include scripts/Makefile.lib
__subdir-Y     := $(patsubst %/,%,$(filter %/, $(obj-Y)))
subdir-Y       += $(__subdir-Y)
subdir-ym      := $(sort $(subdir-y) $(subdir-Y) $(subdir-m))
subdir-ym      := $(addprefix $(obj)/,$(subdir-ym))
obj-Y          := $(addprefix $(obj)/,$(obj-Y))

modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym))
modbuiltin-mods    := $(filter %.ko, $(obj-Y:.o=.ko))
modbuiltin-target  := $(obj)/modules.builtin

__modbuiltin: $(modbuiltin-target) $(subdir-ym)
	@:

$(modbuiltin-target): $(subdir-ym) FORCE
	$(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done;	\
	cat /dev/null $(modbuiltin-subdirs)) > $@

PHONY += FORCE

FORCE:

# Descending
# ---------------------------------------------------------------------------

PHONY += $(subdir-ym)
$(subdir-ym):
	$(Q)$(MAKE) $(modbuiltin)=$@

.PHONY: $(PHONY)