Makefile.modbuiltin 1.8 KB

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