Makefile.modinst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. # Declare the contents of the .PHONY variable as phony. We keep that
  29. # information in a variable so we can use it in if_changed and friends.
  30. .PHONY: $(PHONY)