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

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) \
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
834 ifdef need-config
835 ifdef may-sync-config
854 # This exploits the 'multi-target pattern rule' trick.
862 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
863 else # !may-sync-config
865 # and include/config/auto.conf but do not care if they are up-to-date.
868 checked-configs := $(addprefix $(objtree)/, include/generated/autoconf.h include/generated/rustc_cf…
869 missing-configs := $(filter-out $(wildcard $(checked-configs)), $(checked-configs))
871 ifdef missing-configs
877 @printf >&2 '*** - %s\n' $(missing-configs)
883 endif # may-sync-config
884 endif # need-config
886 KBUILD_CFLAGS += -fno-delete-null-pointer-checks
889 KBUILD_CFLAGS += -O2
890 KBUILD_RUSTFLAGS += -Copt-level=2
892 KBUILD_CFLAGS += -Os
893 KBUILD_RUSTFLAGS += -Copt-level=s
896 # Always set `debug-assertions` and `overflow-checks` because their default
897 # depends on `opt-level` and `debug-assertions`, respectively.
898 KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
899 KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
901 # Tell gcc to never replace conditional load with a non-conditional one
903 # gcc-10 renamed --param=allow-store-data-races=0 to
904 # -fno-allow-store-data-races.
905 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
906 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
914 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
917 stackp-flags-y := -fno-stack-protector
918 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
919 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
921 KBUILD_CFLAGS += $(stackp-flags-y)
924 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
925 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
929 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
930 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
931 # -fomit-frame-pointer with FUNCTION_TRACER.
932 # In the Rust target specification, "frame-pointer" is set explicitly
933 # to "may-omit".
935 KBUILD_CFLAGS += -fomit-frame-pointer
941 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
946 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
948 # https://github.com/llvm/llvm-project/issues/44842
949 CC_AUTO_VAR_INIT_ZERO_ENABLER := -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from
956 KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
960 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
963 KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-context=2)
967 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
972 CC_FLAGS_FTRACE += -mrecord-mcount
974 ifeq ($(call cc-option-yn, -mnop-mcount),y)
975 CC_FLAGS_FTRACE += -mnop-mcount
976 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
982 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
992 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
993 ifeq ($(call cc-option-yn, -mfentry),y)
994 CC_FLAGS_FTRACE += -mfentry
995 CC_FLAGS_USING += -DCC_USING_FENTRY
1005 KBUILD_CFLAGS += -fno-inline-functions-called-once
1008 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
1010 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
1011 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
1012 LDFLAGS_vmlinux += --gc-sections
1017 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
1019 KBUILD_RUSTFLAGS += -Zsanitizer=shadow-call-stack
1026 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
1028 CC_FLAGS_LTO := -flto
1030 CC_FLAGS_LTO += -fvisibility=hidden
1033 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
1037 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
1038 KBUILD_AFLAGS += -fno-lto
1043 CC_FLAGS_CFI := -fsanitize=kcfi
1045 CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
1048 CC_FLAGS_CFI += -fsanitize-kcfi-arity
1051 # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
1053 RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
1061 # Architectures can define flags to add/remove for floating-point support
1062 CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT
1068 # -fmin-function-alignment if it is available, or fall back to -falign-funtions.
1071 KBUILD_CFLAGS += -fmin-function-alignment=$(CONFIG_FUNCTION_ALIGNMENT)
1073 KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
1078 NOSTDINC_FLAGS += -nostdinc
1084 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
1087 KBUILD_CFLAGS += -fms-extensions
1090 KBUILD_CFLAGS += -fno-strict-overflow
1092 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1093 KBUILD_CFLAGS += -fno-stack-check
1097 KBUILD_CFLAGS += -fconserve-stack
1101 KBUILD_CFLAGS += -fno-builtin-wcslen
1105 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
1109 include-y := scripts/Makefile.warn
1110 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1111 include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf
1112 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1113 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1114 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
1115 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1116 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1117 include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
1118 include-$(CONFIG_KSTACK_ERASE) += scripts/Makefile.kstack_erase
1119 include-$(CONFIG_AUTOFDO_CLANG) += scripts/Makefile.autofdo
1120 include-$(CONFIG_PROPELLER_CLANG) += scripts/Makefile.propeller
1121 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1123 include $(addprefix $(srctree)/, $(include-y))
1125 # scripts/Makefile.gcc-plugins is intentionally included last.
1126 # Do not add $(call cc-option,...) below this line. When you build the kernel
1135 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1136 LDFLAGS_vmlinux += --build-id=sha1
1138 KBUILD_LDFLAGS += -z noexecstack
1140 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1144 LDFLAGS_vmlinux += -X
1148 # ld.lld before 15 did not support -z pack-relative-relocs.
1149 LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
1155 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
1159 LDFLAGS_vmlinux += --emit-relocs --discard-none
1163 USERFLAGS_FROM_KERNEL := --target=%
1170 USERFLAGS_FROM_KERNEL += -m32 -m64
1178 KBUILD_USERLDFLAGS += --ld-path=$(LD)
1182 CHECKFLAGS += --arch=$(ARCH)
1185 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1188 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1222 build-dir := .
1223 clean-dirs := $(sort . Documentation \
1224 $(patsubst %/,%,$(filter %/, $(core-) \
1225 $(drivers-) $(libs-))))
1227 export ARCH_CORE := $(core-y)
1228 export ARCH_LIB := $(filter %/, $(libs-y))
1229 export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
1230 # Externally visible symbols (used by link-vmlinux.sh)
1232 KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1233 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1244 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
1247 rm -f $@; \
1249 …$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object
1252 vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
1257 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
1276 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
1301 # A multi level approach is used. prepareN is processed before prepareN-1.
1308 asm-generic $(version_h) include/generated/utsrelease.h \
1310 include/generated/rustc_cfg remove-stale-files
1323 PHONY += remove-stale-files
1324 remove-stale-files:
1325 $(Q)$(srctree)/scripts/remove-stale-files
1327 # Support for using generic headers in asm-generic
1328 asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj
1330 PHONY += asm-generic uapi-asm-generic
1331 asm-generic: uapi-asm-generic
1332 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1333 generic=include/asm-generic
1334 uapi-asm-generic:
1335 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1336 generic=include/uapi/asm-generic
1339 # ---------------------------------------------------------------------------
1346 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1354 if [ $(SUBLEVEL) -gt 255 ]; then \
1384 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1385 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1387 # ---------------------------------------------------------------------------
1395 mkdir -p $(INSTALL_HDR_PATH); \
1396 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1405 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1408 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders
1410 $(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
1412 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1413 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1428 # ---------------------------------------------------------------------------
1439 # ---------------------------------------------------------------------------
1443 vdso_install: export INSTALL_FILES = $(vdso-install-y)
1445 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
1447 # ---------------------------------------------------------------------------
1474 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1478 $(Q)mkdir -p $(objtree)/tools
1479 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1482 $(Q)mkdir -p $(objtree)/tools
1483 $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1485 # ---------------------------------------------------------------------------
1490 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1492 kselftest-%: headers FORCE
1493 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1495 PHONY += kselftest-merge
1496 kselftest-merge:
1498 $(Q)find $(srctree)/tools/testing/selftests -name config -o -name config.$(UTS_MACHINE) | \
1499 xargs $(srctree)/scripts/kconfig/merge_config.sh -y -m $(objtree)/.config
1500 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1502 # ---------------------------------------------------------------------------
1519 $(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
1537 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=$(dtstree)
1568 # ---------------------------------------------------------------------------
1578 # the built-in objects during the descend as well, in order to
1610 CLEAN_FILES += vmlinux.symvers modules-only.symvers \
1614 rust-project.json .vmlinux.objs .vmlinux.export.c \
1615 .builtin-dtbs-list .builtin-dtb.S
1620 debian snap tar-install PKGBUILD pacman \
1625 vmlinux-gdb.py \
1629 # clean - Delete most, but leave enough to build external modules
1631 clean: private rm-files := $(CLEAN_FILES)
1636 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1637 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1641 # mrproper - Delete all generated files, including .config
1643 mrproper: private rm-files := $(MRPROPER_FILES)
1644 mrproper-dirs := $(addprefix _mrproper_,scripts)
1646 PHONY += $(mrproper-dirs) mrproper
1647 $(mrproper-dirs):
1650 mrproper: clean $(mrproper-dirs)
1653 \( -name '*.rmeta' \) \
1654 -type f -print | xargs rm -f
1662 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1663 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1664 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1665 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1666 -type f -print | xargs rm -f
1670 # ---------------------------------------------------------------------------
1672 %src-pkg: FORCE
1673 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1675 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1678 # ---------------------------------------------------------------------------
1682 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1683 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1688 @echo ' clean - Remove most generated files but keep the config and'
1690 @echo ' mrproper - Remove all generated files + config + various backup files'
1691 @echo ' distclean - mrproper + remove editor backup and patch files'
1693 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1696 @echo ' all - Build all targets marked with [*]'
1697 @echo '* vmlinux - Build the bare kernel'
1698 @echo '* modules - Build all modules'
1699 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1700 @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
1701 @echo ' dir/ - Build all files in dir and below'
1702 @echo ' dir/file.[ois] - Build specified target only'
1703 @echo ' dir/file.ll - Build the LLVM assembly file'
1705 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1707 @echo ' dir/file.ko - Build module including final link'
1708 @echo ' modules_prepare - Set up for building external modules'
1709 @echo ' tags/TAGS - Generate tags file for editors'
1710 @echo ' cscope - Generate cscope index'
1711 @echo ' gtags - Generate GNU GLOBAL index'
1712 @echo ' kernelrelease - Output the release version string (use with make -s)'
1713 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1714 @echo ' image_name - Output the image name (use with make -s)'
1715 @echo ' headers - Build ready-to-install UAPI headers in usr/include'
1716 @echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
1720 @echo ' checkstack - Generate a list of stack hogs and consider all functions'
1722 @echo ' versioncheck - Sanity check on version.h usage'
1723 @echo ' includecheck - Check for duplicate included header files'
1724 @echo ' headerdep - Detect inclusion cycles in headers'
1725 @echo ' coccicheck - Check with Coccinelle'
1726 @echo ' clang-analyzer - Check with clang static analyzer'
1727 @echo ' clang-tidy - Check with clang-tidy'
1730 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1733 @echo ' kselftest - Build and run kernel selftest'
1737 @echo ' kselftest-all - Build kernel selftest'
1738 @echo ' kselftest-install - Build and install kernel selftest'
1739 @echo ' kselftest-clean - Remove all generated kselftest files'
1740 @echo ' kselftest-merge - Merge all the config dependencies of'
1744 @echo ' rustavailable - Checks whether the Rust toolchain is'
1746 @echo ' rustfmt - Reformat all the Rust code in the kernel'
1747 @echo ' rustfmtcheck - Checks if all the Rust code in the kernel'
1749 @echo ' rustdoc - Generate Rust documentation'
1751 @echo ' rusttest - Runs the Rust tests'
1753 @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1755 @echo ' dir/file.[os] - Build specified target only'
1756 @echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
1759 @echo ' dir/file.ll - Build the LLVM assembly file'
1763 echo '* dtbs - Build device tree blobs for enabled boards'; \
1764 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1765 echo ' dt_binding_check - Validate device tree binding documents and examples'; \
1766 echo ' dt_binding_schemas - Build processed device tree binding schemas'; \
1767 echo ' dtbs_check - Validate device tree source files';\
1775 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1778 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1780 @echo 'Architecture-specific targets ($(SRCARCH)):'
1782 echo ' No architecture-specific help defined for $(SRCARCH)')
1786 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1788 @$(if $(board-dirs), \
1789 $(foreach b, $(board-dirs), \
1790 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1791 printf " %-16s - Show all of the above\\n" help-boards; \
1798 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1820 help-board-dirs := $(addprefix help-,$(board-dirs))
1822 help-boards: $(help-board-dirs)
1824 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1826 $(help-board-dirs): help-%:
1827 @echo 'Architecture-specific targets ($(SRCARCH) $*):'
1828 @$(if $(boards-per-dir), \
1829 $(foreach b, $(boards-per-dir), \
1830 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1835 # ---------------------------------------------------------------------------
1838 htmldocs-redirects
1846 # ---------------------------------------------------------------------------
1855 # Using the singular to avoid running afoul of `no-dot-config-targets`.
1860 # Testing target
1873 -path $(srctree)/rust/proc-macro2 \
1874 -o -path $(srctree)/rust/quote \
1875 -o -path $(srctree)/rust/syn \
1876 \) -prune -o \
1877 -type f -a -name '*.rs' -a ! -name '*generated*' -print \
1880 rustfmtcheck: rustfmt_flags = --check
1884 # ---------------------------------------------------------------------------
1886 PHONY += misc-check
1887 misc-check:
1888 $(Q)$(srctree)/scripts/misc-check
1890 all: misc-check
1895 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1908 # read-only, and no consistency checks are made and the make
1916 build-dir := .
1918 clean-dirs := .
1919 clean: private rm-files := Module.symvers modules.nsdeps compile_commands.json
1934 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1936 @echo ' modules - default target, build the module(s)'
1937 @echo ' modules_install - install the module'
1938 @echo ' clean - remove generated files in module directory only'
1939 @echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
1954 # ---------------------------------------------------------------------------
1960 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
1961 sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
1978 modules.order: $(build-dir)
1985 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1990 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
2002 modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
2004 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
2007 # ---------------------------------------------------------------------------
2012 # The supported suffixes for single-target are listed in 'single-targets'
2018 ifdef single-build
2021 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
2022 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
2023 $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
2025 $(single-ko): single_modules
2027 $(single-no-ko): $(build-dir)
2032 single_modules: $(single-no-ko) modules_prepare
2033 $(Q){ $(foreach m, $(single-ko), echo $(m:%.ko=%.o);) } > modules.order
2034 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
2036 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
2038 $(Q)rm -f modules.order
2040 single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
2052 PHONY += $(build-dir)
2053 $(build-dir): prepare
2054 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
2056 clean-dirs := $(addprefix _clean_, $(clean-dirs))
2057 PHONY += $(clean-dirs) clean
2058 $(clean-dirs):
2061 clean: $(clean-dirs)
2064 \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
2065 -o -name '*.ko.*' \
2066 -o -name '*.dtb' -o -name '*.dtbo' \
2067 -o -name '*.dtb.S' -o -name '*.dtbo.S' \
2068 -o -name '*.dt.yaml' -o -name 'dtbs-list' \
2069 -o -name '*.dwo' -o -name '*.lst' \
2070 -o -name '*.su' -o -name '*.mod' \
2071 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2072 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
2073 -o -name '*.asn1.[ch]' \
2074 -o -name '*.symtypes' -o -name 'modules.order' \
2075 -o -name '*.c.[012]*.*' \
2076 -o -name '*.ll' \
2077 -o -name '*.gcno' \
2078 \) -type f -print \
2079 -o -name '.tmp_*' -print \
2080 | xargs rm -rf
2083 # ---------------------------------------------------------------------------
2090 # Generate rust-project.json (a file that describes the structure of non-Cargo
2091 # Rust projects) for rust-analyzer (an implementation of the Language Server
2093 PHONY += rust-analyzer
2094 rust-analyzer:
2097 # FIXME: external modules must not descend into a sub-directory of the kernel
2104 # ---------------------------------------------------------------------------
2112 # ---------------------------------------------------------------------------
2115 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
2117 compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
2124 PHONY += clang-tidy clang-analyzer
2128 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
2130 clang-tidy clang-analyzer: compile_commands.json
2133 clang-tidy clang-analyzer:
2139 # ---------------------------------------------------------------------------
2145 -name '*.[hcS]' -type f -print | sort \
2146 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2150 -name '*.[hcS]' -type f -print | sort \
2151 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2160 # else wants $(ARCH), including people doing cross-builds, which means
2169 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2181 PHONY += run-command
2182 run-command:
2185 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2186 cmd_rmfiles = rm -rf $(rm-files)
2189 existing-targets := $(wildcard $(sort $(targets)))
2191 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2193 endif # config-build
2194 endif # mixed-build
2195 endif # need-sub-make