blob: 1adb974e6950efb80943f82b1c4ca416b09b5417 [file] [log] [blame]
Michal Marekbc081dd2009-12-07 16:38:33 +01001# ==========================================================================
2# Generating modules.builtin
3# ==========================================================================
4
5src := $(obj)
6
7PHONY := __modbuiltin
8__modbuiltin:
9
10-include include/config/auto.conf
11# tristate.conf sets tristate variables to uppercase 'Y' or 'M'
12# That way, we get the list of built-in modules in obj-Y
13-include include/config/tristate.conf
14
15include scripts/Kbuild.include
16
Michal Marek607b30f2010-06-10 12:23:08 +020017ifneq ($(KBUILD_SRC),)
18# Create output directory if not already present
19_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
20endif
21
Michal Marekbc081dd2009-12-07 16:38:33 +010022# The filename Kbuild has precedence over Makefile
23kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
24kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
25include $(kbuild-file)
26
27include scripts/Makefile.lib
28__subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y)))
29subdir-Y += $(__subdir-Y)
30subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m))
31subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
32obj-Y := $(addprefix $(obj)/,$(obj-Y))
33
34modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym))
35modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko))
36modbuiltin-target := $(obj)/modules.builtin
37
38__modbuiltin: $(modbuiltin-target) $(subdir-ym)
39 @:
40
41$(modbuiltin-target): $(subdir-ym) FORCE
42 $(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done; \
43 cat /dev/null $(modbuiltin-subdirs)) > $@
44
45PHONY += FORCE
46
47FORCE:
48
49# Descending
50# ---------------------------------------------------------------------------
51
52PHONY += $(subdir-ym)
53$(subdir-ym):
54 $(Q)$(MAKE) $(modbuiltin)=$@
55
56
57# Declare the contents of the .PHONY variable as phony. We keep that
58# information in a variable se we can use it in if_changed and friends.
59
60.PHONY: $(PHONY)