Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | # ========================================================================== |
| 3 | # Installing modules |
| 4 | # ========================================================================== |
| 5 | |
Paul Smith | 4f19336 | 2006-03-05 17:14:10 -0500 | [diff] [blame] | 6 | PHONY := __modinst |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | __modinst: |
| 8 | |
Sam Ravnborg | 8ec4b4f | 2005-07-25 20:10:36 +0000 | [diff] [blame] | 9 | include scripts/Kbuild.include |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | # |
| 12 | |
이건호 | ef591a5 | 2012-08-29 22:58:12 +0900 | [diff] [blame] | 13 | __modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) |
| 15 | |
Paul Smith | 4f19336 | 2006-03-05 17:14:10 -0500 | [diff] [blame] | 16 | PHONY += $(modules) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | __modinst: $(modules) |
| 18 | @: |
| 19 | |
Rusty Russell | f6a79af | 2012-11-06 11:46:59 +1030 | [diff] [blame] | 20 | # Don't stop modules_install if we can't sign external modules. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | quiet_cmd_modules_install = INSTALL $@ |
Bertrand Jacquin | 40e42f6 | 2014-08-27 20:30:56 +0930 | [diff] [blame] | 22 | cmd_modules_install = \ |
| 23 | mkdir -p $(2) ; \ |
| 24 | cp $@ $(2) ; \ |
| 25 | $(mod_strip_cmd) $(2)/$(notdir $@) ; \ |
Douglas Anderson | f84dde10 | 2019-03-15 09:25:03 -0700 | [diff] [blame] | 26 | $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \ |
Bertrand Jacquin | beb50df | 2014-08-27 20:31:56 +0930 | [diff] [blame] | 27 | $(mod_compress_cmd) $(2)/$(notdir $@) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | # Modules built outside the kernel source tree go into extra by default |
| 30 | INSTALL_MOD_DIR ?= extra |
Sam Ravnborg | 9b21311 | 2008-01-01 13:40:28 +0100 | [diff] [blame] | 31 | ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) |
| 34 | |
| 35 | $(modules): |
| 36 | $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) |
Paul Smith | 4f19336 | 2006-03-05 17:14:10 -0500 | [diff] [blame] | 37 | |
Paul Smith | 4f19336 | 2006-03-05 17:14:10 -0500 | [diff] [blame] | 38 | .PHONY: $(PHONY) |