Lines Matching +full:sub +full:- +full:modules
1 # SPDX-License-Identifier: GPL-2.0
24 # Most importantly: sub-Makefiles should only ever modify files in
27 # unavoidable when linking the built-in.a targets which finally
28 # turn into vmlinux), we will call a sub make in that other dir, and
39 # Do not use make's built-in rules and variables
40 # (this increases performance and avoids hard-to-debug behaviour)
41 MAKEFLAGS += -rR
53 # ---------------------------------------------------------------------------
60 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
67 # A simple variant is to prefix commands with $(Q) - that's useful
68 # for commands that shall be hidden in non-verbose mode.
94 # If the user is running make -s (silent mode), suppress echoing of
97 ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
108 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
129 # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
131 abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
143 MAKEFLAGS += --no-print-directory
145 need-sub-make := 1
157 # This does not become effective immediately because MAKEFLAGS is re-parsed
158 # once after the Makefile is read. We need to invoke sub-make.
159 MAKEFLAGS += --include-dir=$(abs_srctree)
160 need-sub-make := 1
163 this-makefile := $(lastword $(MAKEFILE_LIST))
166 # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
167 # We need to invoke sub-make to avoid implicit rules in the top Makefile.
168 need-sub-make := 1
170 $(this-makefile): ;
176 ifeq ($(need-sub-make),1)
178 PHONY += $(MAKECMDGOALS) __sub-make
180 $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
184 __sub-make:
185 $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
187 endif # need-sub-make
191 ifeq ($(need-sub-make),)
196 MAKEFLAGS += --no-print-directory
201 # Use 'make C=1' to enable checking of only re-compiled files.
203 # of whether they are re-compiled or not.
205 # See the file "Documentation/dev-tools/sparse.rst" for more details,
222 $(error building multiple external modules is not supported))
226 extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
262 clean-targets := %clean mrproper cleandocs
263 no-dot-config-targets := $(clean-targets) \
266 %asm-generic kernelversion %src-pkg dt_binding_check \
268 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease
269 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
271 config-build :=
272 mixed-build :=
273 need-config := 1
274 may-sync-config := 1
275 single-build :=
277 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
278 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
279 need-config :=
283 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
284 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
285 may-sync-config :=
290 may-sync-config :=
295 config-build := 1
297 mixed-build := 1
303 ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
304 single-build := 1
305 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
306 mixed-build := 1
310 # For "make -j clean all", "make -j mrproper defconfig all", etc.
311 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
312 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
313 mixed-build := 1
320 mixed-build := 1
324 ifdef mixed-build
335 $(Q)set -e; \
337 $(MAKE) -f $(srctree)/Makefile $$i; \
340 else # !mixed-build
351 # Cross compiling and selecting different set of gcc/bin-utils
352 # ---------------------------------------------------------------------------
362 # during compilation. Only gcc and related bin-utils executables
365 # make CROSS_COMPILE=ia64-linux-
399 # Default file for 'make defconfig'. This may be overridden by arch-Makefile.
417 export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
418 -O2 -fomit-frame-pointer -std=gnu89
422 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
427 CPP = $(CC) -E
431 AR = llvm-ar
432 NM = llvm-nm
433 OBJCOPY = llvm-objcopy
434 OBJDUMP = llvm-objdump
435 READELF = llvm-readelf
436 STRIP = llvm-strip
467 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
468 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
479 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
480 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
481 -I$(srctree)/include/uapi \
482 -I$(objtree)/include/generated/uapi \
483 -include $(srctree)/include/linux/kconfig.h
488 -I$(srctree)/arch/$(SRCARCH)/include \
489 -I$(objtree)/arch/$(SRCARCH)/include/generated \
490 $(if $(building_out_of_srctree),-I$(srctree)/include) \
491 -I$(objtree)/include \
494 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
495 KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
496 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
497 -Werror=implicit-function-declaration -Werror=implicit-int \
498 -Werror=return-type -Wno-format-security \
499 -std=gnu89
500 KBUILD_CPPFLAGS := -D__KERNEL__
503 KBUILD_AFLAGS_MODULE := -DMODULE
504 KBUILD_CFLAGS_MODULE := -DMODULE
523 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
524 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
525 -prune -o
526 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
527 --exclude CVS --exclude .pc --exclude .hg --exclude .git
536 $(Q)rm -f .tmp_quiet_recordmcount
539 # Before starting out-of-tree build, make sure the source tree is clean.
547 $(Q)if [ -f $(srctree)/.config -o \
548 -d $(srctree)/include/config -o \
549 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
556 $(Q)ln -fsn $(srctree) source
558 $(Q)test -e .gitignore || \
562 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
564 CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
566 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
570 CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
573 CLANG_FLAGS += -no-integrated-as
575 CLANG_FLAGS += -Werror=unknown-warning-option
585 CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
587 ifdef config-build
589 # *config targets only - make sure prerequisites are updated, and descend
604 else #!config-build
606 # Build targets only - this includes vmlinux, arch specific targets, clean
610 # but instead __all depend on modules
615 __all: modules
618 # Decide whether to build built-in, modular, or both.
619 # Normally, just do built-in.
624 # If we have only "make modules", don't compile built-in objects.
625 ifeq ($(MAKECMDGOALS),modules)
629 # If we have "make <whatever> modules", compile modules
631 # Just "make" or "make all" shall build modules as well
633 ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
643 ifdef need-config
649 core-y := init/ usr/
650 drivers-y := drivers/ sound/
651 drivers-$(CONFIG_SAMPLES) += samples/
652 drivers-y += net/ virt/
653 libs-y := lib/
658 # This allow a user to issue only 'make' to build a kernel including modules
662 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \
663 $(call cc-option,-fno-tree-loop-im) \
664 $(call cc-disable-warning,maybe-uninitialized,)
669 CC_FLAGS_FTRACE := -pg
672 RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
673 RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register
674 RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
675 RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline
676 RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CL…
677 RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE…
683 ifdef need-config
684 ifdef may-sync-config
703 # This exploits the 'multi-target pattern rule' trick.
707 cmd_syncconfig = $(MAKE) -f $(srctree)/Makefile syncconfig
711 else # !may-sync-config
712 # External modules and some install targets need include/generated/autoconf.h
713 # and include/config/auto.conf but do not care if they are up-to-date.
718 $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
726 endif # may-sync-config
727 endif # need-config
729 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
730 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
731 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
732 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
733 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
736 KBUILD_CFLAGS += -O2
738 KBUILD_CFLAGS += -O3
740 KBUILD_CFLAGS += -Os
743 # Tell gcc to never replace conditional load with a non-conditional one
744 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
745 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
752 KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
753 $(call cc-option,-fno-ipa-cp-clone,) \
754 $(call cc-option,-fno-partial-inlining)
758 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
761 stackp-flags-y := -fno-stack-protector
762 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
763 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
765 KBUILD_CFLAGS += $(stackp-flags-y)
768 KBUILD_CPPFLAGS += -Qunused-arguments
769 KBUILD_CFLAGS += -Wno-format-invalid-specifier
770 KBUILD_CFLAGS += -Wno-gnu
774 KBUILD_CFLAGS += -mno-global-merge
779 KBUILD_CFLAGS += -Wno-unused-but-set-variable
781 # Warn about unmarked fall-throughs in switch statement.
784 KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
787 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
789 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
793 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
794 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
795 # -fomit-frame-pointer with FUNCTION_TRACER.
797 KBUILD_CFLAGS += -fomit-frame-pointer
803 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
811 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
812 KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
818 DEBUG_CFLAGS := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
824 DEBUG_CFLAGS += -gsplit-dwarf
826 DEBUG_CFLAGS += -g
830 KBUILD_AFLAGS += -Wa,-gdwarf-2
834 DEBUG_CFLAGS += -gdwarf-4
838 DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
839 $(call cc-option,-fno-var-tracking)
843 DEBUG_CFLAGS += -gz=zlib
844 KBUILD_AFLAGS += -gz=zlib
845 KBUILD_LDFLAGS += --compress-debug-sections=zlib
856 ifeq ($(call cc-option-yn,-mrecord-mcount),y)
857 CC_FLAGS_FTRACE += -mrecord-mcount
861 ifeq ($(call cc-option-yn, -mnop-mcount),y)
862 CC_FLAGS_FTRACE += -mnop-mcount
863 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
868 ifeq ($(call cc-option-yn, -mfentry),y)
869 CC_FLAGS_FTRACE += -mfentry
870 CC_FLAGS_USING += -DCC_USING_FENTRY
886 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
890 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
891 LDFLAGS_vmlinux += --gc-sections
895 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
901 KBUILD_CFLAGS += -falign-functions=32
905 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
908 KBUILD_CFLAGS += -Wdeclaration-after-statement
911 KBUILD_CFLAGS += -Wvla
914 KBUILD_CFLAGS += -Wno-pointer-sign
917 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
920 KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
921 KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
922 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
925 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
928 KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
931 KBUILD_CFLAGS += -fno-strict-overflow
933 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
934 KBUILD_CFLAGS += -fno-stack-check
937 KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
939 # Prohibit date/time macros, which would make the build non-deterministic
940 KBUILD_CFLAGS += -Werror=date-time
943 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
946 KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
949 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
951 # ensure -fcf-protection is disabled when using retpoline as it is
952 # incompatible with -mindirect-branch=thunk-extern
954 KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
958 include-y := scripts/Makefile.extrawarn
959 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
960 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
961 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
962 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
963 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
965 include $(addprefix $(srctree)/, $(include-y))
967 # scripts/Makefile.gcc-plugins is intentionally included last.
968 # Do not add $(call cc-option,...) below this line. When you build the kernel
976 KBUILD_LDFLAGS_MODULE += --build-id=sha1
977 LDFLAGS_vmlinux += --build-id=sha1
980 LDFLAGS_vmlinux += $(call ld-option, -X,)
984 LDFLAGS_vmlinux += --pack-dyn-relocs=relr
990 LDFLAGS_vmlinux += --orphan-handling=warn
994 KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
995 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
998 CHECKFLAGS += --arch=$(ARCH)
1001 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1004 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1031 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
1035 # INSTALL_MOD_STRIP, if defined, will cause modules to be
1037 # the default option --strip-debug will be used. Otherwise,
1042 mod_strip_cmd = $(STRIP) --strip-debug
1058 mod_compress_cmd = $(KGZIP) -n -f
1061 mod_compress_cmd = $(XZ) -f
1069 mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODU…
1075 HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
1077 has_libelf = $(call try-run,\
1078 echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
1101 export MODORDER := $(extmod-prefix)modules.order
1102 export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
1105 core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
1107 vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
1108 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
1109 $(libs-y) $(libs-m)))
1111 vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
1112 $(patsubst %/,%,$(filter %/, $(core-) \
1113 $(drivers-) $(libs-))))
1115 subdir-modorder := $(addsuffix modules.order,$(filter %/, \
1116 $(core-y) $(core-m) $(libs-y) $(libs-m) \
1117 $(drivers-y) $(drivers-m)))
1119 build-dirs := $(vmlinux-dirs)
1120 clean-dirs := $(vmlinux-alldirs)
1122 # Externally visible symbols (used by link-vmlinux.sh)
1123 KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
1124 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
1126 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1127 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1129 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
1131 KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
1136 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scrip…
1138 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
1144 # we have to build modules as well to determine what those symbols are.
1148 autoksyms_recursive: descend modules.order
1150 "$(MAKE) -f $(srctree)/Makefile vmlinux"
1156 cmd_autoksyms_h = mkdir -p $(dir $@); \
1165 cmd_link-vmlinux = \
1167 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
1169 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
1170 +$(call if_changed,link-vmlinux)
1176 $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
1193 # or the modules are listed in "prepare".
1194 # A multi level approach is used. prepareN is processed before prepareN-1.
1201 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
1209 prepare: prepare0 prepare-objtool prepare-resolve_btfids
1211 # Support for using generic headers in asm-generic
1212 asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
1214 PHONY += asm-generic uapi-asm-generic
1215 asm-generic: uapi-asm-generic
1216 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1217 generic=include/asm-generic
1218 uapi-asm-generic:
1219 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1220 generic=include/uapi/asm-generic
1222 PHONY += prepare-objtool prepare-resolve_btfids
1223 prepare-objtool: $(objtool_target)
1226 …metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1229 …nnot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1233 prepare-resolve_btfids: $(resolve_btfids_target)
1235 … BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1239 # ---------------------------------------------------------------------------
1246 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1261 $(Q)rm -f $(old_version_h)
1268 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1269 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1271 # ---------------------------------------------------------------------------
1279 mkdir -p $(INSTALL_HDR_PATH); \
1280 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1289 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1292 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1295 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1296 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1298 # Deprecated. It is no-op now.
1311 # ---------------------------------------------------------------------------
1316 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1318 kselftest-%: FORCE
1319 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1321 PHONY += kselftest-merge
1322 kselftest-merge:
1324 $(Q)find $(srctree)/tools/testing/selftests -name config | \
1325 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1326 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1328 # ---------------------------------------------------------------------------
1372 # ---------------------------------------------------------------------------
1373 # Modules
1377 # By default, build modules as well
1379 all: modules
1381 # When we're building modules with modversions, we need to consider
1382 # the built-in objects during the descend as well, in order to
1388 # Build modules
1390 # A module can be listed more than once in obj-m resulting in
1391 # duplicate lines in modules.order files. Those are removed
1394 PHONY += modules
1395 modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare target
1396 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1399 modules_check: modules.order
1400 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1402 cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
1404 modules.order: $(subdir-modorder) FORCE
1407 targets += modules.order
1409 # Target to prepare building external modules
1414 # Target to install modules
1420 @rm -rf $(MODLIB)/kernel
1421 @rm -f $(MODLIB)/source
1422 @mkdir -p $(MODLIB)/kernel
1423 @ln -s $(abspath $(srctree)) $(MODLIB)/source
1424 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
1425 rm -f $(MODLIB)/build ; \
1426 ln -s $(CURDIR) $(MODLIB)/build ; \
1428 @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
1429 @cp -f modules.builtin $(MODLIB)/
1430 @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
1431 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1434 # boot a modules.dep even before / is mounted read-write. However the
1443 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
1448 # Modules not configured
1449 # ---------------------------------------------------------------------------
1451 PHONY += modules modules_install
1452 modules modules_install: target
1454 @echo >&2 "The present kernel configuration has modules disabled."
1465 # Leave enough to build external modules
1471 modules.builtin modules.builtin.modinfo modules.nsdeps \
1477 debian snap tar-install \
1482 signing_key.x509.signer vmlinux-gdb.py \
1488 # clean - Delete most, but leave enough to build external modules
1490 clean: rm-files := $(CLEAN_FILES)
1495 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1496 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1500 # mrproper - Delete all generated files, including .config
1502 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1503 mrproper-dirs := $(addprefix _mrproper_,scripts)
1505 PHONY += $(mrproper-dirs) mrproper
1506 $(mrproper-dirs):
1509 mrproper: clean $(mrproper-dirs)
1514 distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
1521 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1522 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1523 -o -name 'core' \) \
1524 -type f -print | xargs rm -f
1528 # ---------------------------------------------------------------------------
1530 %src-pkg: FORCE
1531 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1533 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1536 # ---------------------------------------------------------------------------
1540 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1541 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1546 @echo ' clean - Remove most generated files but keep the config and'
1547 @echo ' enough build support to build external modules'
1548 @echo ' mrproper - Remove all generated files + config + various backup files'
1549 @echo ' distclean - mrproper + remove editor backup and patch files'
1552 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1555 @echo ' all - Build all targets marked with [*]'
1556 @echo '* vmlinux - Build the bare kernel'
1557 @echo '* modules - Build all modules'
1558 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1559 @echo ' dir/ - Build all files in dir and below'
1560 @echo ' dir/file.[ois] - Build specified target only'
1561 @echo ' dir/file.ll - Build the LLVM assembly file'
1563 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1565 @echo ' dir/file.ko - Build module including final link'
1566 @echo ' modules_prepare - Set up for building external modules'
1567 @echo ' tags/TAGS - Generate tags file for editors'
1568 @echo ' cscope - Generate cscope index'
1569 @echo ' gtags - Generate GNU GLOBAL index'
1570 @echo ' kernelrelease - Output the release version string (use with make -s)'
1571 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1572 @echo ' image_name - Output the image name (use with make -s)'
1573 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1577 @echo ' checkstack - Generate a list of stack hogs'
1578 @echo ' versioncheck - Sanity check on version.h usage'
1579 @echo ' includecheck - Check for duplicate included header files'
1580 @echo ' export_report - List the usages of all exported symbols'
1581 @echo ' headerdep - Detect inclusion cycles in headers'
1582 @echo ' coccicheck - Check with Coccinelle'
1583 @echo ' clang-analyzer - Check with clang static analyzer'
1584 @echo ' clang-tidy - Check with clang-tidy'
1587 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1590 @echo ' kselftest - Build and run kernel selftest'
1594 @echo ' kselftest-all - Build kernel selftest'
1595 @echo ' kselftest-install - Build and install kernel selftest'
1596 @echo ' kselftest-clean - Remove all generated kselftest files'
1597 @echo ' kselftest-merge - Merge all the config dependencies of'
1602 echo '* dtbs - Build device tree blobs for enabled boards'; \
1603 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1604 echo ' dt_binding_check - Validate device tree binding documents'; \
1605 echo ' dtbs_check - Validate device tree source files';\
1613 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1616 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1624 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1626 @$(if $(board-dirs), \
1627 $(foreach b, $(board-dirs), \
1628 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1629 printf " %-16s - Show all of the above\\n" help-boards; \
1635 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1649 help-board-dirs := $(addprefix help-,$(board-dirs))
1651 help-boards: $(help-board-dirs)
1653 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1655 $(help-board-dirs): help-%:
1657 @$(if $(boards-per-dir), \
1658 $(foreach b, $(boards-per-dir), \
1659 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1664 # ---------------------------------------------------------------------------
1672 # ---------------------------------------------------------------------------
1677 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1687 # When building external modules the kernel used as basis is considered
1688 # read-only, and no consistency checks are made and the make
1694 # modules.
1696 # make M=dir modules Make all modules in specified dir
1697 # make M=dir Same as 'make M=dir modules'
1699 # Install the modules built in the module directory
1702 # We are always building only modules.
1706 build-dirs := $(KBUILD_EXTMOD)
1707 PHONY += modules
1708 modules: $(MODORDER) target
1709 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1717 install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1720 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1721 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1727 compile_commands.json: $(extmod-prefix)compile_commands.json
1730 clean-dirs := $(KBUILD_EXTMOD)
1731 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
1736 @echo ' Building external modules.'
1737 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1739 @echo ' modules - default target, build the module(s)'
1740 @echo ' modules_install - install the module'
1741 @echo ' clean - remove generated files in module directory only'
1744 # no-op for external module builds
1750 # ---------------------------------------------------------------------------
1755 # The supported suffixes for single-target are listed in 'single-targets'
1761 ifdef single-build
1764 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1765 single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS)))
1767 $(single-ko): single_modpost
1769 $(single-no-ko): descend
1773 # For the single build of in-tree modules, use a temporary file to avoid
1774 # the situation of modules_install installing an invalid modules.order.
1775 MODORDER := .modules.tmp
1779 single_modpost: $(single-no-ko) modules_prepare
1780 $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
1781 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1785 export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
1788 build-dirs := $(foreach d, $(build-dirs), \
1797 # Handle descending into subdirectories listed in $(build-dirs)
1802 PHONY += descend $(build-dirs)
1803 descend: $(build-dirs)
1804 $(build-dirs): prepare
1806 single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
1807 need-builtin=1 need-modorder=1
1809 clean-dirs := $(addprefix _clean_, $(clean-dirs))
1810 PHONY += $(clean-dirs) clean
1811 $(clean-dirs):
1814 clean: $(clean-dirs)
1817 \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
1818 -o -name '*.ko.*' \
1819 -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
1820 -o -name '*.dwo' -o -name '*.lst' \
1821 -o -name '*.su' -o -name '*.mod' \
1822 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1823 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
1824 -o -name '*.asn1.[ch]' \
1825 -o -name '*.symtypes' -o -name 'modules.order' \
1826 -o -name '.tmp_*.o.*' \
1827 -o -name '*.c.[012]*.*' \
1828 -o -name '*.ll' \
1829 -o -name '*.gcno' \) -type f -print | xargs rm -f
1832 # ---------------------------------------------------------------------------
1840 # ---------------------------------------------------------------------------
1844 nsdeps: modules
1848 # ---------------------------------------------------------------------------
1851 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
1853 $(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
1858 targets += $(extmod-prefix)compile_commands.json
1860 PHONY += clang-tidy clang-analyzer
1864 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
1866 clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json
1869 clang-tidy clang-analyzer:
1875 # ---------------------------------------------------------------------------
1881 -name '*.[hcS]' -type f -print | sort \
1882 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
1886 -name '*.[hcS]' -type f -print | sort \
1887 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
1899 # else wants $(ARCH), including people doing cross-builds, which means
1907 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1926 $(Q)mkdir -p $(objtree)/tools
1927 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
1930 $(Q)mkdir -p $(objtree)/tools
1931 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
1933 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1934 cmd_rmfiles = rm -rf $(rm-files)
1942 existing-targets := $(wildcard $(sort $(targets)))
1944 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
1946 endif # config-build
1947 endif # mixed-build
1948 endif # need-sub-make