Makefile.modbuiltin 1.7 KB

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