Lines Matching +full:debian +full:- +full:testing +full:- +full:ubsan

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
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) \
297 %asm-generic kernelversion %src-pkg dt_binding_check \
299 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
301 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/
303 config-build :=
304 mixed-build :=
305 need-config := 1
306 may-sync-config := 1
307 single-build :=
309 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
310 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
311 need-config :=
315 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
316 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
317 may-sync-config :=
321 need-compiler := $(may-sync-config)
324 may-sync-config :=
329 config-build := 1
331 mixed-build := 1
337 ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
338 single-build := 1
339 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
340 mixed-build := 1
344 # For "make -j clean all", "make -j mrproper defconfig all", etc.
345 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
346 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
347 mixed-build := 1
354 mixed-build := 1
358 ifdef mixed-build
369 $(Q)set -e; \
371 $(MAKE) -f $(srctree)/Makefile $$i; \
374 else # !mixed-build
379 KERNELRELEASE = $(call read-file, $(objtree)/include/config/kernel.release)
385 # Cross compiling and selecting different set of gcc/bin-utils
386 # ---------------------------------------------------------------------------
396 # during compilation. Only gcc and related bin-utils executables
399 # make CROSS_COMPILE=aarch64-linux-gnu-
448 else ifneq ($(filter -%,$(LLVM)),)
459 HOSTPKG_CONFIG = pkg-config
463 KERNELDOC = $(srctree)/scripts/kernel-doc.py
466 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
467 -O2 -fomit-frame-pointer -std=gnu11
473 export rust_common_flags := --edition=2021 \
474 -Zbinary_dep_depinfo=y \
475 -Astable_features \
476 -Dnon_ascii_idents \
477 -Dunsafe_op_in_unsafe_fn \
478 -Wmissing_docs \
479 -Wrust_2018_idioms \
480 -Wunreachable_pub \
481 -Wclippy::all \
482 -Wclippy::as_ptr_cast_mut \
483 -Wclippy::as_underscore \
484 -Wclippy::cast_lossless \
485 -Wclippy::ignored_unit_patterns \
486 -Wclippy::mut_mut \
487 -Wclippy::needless_bitwise_bool \
488 -Aclippy::needless_lifetimes \
489 -Wclippy::no_mangle_with_rust_abi \
490 -Wclippy::ptr_as_ptr \
491 -Wclippy::ptr_cast_constness \
492 -Wclippy::ref_as_ptr \
493 -Wclippy::undocumented_unsafe_blocks \
494 -Wclippy::unnecessary_safety_comment \
495 -Wclippy::unnecessary_safety_doc \
496 -Wrustdoc::missing_crate_level_docs \
497 -Wrustdoc::unescaped_backticks
500 $(HOSTCFLAGS) -I $(srctree)/scripts/include
501 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \
502 -I $(srctree)/scripts/include
503 KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
504 -Zallow-features= $(HOSTRUSTFLAGS)
510 CPP = $(CC) -E
514 AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
515 NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
516 OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
517 OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
518 READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
519 STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
533 CLIPPY_DRIVER = clippy-driver
554 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
555 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
568 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
569 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
570 -I$(srctree)/include/uapi \
571 -I$(objtree)/include/generated/uapi \
572 -include $(srctree)/include/linux/compiler-version.h \
573 -include $(srctree)/include/linux/kconfig.h
578 -I$(srctree)/arch/$(SRCARCH)/include \
579 -I$(objtree)/arch/$(SRCARCH)/include/generated \
580 -I$(srctree)/include \
581 -I$(objtree)/include \
584 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
587 KBUILD_CFLAGS += -std=gnu11
588 KBUILD_CFLAGS += -fshort-wchar
589 KBUILD_CFLAGS += -funsigned-char
590 KBUILD_CFLAGS += -fno-common
591 KBUILD_CFLAGS += -fno-PIE
592 KBUILD_CFLAGS += -fno-strict-aliasing
594 KBUILD_CPPFLAGS := -D__KERNEL__
596 -Cpanic=abort -Cembed-bitcode=n -Clto=n \
597 -Cforce-unwind-tables=n -Ccodegen-units=1 \
598 -Csymbol-mangling-version=v0 \
599 -Crelocation-model=static \
600 -Zfunction-sections=n \
601 -Wclippy::float_arithmetic
606 KBUILD_AFLAGS_MODULE := -DMODULE
607 KBUILD_CFLAGS_MODULE := -DMODULE
608 KBUILD_RUSTFLAGS_MODULE := --cfg MODULE
624 # Allows finding `.clippy.toml` in out-of-srctree builds.
645 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
646 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
647 -prune -o
659 # Before starting out-of-tree build, make sure the source tree is clean.
685 @if [ -f $(srctree)/.config -o \
686 -d $(srctree)/include/config -o \
687 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
695 @if [ -f $(srcroot)/modules.order ]; then \
698 echo >&2 "*** Please run 'make -C $(abs_srctree) M=$(realpath $(srcroot)) clean'"; \
703 $(Q)ln -fsn $(srcroot) source
705 $(Q)test -e .gitignore || \
714 CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
715 RUSTC_VERSION_TEXT = $(subst $(pound),,$(shell $(RUSTC) --version 2>/dev/null))
722 # cc-cross-prefix to determine CROSS_COMPILE.
723 ifdef need-compiler
727 ifdef config-build
729 # *config targets only - make sure prerequisites are updated, and descend
732 # Read arch-specific Makefile to set KBUILD_DEFCONFIG as needed.
744 else #!config-build
746 # Build targets only - this includes vmlinux, arch-specific targets, clean
760 # Decide whether to build built-in, modular, or both.
761 # Normally, just do built-in.
766 # If we have only "make modules", don't compile built-in objects.
775 ifneq ($(filter all modules nsdeps compile_commands.json clang-%,$(MAKECMDGOALS)),)
785 ifdef need-config
791 core-y :=
792 drivers-y :=
793 libs-y := lib/
802 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
804 CFLAGS_GCOV += -fno-tree-loop-im
810 CC_FLAGS_FTRACE := -pg
815 ifdef need-config
816 ifdef may-sync-config
835 # This exploits the 'multi-target pattern rule' trick.
843 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
844 else # !may-sync-config
846 # and include/config/auto.conf but do not care if they are up-to-date.
849 checked-configs := $(addprefix $(objtree)/, include/generated/autoconf.h include/generated/rustc_cf…
850 missing-configs := $(filter-out $(wildcard $(checked-configs)), $(checked-configs))
852 ifdef missing-configs
858 @printf >&2 '*** - %s\n' $(missing-configs)
864 endif # may-sync-config
865 endif # need-config
867 KBUILD_CFLAGS += -fno-delete-null-pointer-checks
870 KBUILD_CFLAGS += -O2
871 KBUILD_RUSTFLAGS += -Copt-level=2
873 KBUILD_CFLAGS += -Os
874 KBUILD_RUSTFLAGS += -Copt-level=s
877 # Always set `debug-assertions` and `overflow-checks` because their default
878 # depends on `opt-level` and `debug-assertions`, respectively.
879 KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
880 KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
882 # Tell gcc to never replace conditional load with a non-conditional one
884 # gcc-10 renamed --param=allow-store-data-races=0 to
885 # -fno-allow-store-data-races.
886 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
887 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
895 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
898 stackp-flags-y := -fno-stack-protector
899 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
900 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
902 KBUILD_CFLAGS += $(stackp-flags-y)
905 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
906 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
910 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
911 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
912 # -fomit-frame-pointer with FUNCTION_TRACER.
913 # In the Rust target specification, "frame-pointer" is set explicitly
914 # to "may-omit".
916 KBUILD_CFLAGS += -fomit-frame-pointer
922 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
927 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
929 # https://github.com/llvm/llvm-project/issues/44842
930 CC_AUTO_VAR_INIT_ZERO_ENABLER := -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from
937 KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
941 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
945 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
950 CC_FLAGS_FTRACE += -mrecord-mcount
952 ifeq ($(call cc-option-yn, -mnop-mcount),y)
953 CC_FLAGS_FTRACE += -mnop-mcount
954 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
960 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
970 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
971 ifeq ($(call cc-option-yn, -mfentry),y)
972 CC_FLAGS_FTRACE += -mfentry
973 CC_FLAGS_USING += -DCC_USING_FENTRY
983 KBUILD_CFLAGS += -fno-inline-functions-called-once
986 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
988 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
989 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
990 LDFLAGS_vmlinux += --gc-sections
995 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
997 KBUILD_RUSTFLAGS += -Zsanitizer=shadow-call-stack
1004 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
1006 CC_FLAGS_LTO := -flto
1008 CC_FLAGS_LTO += -fvisibility=hidden
1011 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
1015 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
1016 KBUILD_AFLAGS += -fno-lto
1021 CC_FLAGS_CFI := -fsanitize=kcfi
1023 CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
1026 CC_FLAGS_CFI += -fsanitize-kcfi-arity
1029 # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
1031 RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
1039 # Architectures can define flags to add/remove for floating-point support
1040 CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT
1046 # -fmin-function-alignment if it is available, or fall back to -falign-funtions.
1049 KBUILD_CFLAGS += -fmin-function-alignment=$(CONFIG_FUNCTION_ALIGNMENT)
1051 KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
1056 NOSTDINC_FLAGS += -nostdinc
1062 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
1065 KBUILD_CFLAGS += -fno-strict-overflow
1067 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1068 KBUILD_CFLAGS += -fno-stack-check
1072 KBUILD_CFLAGS += -fconserve-stack
1076 KBUILD_CFLAGS += -fno-builtin-wcslen
1080 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
1084 include-y := scripts/Makefile.extrawarn
1085 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1086 include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf
1087 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1088 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1089 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
1090 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1091 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1092 include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
1093 include-$(CONFIG_KSTACK_ERASE) += scripts/Makefile.kstack_erase
1094 include-$(CONFIG_AUTOFDO_CLANG) += scripts/Makefile.autofdo
1095 include-$(CONFIG_PROPELLER_CLANG) += scripts/Makefile.propeller
1096 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1098 include $(addprefix $(srctree)/, $(include-y))
1100 # scripts/Makefile.gcc-plugins is intentionally included last.
1101 # Do not add $(call cc-option,...) below this line. When you build the kernel
1110 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1111 LDFLAGS_vmlinux += --build-id=sha1
1113 KBUILD_LDFLAGS += -z noexecstack
1115 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1119 LDFLAGS_vmlinux += -X
1123 # ld.lld before 15 did not support -z pack-relative-relocs.
1124 LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
1130 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
1134 LDFLAGS_vmlinux += --emit-relocs --discard-none
1138 USERFLAGS_FROM_KERNEL := -m32 -m64 --target=%
1144 KBUILD_USERLDFLAGS += --ld-path=$(LD)
1148 CHECKFLAGS += --arch=$(ARCH)
1151 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1154 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1188 build-dir := .
1189 clean-dirs := $(sort . Documentation \
1190 $(patsubst %/,%,$(filter %/, $(core-) \
1191 $(drivers-) $(libs-))))
1193 export ARCH_CORE := $(core-y)
1194 export ARCH_LIB := $(filter %/, $(libs-y))
1195 export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
1196 # Externally visible symbols (used by link-vmlinux.sh)
1198 KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1199 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1210 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
1213 rm -f $@; \
1215 …$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object
1218 vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
1223 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
1242 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
1267 # A multi level approach is used. prepareN is processed before prepareN-1.
1274 asm-generic $(version_h) include/generated/utsrelease.h \
1276 include/generated/rustc_cfg remove-stale-files
1289 PHONY += remove-stale-files
1290 remove-stale-files:
1291 $(Q)$(srctree)/scripts/remove-stale-files
1293 # Support for using generic headers in asm-generic
1294 asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj
1296 PHONY += asm-generic uapi-asm-generic
1297 asm-generic: uapi-asm-generic
1298 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1299 generic=include/asm-generic
1300 uapi-asm-generic:
1301 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1302 generic=include/uapi/asm-generic
1305 # ---------------------------------------------------------------------------
1312 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1320 if [ $(SUBLEVEL) -gt 255 ]; then \
1350 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1351 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1353 # ---------------------------------------------------------------------------
1361 mkdir -p $(INSTALL_HDR_PATH); \
1362 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1371 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1374 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders
1376 $(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
1378 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1379 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1394 # ---------------------------------------------------------------------------
1405 # ---------------------------------------------------------------------------
1409 vdso_install: export INSTALL_FILES = $(vdso-install-y)
1411 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
1413 # ---------------------------------------------------------------------------
1440 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1444 $(Q)mkdir -p $(objtree)/tools
1445 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1448 $(Q)mkdir -p $(objtree)/tools
1449 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1451 # ---------------------------------------------------------------------------
1456 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1458 kselftest-%: headers FORCE
1459 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1461 PHONY += kselftest-merge
1462 kselftest-merge:
1464 $(Q)find $(srctree)/tools/testing/selftests -name config -o -name config.$(UTS_MACHINE) | \
1465 xargs $(srctree)/scripts/kconfig/merge_config.sh -y -m $(objtree)/.config
1466 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1468 # ---------------------------------------------------------------------------
1485 $(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
1503 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=$(dtstree)
1534 # ---------------------------------------------------------------------------
1544 # the built-in objects during the descend as well, in order to
1576 CLEAN_FILES += vmlinux.symvers modules-only.symvers \
1580 rust-project.json .vmlinux.objs .vmlinux.export.c \
1581 .builtin-dtbs-list .builtin-dtb.S
1586 debian snap tar-install PKGBUILD pacman \
1591 vmlinux-gdb.py \
1595 # clean - Delete most, but leave enough to build external modules
1597 clean: private rm-files := $(CLEAN_FILES)
1602 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1603 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1607 # mrproper - Delete all generated files, including .config
1609 mrproper: private rm-files := $(MRPROPER_FILES)
1610 mrproper-dirs := $(addprefix _mrproper_,scripts)
1612 PHONY += $(mrproper-dirs) mrproper
1613 $(mrproper-dirs):
1616 mrproper: clean $(mrproper-dirs)
1619 \( -name '*.rmeta' \) \
1620 -type f -print | xargs rm -f
1628 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1629 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1630 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1631 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1632 -type f -print | xargs rm -f
1636 # ---------------------------------------------------------------------------
1638 %src-pkg: FORCE
1639 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1641 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1644 # ---------------------------------------------------------------------------
1648 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1649 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1654 @echo ' clean - Remove most generated files but keep the config and'
1656 @echo ' mrproper - Remove all generated files + config + various backup files'
1657 @echo ' distclean - mrproper + remove editor backup and patch files'
1659 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1662 @echo ' all - Build all targets marked with [*]'
1663 @echo '* vmlinux - Build the bare kernel'
1664 @echo '* modules - Build all modules'
1665 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1666 @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
1667 @echo ' dir/ - Build all files in dir and below'
1668 @echo ' dir/file.[ois] - Build specified target only'
1669 @echo ' dir/file.ll - Build the LLVM assembly file'
1671 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1673 @echo ' dir/file.ko - Build module including final link'
1674 @echo ' modules_prepare - Set up for building external modules'
1675 @echo ' tags/TAGS - Generate tags file for editors'
1676 @echo ' cscope - Generate cscope index'
1677 @echo ' gtags - Generate GNU GLOBAL index'
1678 @echo ' kernelrelease - Output the release version string (use with make -s)'
1679 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1680 @echo ' image_name - Output the image name (use with make -s)'
1681 @echo ' headers - Build ready-to-install UAPI headers in usr/include'
1682 @echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
1686 @echo ' checkstack - Generate a list of stack hogs and consider all functions'
1688 @echo ' versioncheck - Sanity check on version.h usage'
1689 @echo ' includecheck - Check for duplicate included header files'
1690 @echo ' headerdep - Detect inclusion cycles in headers'
1691 @echo ' coccicheck - Check with Coccinelle'
1692 @echo ' clang-analyzer - Check with clang static analyzer'
1693 @echo ' clang-tidy - Check with clang-tidy'
1696 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1699 @echo ' kselftest - Build and run kernel selftest'
1703 @echo ' kselftest-all - Build kernel selftest'
1704 @echo ' kselftest-install - Build and install kernel selftest'
1705 @echo ' kselftest-clean - Remove all generated kselftest files'
1706 @echo ' kselftest-merge - Merge all the config dependencies of'
1710 @echo ' rustavailable - Checks whether the Rust toolchain is'
1712 @echo ' rustfmt - Reformat all the Rust code in the kernel'
1713 @echo ' rustfmtcheck - Checks if all the Rust code in the kernel'
1715 @echo ' rustdoc - Generate Rust documentation'
1717 @echo ' rusttest - Runs the Rust tests'
1719 @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1721 @echo ' dir/file.[os] - Build specified target only'
1722 @echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
1725 @echo ' dir/file.ll - Build the LLVM assembly file'
1729 echo '* dtbs - Build device tree blobs for enabled boards'; \
1730 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1731 echo ' dt_binding_check - Validate device tree binding documents and examples'; \
1732 echo ' dt_binding_schemas - Build processed device tree binding schemas'; \
1733 echo ' dtbs_check - Validate device tree source files';\
1741 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1744 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1746 @echo 'Architecture-specific targets ($(SRCARCH)):'
1748 echo ' No architecture-specific help defined for $(SRCARCH)')
1752 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1754 @$(if $(board-dirs), \
1755 $(foreach b, $(board-dirs), \
1756 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1757 printf " %-16s - Show all of the above\\n" help-boards; \
1764 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1784 help-board-dirs := $(addprefix help-,$(board-dirs))
1786 help-boards: $(help-board-dirs)
1788 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1790 $(help-board-dirs): help-%:
1791 @echo 'Architecture-specific targets ($(SRCARCH) $*):'
1792 @$(if $(boards-per-dir), \
1793 $(foreach b, $(boards-per-dir), \
1794 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1799 # ---------------------------------------------------------------------------
1800 DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs htmldocs-redirects \
1809 # ---------------------------------------------------------------------------
1818 # Using the singular to avoid running afoul of `no-dot-config-targets`.
1823 # Testing target
1833 -type f -a -name '*.rs' -a ! -name '*generated*' -print \
1836 rustfmtcheck: rustfmt_flags = --check
1840 # ---------------------------------------------------------------------------
1842 PHONY += misc-check
1843 misc-check:
1844 $(Q)$(srctree)/scripts/misc-check
1846 all: misc-check
1851 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1864 # read-only, and no consistency checks are made and the make
1872 build-dir := .
1874 clean-dirs := .
1875 clean: private rm-files := Module.symvers modules.nsdeps compile_commands.json
1890 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1892 @echo ' modules - default target, build the module(s)'
1893 @echo ' modules_install - install the module'
1894 @echo ' clean - remove generated files in module directory only'
1895 @echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
1910 # ---------------------------------------------------------------------------
1916 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
1917 sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
1934 modules.order: $(build-dir)
1941 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1946 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1958 modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
1960 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1963 # ---------------------------------------------------------------------------
1968 # The supported suffixes for single-target are listed in 'single-targets'
1974 ifdef single-build
1977 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1978 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
1979 $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
1981 $(single-ko): single_modules
1983 $(single-no-ko): $(build-dir)
1988 single_modules: $(single-no-ko) modules_prepare
1989 $(Q){ $(foreach m, $(single-ko), echo $(m:%.ko=%.o);) } > modules.order
1990 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1992 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1994 $(Q)rm -f modules.order
1996 single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
2008 PHONY += $(build-dir)
2009 $(build-dir): prepare
2010 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
2012 clean-dirs := $(addprefix _clean_, $(clean-dirs))
2013 PHONY += $(clean-dirs) clean
2014 $(clean-dirs):
2017 clean: $(clean-dirs)
2020 \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
2021 -o -name '*.ko.*' \
2022 -o -name '*.dtb' -o -name '*.dtbo' \
2023 -o -name '*.dtb.S' -o -name '*.dtbo.S' \
2024 -o -name '*.dt.yaml' -o -name 'dtbs-list' \
2025 -o -name '*.dwo' -o -name '*.lst' \
2026 -o -name '*.su' -o -name '*.mod' \
2027 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2028 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
2029 -o -name '*.asn1.[ch]' \
2030 -o -name '*.symtypes' -o -name 'modules.order' \
2031 -o -name '*.c.[012]*.*' \
2032 -o -name '*.ll' \
2033 -o -name '*.gcno' \
2034 \) -type f -print \
2035 -o -name '.tmp_*' -print \
2036 | xargs rm -rf
2039 # ---------------------------------------------------------------------------
2046 # Generate rust-project.json (a file that describes the structure of non-Cargo
2047 # Rust projects) for rust-analyzer (an implementation of the Language Server
2049 PHONY += rust-analyzer
2050 rust-analyzer:
2053 # FIXME: external modules must not descend into a sub-directory of the kernel
2060 # ---------------------------------------------------------------------------
2068 # ---------------------------------------------------------------------------
2071 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
2073 compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
2080 PHONY += clang-tidy clang-analyzer
2084 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
2086 clang-tidy clang-analyzer: compile_commands.json
2089 clang-tidy clang-analyzer:
2095 # ---------------------------------------------------------------------------
2101 -name '*.[hcS]' -type f -print | sort \
2102 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2106 -name '*.[hcS]' -type f -print | sort \
2107 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2116 # else wants $(ARCH), including people doing cross-builds, which means
2125 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2137 PHONY += run-command
2138 run-command:
2141 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2142 cmd_rmfiles = rm -rf $(rm-files)
2145 existing-targets := $(wildcard $(sort $(targets)))
2147 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2149 endif # config-build
2150 endif # mixed-build
2151 endif # need-sub-make