Makefile.modinst 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # ==========================================================================
  2. # Installing modules
  3. # ==========================================================================
  4. PHONY := __modinst
  5. __modinst:
  6. include scripts/Kbuild.include
  7. #
  8. __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
  9. modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
  10. PHONY += $(modules)
  11. __modinst: $(modules)
  12. @:
  13. quiet_cmd_modules_install = INSTALL $@
  14. cmd_modules_install = mkdir -p $(2); \
  15. $(mod_strip_cmd) $@ $(2)/$(notdir $@) || cp $@ $(2)
  16. # Modules built outside the kernel source tree go into extra by default
  17. INSTALL_MOD_DIR ?= extra
  18. ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
  19. modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
  20. $(modules):
  21. $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
  22. # Declare the contents of the .PHONY variable as phony. We keep that
  23. # information in a variable se we can use it in if_changed and friends.
  24. .PHONY: $(PHONY)