Makefile.modinst 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # SPDX-License-Identifier: GPL-2.0
  2. # ==========================================================================
  3. # Installing modules
  4. # ==========================================================================
  5. PHONY := __modinst
  6. __modinst:
  7. include scripts/Kbuild.include
  8. #
  9. __modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
  10. modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
  11. PHONY += $(modules)
  12. __modinst: $(modules)
  13. @:
  14. # Don't stop modules_install if we can't sign external modules.
  15. quiet_cmd_modules_install = INSTALL $@
  16. cmd_modules_install = \
  17. mkdir -p $(2) ; \
  18. cp $@ $(2) ; \
  19. $(mod_strip_cmd) $(2)/$(notdir $@) ; \
  20. $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) && \
  21. $(mod_compress_cmd) $(2)/$(notdir $@)
  22. # Modules built outside the kernel source tree go into extra by default
  23. INSTALL_MOD_DIR ?= extra
  24. ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
  25. modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
  26. $(modules):
  27. $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
  28. .PHONY: $(PHONY)