2017-11-01 15:07:57 +01:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2005-04-16 15:20:36 -07:00
|
|
|
# ===========================================================================
|
|
|
|
|
# Module versions
|
|
|
|
|
# ===========================================================================
|
|
|
|
|
#
|
|
|
|
|
# Stage one of module building created the following:
|
|
|
|
|
# a) The individual .o files used for the module
|
2006-03-24 18:23:14 +01:00
|
|
|
# b) A <module>.o file which is the .o files above linked together
|
2019-07-17 15:17:57 +09:00
|
|
|
# c) A <module>.mod file, listing the name of the preliminary <module>.o file,
|
|
|
|
|
# plus all .o files
|
2019-07-17 15:17:55 +09:00
|
|
|
# d) modules.order, which lists all the modules
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
# Stage 2 is handled by this file and does the following
|
2019-07-17 15:17:55 +09:00
|
|
|
# 1) Find all modules listed in modules.order
|
2005-04-16 15:20:36 -07:00
|
|
|
# 2) modpost is then used to
|
|
|
|
|
# 3) create one <module>.mod.c file pr. module
|
|
|
|
|
# 4) create one Module.symvers file with CRC for all exported symbols
|
|
|
|
|
|
|
|
|
|
# Step 3 is used to place certain information in the module's ELF
|
|
|
|
|
# section, including information such as:
|
2011-05-25 11:09:59 +02:00
|
|
|
# Version magic (see include/linux/vermagic.h for full details)
|
2005-04-16 15:20:36 -07:00
|
|
|
# - Kernel release
|
|
|
|
|
# - SMP is CONFIG_SMP
|
2019-07-28 20:27:41 +02:00
|
|
|
# - PREEMPT is CONFIG_PREEMPT[_RT]
|
2005-04-16 15:20:36 -07:00
|
|
|
# - GCC Version
|
|
|
|
|
# Module info
|
|
|
|
|
# - Module version (MODULE_VERSION)
|
|
|
|
|
# - Module alias'es (MODULE_ALIAS)
|
|
|
|
|
# - Module license (MODULE_LICENSE)
|
|
|
|
|
# - See include/linux/module.h for more details
|
|
|
|
|
|
|
|
|
|
# Step 4 is solely used to allow module versioning in external modules,
|
2010-07-30 20:43:20 +02:00
|
|
|
# where the CRC of each module is retrieved from the Module.symvers file.
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-10-01 11:35:24 +02:00
|
|
|
# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
|
|
|
|
|
# symbols in the final module linking stage
|
|
|
|
|
# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
|
2011-03-30 22:57:33 -03:00
|
|
|
# This is solely useful to speed up test compiles
|
2019-07-31 00:59:02 +09:00
|
|
|
|
|
|
|
|
PHONY := __modpost
|
|
|
|
|
__modpost:
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-06-08 22:12:39 -07:00
|
|
|
include include/config/auto.conf
|
2005-07-25 20:10:36 +00:00
|
|
|
include scripts/Kbuild.include
|
2008-02-28 09:40:58 +01:00
|
|
|
|
2019-07-31 00:59:02 +09:00
|
|
|
kernelsymfile := $(objtree)/Module.symvers
|
|
|
|
|
modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
|
|
|
|
|
|
2020-03-06 17:02:06 +01:00
|
|
|
MODPOST = scripts/mod/modpost \
|
|
|
|
|
$(if $(CONFIG_MODVERSIONS),-m) \
|
|
|
|
|
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
|
|
|
|
|
$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
|
|
|
|
|
$(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \
|
|
|
|
|
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
|
|
|
|
|
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
|
|
|
|
|
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \
|
2019-10-29 21:38:06 +09:00
|
|
|
$(if $(KBUILD_MODPOST_WARN),-w)
|
2019-07-31 00:59:02 +09:00
|
|
|
|
|
|
|
|
ifdef MODPOST_VMLINUX
|
|
|
|
|
|
2019-08-15 01:06:23 +09:00
|
|
|
quiet_cmd_modpost = MODPOST vmlinux.o
|
|
|
|
|
cmd_modpost = $(MODPOST) vmlinux.o
|
2019-07-31 00:59:02 +09:00
|
|
|
|
2019-08-15 01:06:23 +09:00
|
|
|
__modpost:
|
2019-07-31 00:59:02 +09:00
|
|
|
$(call cmd,modpost)
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
2019-10-29 21:38:06 +09:00
|
|
|
MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \
|
2019-10-29 21:38:08 +09:00
|
|
|
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
|
2019-10-03 19:29:13 +09:00
|
|
|
|
|
|
|
|
ifeq ($(KBUILD_EXTMOD),)
|
|
|
|
|
MODPOST += $(wildcard vmlinux)
|
|
|
|
|
else
|
2008-05-31 22:28:40 +02:00
|
|
|
|
2019-11-06 23:52:15 +09:00
|
|
|
# set src + obj - they may be used in the modules's Makefile
|
2008-05-31 22:28:40 +02:00
|
|
|
obj := $(KBUILD_EXTMOD)
|
|
|
|
|
src := $(obj)
|
|
|
|
|
|
2008-02-28 09:40:58 +01:00
|
|
|
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
|
|
|
|
|
include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
|
|
|
|
|
$(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
|
|
|
|
|
endif
|
|
|
|
|
|
2019-07-31 00:59:02 +09:00
|
|
|
# find all modules listed in modules.order
|
2019-08-02 19:23:58 +09:00
|
|
|
modules := $(sort $(shell cat $(MODORDER)))
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2019-08-15 01:06:23 +09:00
|
|
|
# Read out modules.order instead of expanding $(modules) to pass in modpost.
|
|
|
|
|
# Otherwise, allmodconfig would fail with "Argument list too long".
|
2019-07-31 00:59:01 +09:00
|
|
|
quiet_cmd_modpost = MODPOST $(words $(modules)) modules
|
2019-08-02 19:23:58 +09:00
|
|
|
cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST)
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2019-08-15 01:06:23 +09:00
|
|
|
__modpost:
|
2019-07-31 00:59:02 +09:00
|
|
|
$(call cmd,modpost)
|
2019-08-15 01:06:23 +09:00
|
|
|
ifneq ($(KBUILD_MODPOST_NOFINAL),1)
|
|
|
|
|
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
|
|
|
|
|
endif
|
2006-03-05 17:14:10 -05:00
|
|
|
|
2019-07-31 00:59:02 +09:00
|
|
|
endif
|
|
|
|
|
|
2006-03-05 17:14:10 -05:00
|
|
|
.PHONY: $(PHONY)
|