Lines Matching +full:sub +full:- +full:modules
1 # SPDX-License-Identifier: GPL-2.0
5 EXTRAVERSION = -rc2
14 ifeq ($(filter output-sync,$(.FEATURES)),)
28 # Most importantly: sub-Makefiles should only ever modify files in
31 # unavoidable when linking the built-in.a targets which finally
32 # turn into vmlinux), we will call a sub make in that other dir, and
41 this-makefile := $(lastword $(MAKEFILE_LIST))
42 abs_srctree := $(realpath $(dir $(this-makefile)))
47 # Do not use make's built-in rules and variables
48 # (this increases performance and avoids hard-to-debug behaviour)
49 MAKEFLAGS += -rR
61 # ---------------------------------------------------------------------------
71 # A simple variant is to prefix commands with $(Q) - that's useful
72 # for commands that shall be hidden in non-verbose mode.
94 # If the user is running make -s (silent mode), suppress echoing of
96 ifneq ($(findstring s,$(firstword -$(MAKEFLAGS))),)
106 # Use 'make C=1' to enable checking of only re-compiled files.
108 # of whether they are re-compiled or not.
110 # See the file "Documentation/dev-tools/sparse.rst" for more details,
142 $(error building multiple external modules is not supported))
165 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
192 # source directory or kernel build directory), external modules
209 # $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' first.
210 $(shell mkdir -p "$(output)")
226 no-print-directory := --no-print-directory
229 need-sub-make := 1
232 ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),)
233 # If --no-print-directory is unset, recurse once again to set it.
234 # You may end up recursing into __sub-make twice. This is needed due to the
236 need-sub-make := 1
239 ifeq ($(need-sub-make),1)
241 PHONY += $(MAKECMDGOALS) __sub-make
243 $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
247 __sub-make:
248 $(Q)$(MAKE) $(no-print-directory) -C $(abs_output) \
249 -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
251 else # need-sub-make
293 clean-targets := %clean mrproper cleandocs
294 no-dot-config-targets := $(clean-targets) \
296 kconfig-sym-check \
298 %asm-generic kernelversion %src-pkg dt_binding_check \
301 run-command
302 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
304 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/
306 config-build :=
307 mixed-build :=
308 need-config := 1
309 may-sync-config := 1
310 single-build :=
312 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
313 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
314 need-config :=
318 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
319 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
320 may-sync-config :=
324 need-compiler := $(may-sync-config)
327 may-sync-config :=
332 config-build := 1
334 mixed-build := 1
340 ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
341 single-build := 1
342 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
343 mixed-build := 1
347 # For "make -j clean all", "make -j mrproper defconfig all", etc.
348 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
349 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
350 mixed-build := 1
357 mixed-build := 1
361 ifdef mixed-build
372 $(Q)set -e; \
374 $(MAKE) -f $(srctree)/Makefile $$i; \
377 else # !mixed-build
382 KERNELRELEASE = $(call read-file, $(objtree)/include/config/kernel.release)
388 # Cross compiling and selecting different set of gcc/bin-utils
389 # ---------------------------------------------------------------------------
399 # during compilation. Only gcc and related bin-utils executables
402 # make CROSS_COMPILE=aarch64-linux-gnu-
451 else ifneq ($(filter -%,$(LLVM)),)
464 HOSTPKG_CONFIG = pkg-config
468 KERNELDOC = $(srctree)/tools/docs/kernel-doc
471 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
472 -O2 -fomit-frame-pointer -std=gnu11
479 # `-Aclippy::unwrap_or_default`: the lint is buggy [1] and ignores our
481 # [1] https://github.com/rust-lang/rust-clippy/issues/17379
482 export rust_common_flags := --edition=2021 \
483 -Zbinary_dep_depinfo=y \
484 -Astable_features \
485 -Aunused_features \
486 -Dnon_ascii_idents \
487 -Dunsafe_op_in_unsafe_fn \
488 -Wmissing_docs \
489 -Wrust_2018_idioms \
490 -Wunreachable_pub \
491 -Wclippy::all \
492 -Wclippy::as_ptr_cast_mut \
493 -Wclippy::as_underscore \
494 -Wclippy::cast_lossless \
495 -Aclippy::collapsible_if \
496 -Aclippy::collapsible_match \
497 -Wclippy::ignored_unit_patterns \
498 -Aclippy::incompatible_msrv \
499 -Wclippy::mut_mut \
500 -Wclippy::needless_bitwise_bool \
501 -Aclippy::needless_lifetimes \
502 -Wclippy::no_mangle_with_rust_abi \
503 -Wclippy::ptr_as_ptr \
504 -Wclippy::ptr_cast_constness \
505 -Wclippy::ref_as_ptr \
506 -Wclippy::undocumented_unsafe_blocks \
507 -Aclippy::uninlined_format_args \
508 -Wclippy::unnecessary_safety_comment \
509 -Wclippy::unnecessary_safety_doc \
510 -Aclippy::unwrap_or_default \
511 -Wrustdoc::missing_crate_level_docs \
512 -Wrustdoc::unescaped_backticks
515 $(HOSTCFLAGS) -I $(srctree)/scripts/include
516 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \
517 -I $(srctree)/scripts/include
518 KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
519 -Zallow-features=
525 CPP = $(CC) -E
529 AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
530 LLVM_LINK = $(LLVM_PREFIX)llvm-link$(LLVM_SUFFIX)
531 NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
532 OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
533 OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
534 READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
535 STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
536 ifeq ($(filter -fuse-ld=% --ld-path=%,$(KBUILD_HOSTLDFLAGS)),)
537 KBUILD_HOSTLDFLAGS += -fuse-ld=lld
552 CLIPPY_DRIVER = clippy-driver
573 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
574 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
587 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
588 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
589 -I$(srctree)/include/uapi \
590 -I$(objtree)/include/generated/uapi \
591 -include $(srctree)/include/linux/compiler-version.h \
592 -include $(srctree)/include/linux/kconfig.h
597 -I$(srctree)/arch/$(SRCARCH)/include \
598 -I$(objtree)/arch/$(SRCARCH)/include/generated \
599 -I$(srctree)/include \
600 -I$(objtree)/include \
603 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
606 KBUILD_CFLAGS += -fshort-wchar
607 KBUILD_CFLAGS += -funsigned-char
608 KBUILD_CFLAGS += -fno-common
609 KBUILD_CFLAGS += -fno-PIE
610 KBUILD_CFLAGS += -fno-strict-aliasing
612 KBUILD_CPPFLAGS := -D__KERNEL__
614 -Cpanic=abort -Cembed-bitcode=n -Clto=n \
615 -Cforce-unwind-tables=n -Ccodegen-units=1 \
616 -Csymbol-mangling-version=v0 \
617 -Crelocation-model=static \
618 -Zfunction-sections=n \
619 -Wclippy::float_arithmetic
625 KBUILD_AFLAGS_MODULE := -DMODULE
626 KBUILD_CFLAGS_MODULE := -DMODULE
627 KBUILD_RUSTFLAGS_MODULE := --cfg MODULE
643 # Allows finding `.clippy.toml` in out-of-srctree builds.
664 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
665 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
666 -prune -o
680 # Before starting out-of-tree build, make sure the source tree is clean.
709 @if [ -f $(srctree)/.config -o \
710 -d $(srctree)/include/config -o \
711 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
719 @if [ -f $(srcroot)/modules.order ]; then \
722 echo >&2 "*** Please run 'make -C $(abs_srctree) M=$(realpath $(srcroot)) clean'"; \
727 $(Q)ln -fsn $(srcroot) source
728 $(Q)test -e .gitignore || \
737 CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
738 RUSTC_VERSION_TEXT = $(subst $(pound),,$(shell $(RUSTC) --version 2>/dev/null))
739 PAHOLE_VERSION = $(shell $(srctree)/scripts/pahole-version.sh $(PAHOLE))
746 # cc-cross-prefix to determine CROSS_COMPILE.
747 ifdef need-compiler
751 ifdef config-build
753 # *config targets only - make sure prerequisites are updated, and descend
756 # Read arch-specific Makefile to set KBUILD_DEFCONFIG as needed.
768 else #!config-build
770 # Build targets only - this includes vmlinux, arch-specific targets, clean
774 # but instead __all depend on modules
779 __all: modules
784 # Decide whether to build built-in, modular, or both.
785 # Normally, just do built-in.
790 # If we have only "make modules", don't compile built-in objects.
791 ifeq ($(MAKECMDGOALS),modules)
795 # If we have "make <whatever> modules", compile modules
797 # Just "make" or "make all" shall build modules as well
799 ifneq ($(filter all modules nsdeps compile_commands.json clang-% sbom,$(MAKECMDGOALS)),)
809 ifdef need-config
813 CC_FLAGS_DIALECT := -std=gnu11
819 CC_FLAGS_DIALECT += -Wno-gnu
820 CC_FLAGS_DIALECT += -Wno-microsoft-anon-tag
827 core-y :=
828 drivers-y :=
829 libs-y := lib/
834 # This allow a user to issue only 'make' to build a kernel including modules
840 CC_FLAGS_FTRACE := -pg
862 # Per-version Rust flags. These are like `rust_common_flags`, but may
863 # depend on the Rust compiler version (e.g. using `rustc-min-version`).
865 # `-Aclippy::precedence`: the lint was extended in Rust 1.85.0 to
870 $(if $(call rustc-min-version,108600),,-Aclippy::precedence)
878 ifdef need-config
879 ifdef may-sync-config
898 # This exploits the 'multi-target pattern rule' trick.
906 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
907 else # !may-sync-config
908 # External modules and some install targets need include/generated/autoconf.h
909 # and include/config/auto.conf but do not care if they are up-to-date.
912 checked-configs := $(addprefix $(objtree)/, include/generated/autoconf.h include/generated/rustc_cf…
913 missing-configs := $(filter-out $(wildcard $(checked-configs)), $(checked-configs))
915 ifdef missing-configs
921 @printf >&2 '*** - %s\n' $(missing-configs)
927 endif # may-sync-config
928 endif # need-config
930 KBUILD_CFLAGS += -fno-delete-null-pointer-checks
933 KBUILD_CFLAGS += -O2
934 KBUILD_RUSTFLAGS += -Copt-level=2
936 KBUILD_CFLAGS += -Os
937 KBUILD_RUSTFLAGS += -Copt-level=s
940 # Always set `debug-assertions` and `overflow-checks` because their default
941 # depends on `opt-level` and `debug-assertions`, respectively.
942 KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
943 KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
945 # Tell gcc to never replace conditional load with a non-conditional one
947 # gcc-10 renamed --param=allow-store-data-races=0 to
948 # -fno-allow-store-data-races.
949 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
950 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
958 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
961 stackp-flags-y := -fno-stack-protector
962 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
963 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
965 KBUILD_CFLAGS += $(stackp-flags-y)
968 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
969 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
971 # https://github.com/rust-lang/rust/pull/156980.
972 KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109800),,-Zllvm_module_flag=frame-pointer:u32:2:m…
976 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
977 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
978 # -fomit-frame-pointer with FUNCTION_TRACER.
979 # In the Rust target specification, "frame-pointer" is set explicitly
980 # to "may-omit".
982 KBUILD_CFLAGS += -fomit-frame-pointer
988 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
993 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
995 # https://github.com/llvm/llvm-project/issues/44842
996 CC_AUTO_VAR_INIT_ZERO_ENABLER := -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from…
1004 KBUILD_CFLAGS += -falloc-token-max=16
1009 KBUILD_CFLAGS += -fexperimental-late-parse-attributes
1014 KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
1018 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
1021 KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-context=2)
1025 KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-inlining-chain)
1029 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
1034 CC_FLAGS_FTRACE += -mrecord-mcount
1036 ifeq ($(call cc-option-yn, -mnop-mcount),y)
1037 CC_FLAGS_FTRACE += -mnop-mcount
1038 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
1044 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
1054 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
1055 ifeq ($(call cc-option-yn, -mfentry),y)
1056 CC_FLAGS_FTRACE += -mfentry
1057 CC_FLAGS_USING += -DCC_USING_FENTRY
1067 KBUILD_CFLAGS += -fno-inline-functions-called-once
1070 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
1072 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
1073 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
1074 LDFLAGS_vmlinux += --gc-sections
1079 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
1081 KBUILD_RUSTFLAGS += -Zsanitizer=shadow-call-stack
1091 CC_FLAGS_RUST_INLINE_HELPERS := -mllvm -trap-unreachable \
1092 -mllvm -no-trap-after-noreturn
1098 CC_FLAGS_LTO := -flto
1100 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
1102 # These LLVM options were initially added with only in-process ThinLTO
1105 KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-lo…
1108 CC_FLAGS_LTO += -fvisibility=hidden
1111 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
1115 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
1116 KBUILD_AFLAGS += -fno-lto
1121 CC_FLAGS_CFI := -fsanitize=kcfi
1123 CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
1126 CC_FLAGS_CFI += -fsanitize-kcfi-arity
1129 # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
1132 RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled
1140 # Architectures can define flags to add/remove for floating-point support
1141 CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT
1147 # -fmin-function-alignment if it is available, or fall back to -falign-funtions.
1150 KBUILD_CFLAGS += -fmin-function-alignment=$(CONFIG_FUNCTION_ALIGNMENT)
1152 KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
1157 NOSTDINC_FLAGS += -nostdinc
1163 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
1166 KBUILD_CFLAGS += -fno-strict-overflow
1168 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1169 KBUILD_CFLAGS += -fno-stack-check
1173 KBUILD_CFLAGS += -fconserve-stack
1177 KBUILD_CFLAGS += -fno-builtin-wcslen
1179 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
1181 CFLAGS_GCOV += -fno-tree-loop-im
1182 # Use atomic counter updates to avoid concurrent-access crashes in GCOV.
1183 # Only enable if -fprofile-update=prefer-atomic does not introduce new
1185 CFLAGS_GCOV += $(call try-run,\
1187 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w -fprofile-arcs \
1188 -ftest-coverage -x c - -c -o "$$TMP.base" && \
1190 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w -fprofile-arcs \
1191 -ftest-coverage -fprofile-update=prefer-atomic \
1192 -x c - -c -o "$$TMP" && \
1195 cmp -s "$$TMP.ubase" "$$TMP.utest",\
1196 -fprofile-update=prefer-atomic)
1202 KBUILD_CPPFLAGS += -fmacro-prefix-map=$(srcroot)/=
1203 ifeq ($(call rustc-option-yn, --remap-path-scope=macro),y)
1204 KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/= --remap-path-scope=macro
1209 include-y := scripts/Makefile.warn
1210 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1211 include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf
1212 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1213 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1214 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
1215 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1216 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1217 include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
1218 include-$(CONFIG_KSTACK_ERASE) += scripts/Makefile.kstack_erase
1219 include-$(CONFIG_AUTOFDO_CLANG) += scripts/Makefile.autofdo
1220 include-$(CONFIG_PROPELLER_CLANG) += scripts/Makefile.propeller
1221 include-$(CONFIG_WARN_CONTEXT_ANALYSIS) += scripts/Makefile.context-analysis
1222 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1224 include $(addprefix $(srctree)/, $(include-y))
1226 # scripts/Makefile.gcc-plugins is intentionally included last.
1227 # Do not add $(call cc-option,...) below this line. When you build the kernel
1236 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1237 LDFLAGS_vmlinux += --build-id=sha1
1240 # COMDAT-deduplicated sections. Use --force-group-allocation to resolve these
1241 # groups when linking modules. The option is available from ld.bfd 2.29 and
1243 KBUILD_LDFLAGS_MODULE += $(call ld-option,--force-group-allocation)
1245 KBUILD_LDFLAGS += -z noexecstack
1247 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1251 LDFLAGS_vmlinux += -X
1255 # ld.lld before 15 did not support -z pack-relative-relocs.
1256 LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
1262 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
1266 LDFLAGS_vmlinux += --emit-relocs --discard-none
1270 USERFLAGS_FROM_KERNEL := --target=%
1277 USERFLAGS_FROM_KERNEL += -m32 -m64
1285 KBUILD_USERLDFLAGS += --ld-path=$(LD)
1289 CHECKFLAGS += --arch=$(ARCH)
1292 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1295 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1299 ifneq ($(shell $(srctree)/scripts/checker-valid.sh $(CHECK) $(CHECKFLAGS)), 1)
1330 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
1337 build-dir := .
1338 clean-dirs := $(sort . Documentation \
1339 $(patsubst %/,%,$(filter %/, $(core-) \
1340 $(drivers-) $(libs-))))
1342 export ARCH_CORE := $(core-y)
1343 export ARCH_LIB := $(filter %/, $(libs-y))
1344 export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
1345 # Externally visible symbols (used by link-vmlinux.sh)
1347 KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1348 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1355 # we have to build modules as well to determine what those symbols are.
1360 vmlinux_a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
1361 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_a
1368 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
1387 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
1411 # or the modules are listed in "prepare".
1412 # A multi level approach is used. prepareN is processed before prepareN-1.
1419 asm-generic $(version_h) include/generated/utsrelease.h \
1421 include/generated/rustc_cfg remove-stale-files
1434 PHONY += remove-stale-files
1435 remove-stale-files:
1436 $(Q)$(srctree)/scripts/remove-stale-files
1438 # Support for using generic headers in asm-generic
1439 asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj
1441 PHONY += asm-generic uapi-asm-generic
1442 asm-generic: uapi-asm-generic
1443 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1444 generic=include/asm-generic
1445 uapi-asm-generic:
1446 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1447 generic=include/uapi/asm-generic
1450 # ---------------------------------------------------------------------------
1457 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1465 if [ $(SUBLEVEL) -gt 255 ]; then \
1495 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1496 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1498 # ---------------------------------------------------------------------------
1506 mkdir -p $(INSTALL_HDR_PATH); \
1507 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1516 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1519 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders
1521 $(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
1523 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1524 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1543 # ---------------------------------------------------------------------------
1548 # to this Makefile to build and install external modules.
1554 # ---------------------------------------------------------------------------
1558 vdso_install: export INSTALL_FILES = $(vdso-install-y)
1560 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
1562 # ---------------------------------------------------------------------------
1583 # the target's --target=/--sysroot= flags into the host clang invocation under
1587 $(Q)mkdir -p $(objtree)/tools
1588 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ \
1605 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1614 …$(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) $(patsubst objt…
1623 $(Q)$(MAKE) -sC $(srctree)/tools/bootconfig O=$(bootconfig_O) clean
1627 $(Q)mkdir -p $(objtree)/tools
1628 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1631 $(Q)mkdir -p $(objtree)/tools
1632 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1634 # ---------------------------------------------------------------------------
1639 $(Q)unset sub_make_done; $(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1641 kselftest-%: headers FORCE
1642 $(Q)unset sub_make_done; $(MAKE) -C $(srctree)/tools/testing/selftests $*
1644 PHONY += kselftest-merge
1645 kselftest-merge:
1647 $(Q)find $(srctree)/tools/testing/selftests -name config -o -name config.$(UTS_MACHINE) | \
1648 xargs $(srctree)/scripts/kconfig/merge_config.sh -y -m $(objtree)/.config
1649 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1651 # ---------------------------------------------------------------------------
1674 $(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
1692 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=$(dtstree)
1725 $(Q)$(srctree)/scripts/dtc/dt-style-selftest/run.sh
1727 # ---------------------------------------------------------------------------
1728 # Modules
1732 # By default, build modules as well
1734 all: modules
1736 # When we're building modules with modversions, we need to consider
1737 # the built-in objects during the descend as well, in order to
1743 # Build modules
1750 modules: vmlinux target
1753 modules: modules_prepare target
1755 # Target to prepare building external modules
1764 # Leave enough to build external modules
1769 CLEAN_FILES += vmlinux.symvers modules-only.symvers \
1770 modules.builtin modules.builtin.modinfo modules.nsdeps \
1771 modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
1772 vmlinux.thinlto-index builtin.order \
1774 rust-project.json .vmlinux.objs .vmlinux.export.c \
1775 .builtin-dtbs-list .builtin-dtbs.S sbom-*.spdx.json
1780 debian snap tar-install PKGBUILD pacman \
1785 vmlinux-gdb.py \
1791 # clean - Delete most, but leave enough to build external modules
1793 clean: private rm-files := $(CLEAN_FILES)
1798 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1799 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1803 # mrproper - Delete all generated files, including .config
1805 mrproper: private rm-files := $(MRPROPER_FILES)
1806 mrproper-dirs := $(addprefix _mrproper_,scripts)
1808 PHONY += $(mrproper-dirs) mrproper
1809 $(mrproper-dirs):
1812 mrproper: clean objtool_mrproper $(mrproper-dirs)
1815 \( -name '*.rmeta' \) \
1816 -type f -print | xargs rm -f
1824 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1825 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1826 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1827 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1828 -type f -print | xargs rm -f
1832 # ---------------------------------------------------------------------------
1834 modules-cpio-pkg: usr_gen_init_cpio
1836 %src-pkg: FORCE
1837 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1839 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1842 # ---------------------------------------------------------------------------
1846 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1847 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1852 @echo ' clean - Remove most generated files but keep the config and'
1853 @echo ' enough build support to build external modules'
1854 @echo ' mrproper - Remove all generated files + config + various backup files'
1855 @echo ' distclean - mrproper + remove editor backup and patch files'
1857 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1860 @echo ' all - Build all targets marked with [*]'
1861 @echo '* vmlinux - Build the bare kernel'
1862 @echo '* modules - Build all modules'
1863 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1864 @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
1865 @echo ' dir/ - Build all files in dir and below'
1866 @echo ' dir/file.[ois] - Build specified target only'
1867 @echo ' dir/file.ll - Build the LLVM assembly file'
1869 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1871 @echo ' dir/file.ko - Build module including final link'
1872 @echo ' modules_prepare - Set up for building external modules'
1873 @echo ' tags/TAGS - Generate tags file for editors'
1874 @echo ' cscope - Generate cscope index'
1875 @echo ' gtags - Generate GNU GLOBAL index'
1876 @echo ' kernelrelease - Output the release version string (use with make -s)'
1877 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1878 @echo ' image_name - Output the image name (use with make -s)'
1879 @echo ' headers - Build ready-to-install UAPI headers in usr/include'
1880 @echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
1884 @echo ' checkstack - Generate a list of stack hogs and consider all functions'
1886 @echo ' versioncheck - Sanity check on version.h usage'
1887 @echo ' includecheck - Check for duplicate included header files'
1888 @echo ' headerdep - Detect inclusion cycles in headers'
1889 @echo ' coccicheck - Check with Coccinelle'
1890 @echo ' kconfig-sym-check - Check for dangling Kconfig symbol references'
1891 @echo ' clang-analyzer - Check with clang static analyzer'
1892 @echo ' clang-tidy - Check with clang-tidy'
1895 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1896 @echo ' sbom - Generate Software Bill of Materials'
1899 @echo ' kselftest - Build and run kernel selftest'
1903 @echo ' kselftest-all - Build kernel selftest'
1904 @echo ' kselftest-install - Build and install kernel selftest'
1905 @echo ' kselftest-clean - Remove all generated kselftest files'
1906 @echo ' kselftest-merge - Merge all the config dependencies of'
1910 @echo ' rustavailable - Checks whether the Rust toolchain is'
1912 @echo ' rustfmt - Reformat all the Rust code in the kernel'
1913 @echo ' rustfmtcheck - Checks if all the Rust code in the kernel'
1915 @echo ' rustdoc - Generate Rust documentation'
1917 @echo ' rusttest - Runs the Rust tests'
1919 @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1921 @echo ' dir/file.[os] - Build specified target only'
1922 @echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
1925 @echo ' dir/file.ll - Build the LLVM assembly file'
1929 echo '* dtbs - Build device tree blobs for enabled boards'; \
1930 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1931 echo ' dt_binding_check - Validate device tree binding documents and examples'; \
1932 echo ' dt_binding_schemas - Build processed device tree binding schemas'; \
1933 echo ' dt_style_selftest - Run dt-check-style fixture tests'; \
1934 echo ' dtbs_check - Validate device tree source files';\
1942 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1945 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1947 @echo 'Architecture-specific targets ($(SRCARCH)):'
1949 echo ' No architecture-specific help defined for $(SRCARCH)')
1953 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1955 @$(if $(board-dirs), \
1956 $(foreach b, $(board-dirs), \
1957 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1958 printf " %-16s - Show all of the above\\n" help-boards; \
1965 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1987 help-board-dirs := $(addprefix help-,$(board-dirs))
1989 help-boards: $(help-board-dirs)
1991 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1993 $(help-board-dirs): help-%:
1994 @echo 'Architecture-specific targets ($(SRCARCH) $*):'
1995 @$(if $(boards-per-dir), \
1996 $(foreach b, $(boards-per-dir), \
1997 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
2002 # ---------------------------------------------------------------------------
2005 htmldocs-redirects
2013 # ---------------------------------------------------------------------------
2022 # Using the singular to avoid running afoul of `no-dot-config-targets`.
2040 -path $(srctree)/rust/proc-macro2 \
2041 -o -path $(srctree)/rust/quote \
2042 -o -path $(srctree)/rust/syn \
2043 -o -path $(srctree)/rust/zerocopy \
2044 -o -path $(srctree)/rust/zerocopy-derive \
2045 \) -prune -o \
2046 -type f -a -name '*.rs' -a ! -name '*generated*' -print \
2049 rustfmtcheck: rustfmt_flags = --check
2053 # ---------------------------------------------------------------------------
2055 PHONY += misc-check
2056 misc-check:
2057 $(Q)$(srctree)/scripts/misc-check
2059 all: misc-check
2064 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
2076 # When building external modules the kernel used as basis is considered
2077 # read-only, and no consistency checks are made and the make
2081 # We are always building only modules.
2085 build-dir := .
2087 clean-dirs := .
2088 clean: private rm-files := Module.symvers modules.nsdeps compile_commands.json
2108 @echo ' Building external modules.'
2109 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
2111 @echo ' modules - default target, build the module(s)'
2112 @echo ' modules_install - install the module'
2113 @echo ' clean - remove generated files in module directory only'
2114 @echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
2118 modules modules_install: __external_modules_error target
2122 @echo >&2 '*** You cannot build or install external modules.'
2129 # ---------------------------------------------------------------------------
2130 # Modules
2132 PHONY += modules modules_install modules_sign modules_prepare
2135 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
2136 sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
2146 @echo >&2 '*** CONFIG_MODULE_SIG is disabled. You cannot sign modules.'
2153 modules.order: $(build-dir)
2156 # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
2158 modules: modpost target
2160 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
2164 modules_check: modules.order
2165 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
2169 modules: target
2177 modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
2179 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
2182 # ---------------------------------------------------------------------------
2187 # The supported suffixes for single-target are listed in 'single-targets'
2193 ifdef single-build
2196 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
2197 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
2198 $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
2200 $(single-ko): single_modules
2202 $(single-no-ko): $(build-dir)
2205 # Remove modules.order when done because it is not the real one.
2207 single_modules: $(single-no-ko) modules_prepare
2208 $(Q){ $(foreach m, $(single-ko), echo $(m:%.ko=%.o);) } > modules.order
2209 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
2211 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
2213 $(Q)rm -f modules.order
2215 single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
2227 PHONY += $(build-dir)
2228 $(build-dir): prepare
2229 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
2231 clean-dirs := $(addprefix _clean_, $(clean-dirs))
2232 PHONY += $(clean-dirs) clean
2233 $(clean-dirs):
2236 clean: $(clean-dirs)
2239 \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
2240 -o -name '*.ko.*' -o -name '*.o.thinlto.bc' \
2241 -o -name '*.dtb' -o -name '*.dtbo' \
2242 -o -name '*.dtb.S' -o -name '*.dtbo.S' \
2243 -o -name '*.dt.yaml' -o -name 'dtbs-list' \
2244 -o -name '*.dwo' -o -name '*.lst' \
2245 -o -name '*.su' -o -name '*.mod' \
2246 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2247 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
2248 -o -name '*.asn1.[ch]' \
2249 -o -name '*.symtypes' -o -name 'modules.order' \
2250 -o -name '*.c.[012]*.*' \
2251 -o -name '*.ll' \
2252 -o -name '*.gcno' \
2253 -o -name '*.long-type-*.txt' \
2254 \) -type f -print \
2255 -o -name '.tmp_*' -print \
2256 | xargs rm -rf
2259 # ---------------------------------------------------------------------------
2266 # Generate rust-project.json (a file that describes the structure of non-Cargo
2267 # Rust projects) for rust-analyzer (an implementation of the Language Server
2269 PHONY += rust-analyzer
2270 rust-analyzer:
2273 # FIXME: external modules must not descend into a sub-directory of the kernel
2280 # ---------------------------------------------------------------------------
2284 nsdeps: modules
2288 # ---------------------------------------------------------------------------
2291 sbom_targets := sbom-source.spdx.json
2293 sbom_targets += sbom-build.spdx.json sbom-output.spdx.json
2295 cmd_sbom = printf "%s\n" "$(KBUILD_IMAGE)" >"$(tmp-target)"; \
2296 … $(if $(CONFIG_MODULES),sed 's/\.o$$/.ko/' $(objtree)/modules.order >> "$(tmp-target)";) \
2298 --src-tree $(abspath $(srctree)) \
2299 --obj-tree $(abspath $(objtree)) \
2300 --roots-file "$(tmp-target)" \
2301 --output-directory $(abspath $(objtree)) \
2302 --generate-spdx \
2303 --package-license "GPL-2.0 WITH Linux-syscall-note" \
2304 --package-version "$(KERNELVERSION)" \
2305 --write-output-on-error;
2307 sbom: $(notdir $(KBUILD_IMAGE)) include/generated/autoconf.h $(if $(CONFIG_MODULES),modules modules…
2311 # ---------------------------------------------------------------------------
2314 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
2316 compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
2318 $(if $(CONFIG_MODULES), modules.order) FORCE
2323 PHONY += clang-tidy clang-analyzer
2327 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
2329 clang-tidy clang-analyzer: compile_commands.json
2332 clang-tidy clang-analyzer:
2338 # ---------------------------------------------------------------------------
2340 PHONY += includecheck versioncheck coccicheck kconfig-sym-check
2344 -name '*.[hcS]' -type f -print | sort \
2345 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2349 -name '*.[hcS]' -type f -print | sort \
2350 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2355 kconfig-sym-check:
2356 …$(Q)$(PERL) $(srctree)/scripts/kconfig/kconfig-sym-check.pl $(srctree) $(KCONFIG_SYM_CHECK_EXCLUDE…
2362 # else wants $(ARCH), including people doing cross-builds, which means
2371 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2383 PHONY += run-command
2384 run-command:
2387 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2388 cmd_rmfiles = rm -rf $(rm-files)
2391 existing-targets := $(wildcard $(sort $(targets)))
2393 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2395 endif # config-build
2396 endif # mixed-build
2397 endif # need-sub-make