Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Michal Marek | bc081dd | 2009-12-07 16:38:33 +0100 | [diff] [blame] | 2 | # ========================================================================== |
| 3 | # Generating modules.builtin |
| 4 | # ========================================================================== |
| 5 | |
| 6 | src := $(obj) |
| 7 | |
| 8 | PHONY := __modbuiltin |
| 9 | __modbuiltin: |
| 10 | |
Dirk Gouders | b5cdca7 | 2018-08-02 15:47:08 +0200 | [diff] [blame] | 11 | include include/config/auto.conf |
Michal Marek | bc081dd | 2009-12-07 16:38:33 +0100 | [diff] [blame] | 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 |
Dirk Gouders | b5cdca7 | 2018-08-02 15:47:08 +0200 | [diff] [blame] | 14 | include include/config/tristate.conf |
Michal Marek | bc081dd | 2009-12-07 16:38:33 +0100 | [diff] [blame] | 15 | |
| 16 | include scripts/Kbuild.include |
| 17 | |
Michal Marek | 607b30f | 2010-06-10 12:23:08 +0200 | [diff] [blame] | 18 | ifneq ($(KBUILD_SRC),) |
| 19 | # Create output directory if not already present |
| 20 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) |
| 21 | endif |
| 22 | |
Michal Marek | bc081dd | 2009-12-07 16:38:33 +0100 | [diff] [blame] | 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) |
| 27 | |
| 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)) |
| 34 | |
| 35 | modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym)) |
| 36 | modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko)) |
| 37 | modbuiltin-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 | |
| 46 | PHONY += FORCE |
| 47 | |
| 48 | FORCE: |
| 49 | |
| 50 | # Descending |
| 51 | # --------------------------------------------------------------------------- |
| 52 | |
| 53 | PHONY += $(subdir-ym) |
| 54 | $(subdir-ym): |
| 55 | $(Q)$(MAKE) $(modbuiltin)=$@ |
| 56 | |
Michal Marek | bc081dd | 2009-12-07 16:38:33 +0100 | [diff] [blame] | 57 | .PHONY: $(PHONY) |