Lines Matching +full:json +full:- +full:schema

1 # SPDX-License-Identifier: GPL-2.0
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
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,
165 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
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
478 export rust_common_flags := --edition=2021 \
479 -Zbinary_dep_depinfo=y \
480 -Astable_features \
481 -Aunused_features \
482 -Dnon_ascii_idents \
483 -Dunsafe_op_in_unsafe_fn \
484 -Wmissing_docs \
485 -Wrust_2018_idioms \
486 -Wunreachable_pub \
487 -Wclippy::all \
488 -Wclippy::as_ptr_cast_mut \
489 -Wclippy::as_underscore \
490 -Wclippy::cast_lossless \
491 -Aclippy::collapsible_if \
492 -Aclippy::collapsible_match \
493 -Wclippy::ignored_unit_patterns \
494 -Aclippy::incompatible_msrv \
495 -Wclippy::mut_mut \
496 -Wclippy::needless_bitwise_bool \
497 -Aclippy::needless_lifetimes \
498 -Wclippy::no_mangle_with_rust_abi \
499 -Wclippy::ptr_as_ptr \
500 -Wclippy::ptr_cast_constness \
501 -Wclippy::ref_as_ptr \
502 -Wclippy::undocumented_unsafe_blocks \
503 -Aclippy::uninlined_format_args \
504 -Wclippy::unnecessary_safety_comment \
505 -Wclippy::unnecessary_safety_doc \
506 -Wrustdoc::missing_crate_level_docs \
507 -Wrustdoc::unescaped_backticks
510 $(HOSTCFLAGS) -I $(srctree)/scripts/include
511 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \
512 -I $(srctree)/scripts/include
513 KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
514 -Zallow-features=
520 CPP = $(CC) -E
524 AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
525 LLVM_LINK = $(LLVM_PREFIX)llvm-link$(LLVM_SUFFIX)
526 NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
527 OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
528 OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
529 READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
530 STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
531 ifeq ($(filter -fuse-ld=% --ld-path=%,$(KBUILD_HOSTLDFLAGS)),)
532 KBUILD_HOSTLDFLAGS += -fuse-ld=lld
547 CLIPPY_DRIVER = clippy-driver
568 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
569 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
582 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
583 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
584 -I$(srctree)/include/uapi \
585 -I$(objtree)/include/generated/uapi \
586 -include $(srctree)/include/linux/compiler-version.h \
587 -include $(srctree)/include/linux/kconfig.h
592 -I$(srctree)/arch/$(SRCARCH)/include \
593 -I$(objtree)/arch/$(SRCARCH)/include/generated \
594 -I$(srctree)/include \
595 -I$(objtree)/include \
598 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
601 KBUILD_CFLAGS += -fshort-wchar
602 KBUILD_CFLAGS += -funsigned-char
603 KBUILD_CFLAGS += -fno-common
604 KBUILD_CFLAGS += -fno-PIE
605 KBUILD_CFLAGS += -fno-strict-aliasing
607 KBUILD_CPPFLAGS := -D__KERNEL__
609 -Cpanic=abort -Cembed-bitcode=n -Clto=n \
610 -Cforce-unwind-tables=n -Ccodegen-units=1 \
611 -Csymbol-mangling-version=v0 \
612 -Crelocation-model=static \
613 -Zfunction-sections=n \
614 -Wclippy::float_arithmetic
620 KBUILD_AFLAGS_MODULE := -DMODULE
621 KBUILD_CFLAGS_MODULE := -DMODULE
622 KBUILD_RUSTFLAGS_MODULE := --cfg MODULE
638 # Allows finding `.clippy.toml` in out-of-srctree builds.
659 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
660 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
661 -prune -o
675 # Before starting out-of-tree build, make sure the source tree is clean.
706 @if [ -f $(srctree)/.config -o \
707 -d $(srctree)/include/config -o \
708 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
716 @if [ -f $(srcroot)/modules.order ]; then \
719 echo >&2 "*** Please run 'make -C $(abs_srctree) M=$(realpath $(srcroot)) clean'"; \
724 $(Q)ln -fsn $(srcroot) source
725 $(Q)test -e .gitignore || \
734 CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
735 RUSTC_VERSION_TEXT = $(subst $(pound),,$(shell $(RUSTC) --version 2>/dev/null))
736 PAHOLE_VERSION = $(shell $(srctree)/scripts/pahole-version.sh $(PAHOLE))
743 # cc-cross-prefix to determine CROSS_COMPILE.
744 ifdef need-compiler
748 ifdef config-build
750 # *config targets only - make sure prerequisites are updated, and descend
753 # Read arch-specific Makefile to set KBUILD_DEFCONFIG as needed.
765 else #!config-build
767 # Build targets only - this includes vmlinux, arch-specific targets, clean
781 # Decide whether to build built-in, modular, or both.
782 # Normally, just do built-in.
787 # If we have only "make modules", don't compile built-in objects.
796 ifneq ($(filter all modules nsdeps compile_commands.json clang-% sbom,$(MAKECMDGOALS)),)
806 ifdef need-config
810 CC_FLAGS_DIALECT := -std=gnu11
816 CC_FLAGS_DIALECT += -Wno-gnu
817 CC_FLAGS_DIALECT += -Wno-microsoft-anon-tag
824 core-y :=
825 drivers-y :=
826 libs-y := lib/
837 CC_FLAGS_FTRACE := -pg
859 # Per-version Rust flags. These are like `rust_common_flags`, but may
860 # depend on the Rust compiler version (e.g. using `rustc-min-version`).
862 # `-Aclippy::precedence`: the lint was extended in Rust 1.85.0 to
867 $(if $(call rustc-min-version,108600),,-Aclippy::precedence)
875 ifdef need-config
876 ifdef may-sync-config
895 # This exploits the 'multi-target pattern rule' trick.
903 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
904 else # !may-sync-config
906 # and include/config/auto.conf but do not care if they are up-to-date.
909 checked-configs := $(addprefix $(objtree)/, include/generated/autoconf.h include/generated/rustc_cfg include/config/auto.conf)
910 missing-configs := $(filter-out $(wildcard $(checked-configs)), $(checked-configs))
912 ifdef missing-configs
918 @printf >&2 '*** - %s\n' $(missing-configs)
924 endif # may-sync-config
925 endif # need-config
927 KBUILD_CFLAGS += -fno-delete-null-pointer-checks
930 KBUILD_CFLAGS += -O2
931 KBUILD_RUSTFLAGS += -Copt-level=2
933 KBUILD_CFLAGS += -Os
934 KBUILD_RUSTFLAGS += -Copt-level=s
937 # Always set `debug-assertions` and `overflow-checks` because their default
938 # depends on `opt-level` and `debug-assertions`, respectively.
939 KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
940 KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
942 # Tell gcc to never replace conditional load with a non-conditional one
944 # gcc-10 renamed --param=allow-store-data-races=0 to
945 # -fno-allow-store-data-races.
946 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
947 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
955 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
958 stackp-flags-y := -fno-stack-protector
959 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
960 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
962 KBUILD_CFLAGS += $(stackp-flags-y)
965 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
966 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
968 # https://github.com/rust-lang/rust/pull/156980.
969 KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109800),,-Zllvm_module_flag=frame-pointer:u32:2:max)
973 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
974 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
975 # -fomit-frame-pointer with FUNCTION_TRACER.
976 # In the Rust target specification, "frame-pointer" is set explicitly
977 # to "may-omit".
979 KBUILD_CFLAGS += -fomit-frame-pointer
985 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
990 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
992 # https://github.com/llvm/llvm-project/issues/44842
993 CC_AUTO_VAR_INIT_ZERO_ENABLER := -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
1001 KBUILD_CFLAGS += -falloc-token-max=16
1006 KBUILD_CFLAGS += -fexperimental-late-parse-attributes
1011 KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
1015 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
1018 KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-context=2)
1022 KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-inlining-chain)
1026 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
1031 CC_FLAGS_FTRACE += -mrecord-mcount
1033 ifeq ($(call cc-option-yn, -mnop-mcount),y)
1034 CC_FLAGS_FTRACE += -mnop-mcount
1035 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
1041 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
1051 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
1052 ifeq ($(call cc-option-yn, -mfentry),y)
1053 CC_FLAGS_FTRACE += -mfentry
1054 CC_FLAGS_USING += -DCC_USING_FENTRY
1064 KBUILD_CFLAGS += -fno-inline-functions-called-once
1067 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
1069 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
1070 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
1071 LDFLAGS_vmlinux += --gc-sections
1076 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
1078 KBUILD_RUSTFLAGS += -Zsanitizer=shadow-call-stack
1085 CC_FLAGS_LTO := -flto
1087 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
1089 # These LLVM options were initially added with only in-process ThinLTO
1092 KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-locals=false)
1095 CC_FLAGS_LTO += -fvisibility=hidden
1098 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
1102 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
1103 KBUILD_AFLAGS += -fno-lto
1108 CC_FLAGS_CFI := -fsanitize=kcfi
1110 CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
1113 CC_FLAGS_CFI += -fsanitize-kcfi-arity
1116 # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
1118 RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
1126 # Architectures can define flags to add/remove for floating-point support
1127 CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT
1133 # -fmin-function-alignment if it is available, or fall back to -falign-funtions.
1136 KBUILD_CFLAGS += -fmin-function-alignment=$(CONFIG_FUNCTION_ALIGNMENT)
1138 KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
1143 NOSTDINC_FLAGS += -nostdinc
1149 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
1152 KBUILD_CFLAGS += -fno-strict-overflow
1154 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1155 KBUILD_CFLAGS += -fno-stack-check
1159 KBUILD_CFLAGS += -fconserve-stack
1163 KBUILD_CFLAGS += -fno-builtin-wcslen
1165 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
1167 CFLAGS_GCOV += -fno-tree-loop-im
1168 # Use atomic counter updates to avoid concurrent-access crashes in GCOV.
1169 # Only enable if -fprofile-update=prefer-atomic does not introduce new
1171 CFLAGS_GCOV += $(call try-run,\
1173 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w -fprofile-arcs \
1174 -ftest-coverage -x c - -c -o "$$TMP.base" && \
1176 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w -fprofile-arcs \
1177 -ftest-coverage -fprofile-update=prefer-atomic \
1178 -x c - -c -o "$$TMP" && \
1181 cmp -s "$$TMP.ubase" "$$TMP.utest",\
1182 -fprofile-update=prefer-atomic)
1188 KBUILD_CPPFLAGS += -fmacro-prefix-map=$(srcroot)/=
1189 ifeq ($(call rustc-option-yn, --remap-path-scope=macro),y)
1190 KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/= --remap-path-scope=macro
1195 include-y := scripts/Makefile.warn
1196 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1197 include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf
1198 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1199 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1200 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
1201 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1202 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1203 include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
1204 include-$(CONFIG_KSTACK_ERASE) += scripts/Makefile.kstack_erase
1205 include-$(CONFIG_AUTOFDO_CLANG) += scripts/Makefile.autofdo
1206 include-$(CONFIG_PROPELLER_CLANG) += scripts/Makefile.propeller
1207 include-$(CONFIG_WARN_CONTEXT_ANALYSIS) += scripts/Makefile.context-analysis
1208 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1210 include $(addprefix $(srctree)/, $(include-y))
1212 # scripts/Makefile.gcc-plugins is intentionally included last.
1213 # Do not add $(call cc-option,...) below this line. When you build the kernel
1222 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1223 LDFLAGS_vmlinux += --build-id=sha1
1225 KBUILD_LDFLAGS += -z noexecstack
1227 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1231 LDFLAGS_vmlinux += -X
1235 # ld.lld before 15 did not support -z pack-relative-relocs.
1236 LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
1242 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
1246 LDFLAGS_vmlinux += --emit-relocs --discard-none
1250 USERFLAGS_FROM_KERNEL := --target=%
1257 USERFLAGS_FROM_KERNEL += -m32 -m64
1265 KBUILD_USERLDFLAGS += --ld-path=$(LD)
1269 CHECKFLAGS += --arch=$(ARCH)
1272 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1275 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1279 ifneq ($(shell $(srctree)/scripts/checker-valid.sh $(CHECK) $(CHECKFLAGS)), 1)
1317 build-dir := .
1318 clean-dirs := $(sort . Documentation \
1319 $(patsubst %/,%,$(filter %/, $(core-) \
1320 $(drivers-) $(libs-))))
1322 export ARCH_CORE := $(core-y)
1323 export ARCH_LIB := $(filter %/, $(libs-y))
1324 export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
1325 # Externally visible symbols (used by link-vmlinux.sh)
1327 KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1328 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1340 vmlinux_a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
1341 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_a
1348 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
1367 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
1392 # A multi level approach is used. prepareN is processed before prepareN-1.
1399 asm-generic $(version_h) include/generated/utsrelease.h \
1401 include/generated/rustc_cfg remove-stale-files
1414 PHONY += remove-stale-files
1415 remove-stale-files:
1416 $(Q)$(srctree)/scripts/remove-stale-files
1418 # Support for using generic headers in asm-generic
1419 asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj
1421 PHONY += asm-generic uapi-asm-generic
1422 asm-generic: uapi-asm-generic
1423 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1424 generic=include/asm-generic
1425 uapi-asm-generic:
1426 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1427 generic=include/uapi/asm-generic
1430 # ---------------------------------------------------------------------------
1437 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1445 if [ $(SUBLEVEL) -gt 255 ]; then \
1475 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1476 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1478 # ---------------------------------------------------------------------------
1486 mkdir -p $(INSTALL_HDR_PATH); \
1487 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1496 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1499 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders
1501 $(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
1503 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1504 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1523 # ---------------------------------------------------------------------------
1534 # ---------------------------------------------------------------------------
1538 vdso_install: export INSTALL_FILES = $(vdso-install-y)
1540 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
1542 # ---------------------------------------------------------------------------
1569 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1578 $(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) $(patsubst objtool_%,%,$@)
1582 $(Q)mkdir -p $(objtree)/tools
1583 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1586 $(Q)mkdir -p $(objtree)/tools
1587 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1589 # ---------------------------------------------------------------------------
1594 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1596 kselftest-%: headers FORCE
1597 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1599 PHONY += kselftest-merge
1600 kselftest-merge:
1602 $(Q)find $(srctree)/tools/testing/selftests -name config -o -name config.$(UTS_MACHINE) | \
1603 xargs $(srctree)/scripts/kconfig/merge_config.sh -y -m $(objtree)/.config
1604 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1606 # ---------------------------------------------------------------------------
1629 $(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
1647 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=$(dtstree)
1680 $(Q)$(srctree)/scripts/dtc/dt-style-selftest/run.sh
1682 # ---------------------------------------------------------------------------
1692 # the built-in objects during the descend as well, in order to
1724 CLEAN_FILES += vmlinux.symvers modules-only.symvers \
1727 vmlinux.thinlto-index builtin.order \
1728 compile_commands.json rust/test \
1729 rust-project.json .vmlinux.objs .vmlinux.export.c \
1730 .builtin-dtbs-list .builtin-dtbs.S sbom-*.spdx.json
1735 debian snap tar-install PKGBUILD pacman \
1740 vmlinux-gdb.py \
1746 # clean - Delete most, but leave enough to build external modules
1748 clean: private rm-files := $(CLEAN_FILES)
1753 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1754 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1758 # mrproper - Delete all generated files, including .config
1760 mrproper: private rm-files := $(MRPROPER_FILES)
1761 mrproper-dirs := $(addprefix _mrproper_,scripts)
1763 PHONY += $(mrproper-dirs) mrproper
1764 $(mrproper-dirs):
1767 mrproper: clean objtool_mrproper $(mrproper-dirs)
1770 \( -name '*.rmeta' \) \
1771 -type f -print | xargs rm -f
1779 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1780 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1781 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1782 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1783 -type f -print | xargs rm -f
1787 # ---------------------------------------------------------------------------
1789 modules-cpio-pkg: usr_gen_init_cpio
1791 %src-pkg: FORCE
1792 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1794 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1797 # ---------------------------------------------------------------------------
1801 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1802 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1807 @echo ' clean - Remove most generated files but keep the config and'
1809 @echo ' mrproper - Remove all generated files + config + various backup files'
1810 @echo ' distclean - mrproper + remove editor backup and patch files'
1812 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1815 @echo ' all - Build all targets marked with [*]'
1816 @echo '* vmlinux - Build the bare kernel'
1817 @echo '* modules - Build all modules'
1818 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1819 @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
1820 @echo ' dir/ - Build all files in dir and below'
1821 @echo ' dir/file.[ois] - Build specified target only'
1822 @echo ' dir/file.ll - Build the LLVM assembly file'
1824 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1826 @echo ' dir/file.ko - Build module including final link'
1827 @echo ' modules_prepare - Set up for building external modules'
1828 @echo ' tags/TAGS - Generate tags file for editors'
1829 @echo ' cscope - Generate cscope index'
1830 @echo ' gtags - Generate GNU GLOBAL index'
1831 @echo ' kernelrelease - Output the release version string (use with make -s)'
1832 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1833 @echo ' image_name - Output the image name (use with make -s)'
1834 @echo ' headers - Build ready-to-install UAPI headers in usr/include'
1835 @echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
1839 @echo ' checkstack - Generate a list of stack hogs and consider all functions'
1841 @echo ' versioncheck - Sanity check on version.h usage'
1842 @echo ' includecheck - Check for duplicate included header files'
1843 @echo ' headerdep - Detect inclusion cycles in headers'
1844 @echo ' coccicheck - Check with Coccinelle'
1845 @echo ' kconfig-sym-check - Check for dangling Kconfig symbol references'
1846 @echo ' clang-analyzer - Check with clang static analyzer'
1847 @echo ' clang-tidy - Check with clang-tidy'
1850 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1851 @echo ' sbom - Generate Software Bill of Materials'
1854 @echo ' kselftest - Build and run kernel selftest'
1858 @echo ' kselftest-all - Build kernel selftest'
1859 @echo ' kselftest-install - Build and install kernel selftest'
1860 @echo ' kselftest-clean - Remove all generated kselftest files'
1861 @echo ' kselftest-merge - Merge all the config dependencies of'
1865 @echo ' rustavailable - Checks whether the Rust toolchain is'
1867 @echo ' rustfmt - Reformat all the Rust code in the kernel'
1868 @echo ' rustfmtcheck - Checks if all the Rust code in the kernel'
1870 @echo ' rustdoc - Generate Rust documentation'
1872 @echo ' rusttest - Runs the Rust tests'
1874 @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1876 @echo ' dir/file.[os] - Build specified target only'
1877 @echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
1880 @echo ' dir/file.ll - Build the LLVM assembly file'
1884 echo '* dtbs - Build device tree blobs for enabled boards'; \
1885 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1886 echo ' dt_binding_check - Validate device tree binding documents and examples'; \
1887 echo ' dt_binding_schemas - Build processed device tree binding schemas'; \
1888 echo ' dt_style_selftest - Run dt-check-style fixture tests'; \
1889 echo ' dtbs_check - Validate device tree source files';\
1897 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1900 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1902 @echo 'Architecture-specific targets ($(SRCARCH)):'
1904 echo ' No architecture-specific help defined for $(SRCARCH)')
1908 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1910 @$(if $(board-dirs), \
1911 $(foreach b, $(board-dirs), \
1912 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1913 printf " %-16s - Show all of the above\\n" help-boards; \
1920 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1934 echo ' make CHECK_DTBS=1 [targets] Check all generated dtb files against schema'; \
1942 help-board-dirs := $(addprefix help-,$(board-dirs))
1944 help-boards: $(help-board-dirs)
1946 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1948 $(help-board-dirs): help-%:
1949 @echo 'Architecture-specific targets ($(SRCARCH) $*):'
1950 @$(if $(boards-per-dir), \
1951 $(foreach b, $(boards-per-dir), \
1952 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1957 # ---------------------------------------------------------------------------
1960 htmldocs-redirects
1968 # ---------------------------------------------------------------------------
1977 # Using the singular to avoid running afoul of `no-dot-config-targets`.
1995 -path $(srctree)/rust/proc-macro2 \
1996 -o -path $(srctree)/rust/quote \
1997 -o -path $(srctree)/rust/syn \
1998 -o -path $(srctree)/rust/zerocopy \
1999 -o -path $(srctree)/rust/zerocopy-derive \
2000 \) -prune -o \
2001 -type f -a -name '*.rs' -a ! -name '*generated*' -print \
2004 rustfmtcheck: rustfmt_flags = --check
2008 # ---------------------------------------------------------------------------
2010 PHONY += misc-check
2011 misc-check:
2012 $(Q)$(srctree)/scripts/misc-check
2014 all: misc-check
2019 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
2032 # read-only, and no consistency checks are made and the make
2040 build-dir := .
2042 clean-dirs := .
2043 clean: private rm-files := Module.symvers modules.nsdeps compile_commands.json
2064 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
2066 @echo ' modules - default target, build the module(s)'
2067 @echo ' modules_install - install the module'
2068 @echo ' clean - remove generated files in module directory only'
2069 @echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
2084 # ---------------------------------------------------------------------------
2090 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
2091 sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
2108 modules.order: $(build-dir)
2115 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
2120 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
2132 modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
2134 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
2137 # ---------------------------------------------------------------------------
2142 # The supported suffixes for single-target are listed in 'single-targets'
2148 ifdef single-build
2151 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
2152 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
2153 $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
2155 $(single-ko): single_modules
2157 $(single-no-ko): $(build-dir)
2162 single_modules: $(single-no-ko) modules_prepare
2163 $(Q){ $(foreach m, $(single-ko), echo $(m:%.ko=%.o);) } > modules.order
2164 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
2166 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
2168 $(Q)rm -f modules.order
2170 single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
2182 PHONY += $(build-dir)
2183 $(build-dir): prepare
2184 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
2186 clean-dirs := $(addprefix _clean_, $(clean-dirs))
2187 PHONY += $(clean-dirs) clean
2188 $(clean-dirs):
2191 clean: $(clean-dirs)
2194 \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
2195 -o -name '*.ko.*' -o -name '*.o.thinlto.bc' \
2196 -o -name '*.dtb' -o -name '*.dtbo' \
2197 -o -name '*.dtb.S' -o -name '*.dtbo.S' \
2198 -o -name '*.dt.yaml' -o -name 'dtbs-list' \
2199 -o -name '*.dwo' -o -name '*.lst' \
2200 -o -name '*.su' -o -name '*.mod' \
2201 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2202 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
2203 -o -name '*.asn1.[ch]' \
2204 -o -name '*.symtypes' -o -name 'modules.order' \
2205 -o -name '*.c.[012]*.*' \
2206 -o -name '*.ll' \
2207 -o -name '*.gcno' \
2208 -o -name '*.long-type-*.txt' \
2209 \) -type f -print \
2210 -o -name '.tmp_*' -print \
2211 | xargs rm -rf
2214 # ---------------------------------------------------------------------------
2221 # Generate rust-project.json (a file that describes the structure of non-Cargo
2222 # Rust projects) for rust-analyzer (an implementation of the Language Server
2224 PHONY += rust-analyzer
2225 rust-analyzer:
2228 # FIXME: external modules must not descend into a sub-directory of the kernel
2235 # ---------------------------------------------------------------------------
2242 # Script to generate .spdx.json SBOM documents describing the build
2243 # ---------------------------------------------------------------------------
2246 sbom_targets := sbom-source.spdx.json
2248 sbom_targets += sbom-build.spdx.json sbom-output.spdx.json
2250 cmd_sbom = printf "%s\n" "$(KBUILD_IMAGE)" >"$(tmp-target)"; \
2251 $(if $(CONFIG_MODULES),sed 's/\.o$$/.ko/' $(objtree)/modules.order >> "$(tmp-target)";) \
2253 --src-tree $(abspath $(srctree)) \
2254 --obj-tree $(abspath $(objtree)) \
2255 --roots-file "$(tmp-target)" \
2256 --output-directory $(abspath $(objtree)) \
2257 --generate-spdx \
2258 --package-license "GPL-2.0 WITH Linux-syscall-note" \
2259 --package-version "$(KERNELVERSION)" \
2260 --write-output-on-error;
2266 # ---------------------------------------------------------------------------
2269 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
2271 compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
2276 targets += compile_commands.json
2278 PHONY += clang-tidy clang-analyzer
2282 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
2284 clang-tidy clang-analyzer: compile_commands.json
2287 clang-tidy clang-analyzer:
2293 # ---------------------------------------------------------------------------
2295 PHONY += includecheck versioncheck coccicheck kconfig-sym-check
2299 -name '*.[hcS]' -type f -print | sort \
2300 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2304 -name '*.[hcS]' -type f -print | sort \
2305 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2310 kconfig-sym-check:
2311 $(Q)$(PERL) $(srctree)/scripts/kconfig/kconfig-sym-check.pl $(srctree) $(KCONFIG_SYM_CHECK_EXCLUDES)
2317 # else wants $(ARCH), including people doing cross-builds, which means
2326 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2338 PHONY += run-command
2339 run-command:
2342 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2343 cmd_rmfiles = rm -rf $(rm-files)
2346 existing-targets := $(wildcard $(sort $(targets)))
2348 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2350 endif # config-build
2351 endif # mixed-build
2352 endif # need-sub-make