Makefile.modinst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. # Don't stop modules_install if we can't sign external modules.
  14. quiet_cmd_modules_install = INSTALL $@
  15. cmd_modules_install = \
  16. mkdir -p $(2) ; \
  17. cp $@ $(2) ; \
  18. $(mod_strip_cmd) $(2)/$(notdir $@) ; \
  19. $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) && \
  20. $(mod_compress_cmd) $(2)/$(notdir $@)
  21. # Modules built outside the kernel source tree go into extra by default
  22. INSTALL_MOD_DIR ?= extra
  23. ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
  24. modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
  25. $(modules):
  26. $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
  27. # Declare the contents of the .PHONY variable as phony. We keep that
  28. # information in a variable so we can use it in if_changed and friends.
  29. .PHONY: $(PHONY)