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

1 # SPDX-License-Identifier: GPL-2.0
12 # expect to learn how to build the kernel reading this file.
14 ifeq ($(filter output-sync,$(.FEATURES)),)
25 # We are using a recursive build, so we need to do a little thinking
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 # ---------------------------------------------------------------------------
63 # Most of build commands in Kbuild start with "cmd_". You can optionally define
71 # A simple variant is to prefix commands with $(Q) - that's useful
72 # for commands that shall be hidden in non-verbose mode.
74 # $(Q)$(MAKE) $(build)=scripts/basic
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,
132 # directory of external module to build. Setting M= takes precedence.
165 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
192 # source directory or kernel build directory), external modules
209 # $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' first.
210 $(shell mkdir -p "$(output)")
226 no-print-directory := --no-print-directory
229 need-sub-make := 1
232 ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),)
233 # If --no-print-directory is unset, recurse once again to set it.
234 # You may end up recursing into __sub-make twice. This is needed due to the
236 need-sub-make := 1
239 ifeq ($(need-sub-make),1)
241 PHONY += $(MAKECMDGOALS) __sub-make
243 $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
247 __sub-make:
248 $(Q)$(MAKE) $(no-print-directory) -C $(abs_output) \
249 -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
251 else # need-sub-make
286 # mixing *config targets and build targets.
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
336 # We cannot build single targets and the others at the same time
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
360 # We're called with mixed targets (*config and build targets).
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
461 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
462 -O2 -fomit-frame-pointer -std=gnu11
468 export rust_common_flags := --edition=2021 \
469 -Zbinary_dep_depinfo=y \
470 -Astable_features \
471 -Dnon_ascii_idents \
472 -Dunsafe_op_in_unsafe_fn \
473 -Wmissing_docs \
474 -Wrust_2018_idioms \
475 -Wunreachable_pub \
476 -Wclippy::all \
477 -Wclippy::ignored_unit_patterns \
478 -Wclippy::mut_mut \
479 -Wclippy::needless_bitwise_bool \
480 -Aclippy::needless_lifetimes \
481 -Wclippy::no_mangle_with_rust_abi \
482 -Wclippy::undocumented_unsafe_blocks \
483 -Wclippy::unnecessary_safety_comment \
484 -Wclippy::unnecessary_safety_doc \
485 -Wrustdoc::missing_crate_level_docs \
486 -Wrustdoc::unescaped_backticks
489 $(HOSTCFLAGS) -I $(srctree)/scripts/include
490 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \
491 -I $(srctree)/scripts/include
492 KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
493 -Zallow-features= $(HOSTRUSTFLAGS)
499 CPP = $(CC) -E
503 AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
504 NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
505 OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
506 OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
507 READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
508 STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
522 CLIPPY_DRIVER = clippy-driver
542 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
543 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
556 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
557 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
558 -I$(srctree)/include/uapi \
559 -I$(objtree)/include/generated/uapi \
560 -include $(srctree)/include/linux/compiler-version.h \
561 -include $(srctree)/include/linux/kconfig.h
566 -I$(srctree)/arch/$(SRCARCH)/include \
567 -I$(objtree)/arch/$(SRCARCH)/include/generated \
568 -I$(srctree)/include \
569 -I$(objtree)/include \
572 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
575 KBUILD_CFLAGS += -std=gnu11
576 KBUILD_CFLAGS += -fshort-wchar
577 KBUILD_CFLAGS += -funsigned-char
578 KBUILD_CFLAGS += -fno-common
579 KBUILD_CFLAGS += -fno-PIE
580 KBUILD_CFLAGS += -fno-strict-aliasing
582 KBUILD_CPPFLAGS := -D__KERNEL__
584 -Cpanic=abort -Cembed-bitcode=n -Clto=n \
585 -Cforce-unwind-tables=n -Ccodegen-units=1 \
586 -Csymbol-mangling-version=v0 \
587 -Crelocation-model=static \
588 -Zfunction-sections=n \
589 -Wclippy::float_arithmetic
594 KBUILD_AFLAGS_MODULE := -DMODULE
595 KBUILD_CFLAGS_MODULE := -DMODULE
596 KBUILD_RUSTFLAGS_MODULE := --cfg MODULE
612 # Allows finding `.clippy.toml` in out-of-srctree builds.
633 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
634 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
635 -prune -o
638 # Rules shared between *config targets and build targets
643 $(Q)$(MAKE) $(build)=scripts/basic
647 # Before starting out-of-tree build, make sure the source tree is clean.
673 @if [ -f $(srctree)/.config -o \
674 -d $(srctree)/include/config -o \
675 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
683 @if [ -f $(srcroot)/modules.order ]; then \
686 echo >&2 "*** Please run 'make -C $(abs_srctree) M=$(realpath $(srcroot)) clean'"; \
691 $(Q)ln -fsn $(srcroot) source
693 $(Q)test -e .gitignore || \
694 { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
702 CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
703 RUSTC_VERSION_TEXT = $(subst $(pound),,$(shell $(RUSTC) --version 2>/dev/null))
710 # cc-cross-prefix to determine CROSS_COMPILE.
711 ifdef need-compiler
715 ifdef config-build
717 # *config targets only - make sure prerequisites are updated, and descend
720 # Read arch-specific Makefile to set KBUILD_DEFCONFIG as needed.
727 $(Q)$(MAKE) $(build)=scripts/kconfig $@
730 $(Q)$(MAKE) $(build)=scripts/kconfig $@
732 else #!config-build
734 # Build targets only - this includes vmlinux, arch-specific targets, clean
748 # Decide whether to build built-in, modular, or both.
749 # Normally, just do built-in.
754 # If we have only "make modules", don't compile built-in objects.
761 # Just "make" or "make all" shall build modules as well
763 ifneq ($(filter all modules nsdeps compile_commands.json clang-%,$(MAKECMDGOALS)),)
773 ifdef need-config
779 core-y :=
780 drivers-y :=
781 libs-y := lib/
786 # This allow a user to issue only 'make' to build a kernel including modules
790 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
792 CFLAGS_GCOV += -fno-tree-loop-im
798 CC_FLAGS_FTRACE := -pg
803 ifdef need-config
804 ifdef may-sync-config
819 # The actual configuration files used during the build are stored in
823 # This exploits the 'multi-target pattern rule' trick.
831 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
832 else # !may-sync-config
834 # and include/config/auto.conf but do not care if they are up-to-date.
837 checked-configs := $(addprefix $(objtree)/, include/generated/autoconf.h include/generated/rustc_cf…
838 missing-configs := $(filter-out $(wildcard $(checked-configs)), $(checked-configs))
840 ifdef missing-configs
846 @printf >&2 '*** - %s\n' $(missing-configs)
852 endif # may-sync-config
853 endif # need-config
855 KBUILD_CFLAGS += -fno-delete-null-pointer-checks
858 KBUILD_CFLAGS += -O2
859 KBUILD_RUSTFLAGS += -Copt-level=2
861 KBUILD_CFLAGS += -Os
862 KBUILD_RUSTFLAGS += -Copt-level=s
865 # Always set `debug-assertions` and `overflow-checks` because their default
866 # depends on `opt-level` and `debug-assertions`, respectively.
867 KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
868 KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
870 # Tell gcc to never replace conditional load with a non-conditional one
872 # gcc-10 renamed --param=allow-store-data-races=0 to
873 # -fno-allow-store-data-races.
874 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
875 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
883 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
886 stackp-flags-y := -fno-stack-protector
887 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
888 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
890 KBUILD_CFLAGS += $(stackp-flags-y)
892 KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
893 KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y)
896 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
897 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
901 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
902 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
903 # -fomit-frame-pointer with FUNCTION_TRACER.
904 # In the Rust target specification, "frame-pointer" is set explicitly
905 # to "may-omit".
907 KBUILD_CFLAGS += -fomit-frame-pointer
913 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
918 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
920 # https://github.com/llvm/llvm-project/issues/44842
921 CC_AUTO_VAR_INIT_ZERO_ENABLER := -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from
928 KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
932 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
936 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
941 CC_FLAGS_FTRACE += -mrecord-mcount
943 ifeq ($(call cc-option-yn, -mnop-mcount),y)
944 CC_FLAGS_FTRACE += -mnop-mcount
945 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
951 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
961 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
962 ifeq ($(call cc-option-yn, -mfentry),y)
963 CC_FLAGS_FTRACE += -mfentry
964 CC_FLAGS_USING += -DCC_USING_FENTRY
974 KBUILD_CFLAGS += -fno-inline-functions-called-once
977 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
979 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
980 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
981 LDFLAGS_vmlinux += --gc-sections
986 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
988 KBUILD_RUSTFLAGS += -Zsanitizer=shadow-call-stack
995 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
997 CC_FLAGS_LTO := -flto
999 CC_FLAGS_LTO += -fvisibility=hidden
1002 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
1006 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
1007 KBUILD_AFLAGS += -fno-lto
1012 CC_FLAGS_CFI := -fsanitize=kcfi
1014 CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
1017 CC_FLAGS_CFI += -fsanitize-kcfi-arity
1020 # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
1022 RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
1030 # Architectures can define flags to add/remove for floating-point support
1031 CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT
1037 # -fmin-function-alignment if it is available, or fall back to -falign-funtions.
1040 KBUILD_CFLAGS += -fmin-function-alignment=$(CONFIG_FUNCTION_ALIGNMENT)
1042 KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
1047 NOSTDINC_FLAGS += -nostdinc
1053 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
1056 KBUILD_CFLAGS += -fno-strict-overflow
1058 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1059 KBUILD_CFLAGS += -fno-stack-check
1063 KBUILD_CFLAGS += -fconserve-stack
1067 KBUILD_CFLAGS += -fno-builtin-wcslen
1071 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
1075 include-y := scripts/Makefile.extrawarn
1076 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1077 include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf
1078 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1079 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1080 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
1081 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1082 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1083 include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
1084 include-$(CONFIG_AUTOFDO_CLANG) += scripts/Makefile.autofdo
1085 include-$(CONFIG_PROPELLER_CLANG) += scripts/Makefile.propeller
1086 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1088 include $(addprefix $(srctree)/, $(include-y))
1090 # scripts/Makefile.gcc-plugins is intentionally included last.
1091 # Do not add $(call cc-option,...) below this line. When you build the kernel
1100 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1101 LDFLAGS_vmlinux += --build-id=sha1
1103 KBUILD_LDFLAGS += -z noexecstack
1105 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1109 LDFLAGS_vmlinux += -X
1113 # ld.lld before 15 did not support -z pack-relative-relocs.
1114 LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
1120 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
1124 LDFLAGS_vmlinux += --emit-relocs --discard-none
1128 KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
1129 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
1133 KBUILD_USERLDFLAGS += --ld-path=$(LD)
1137 CHECKFLAGS += --arch=$(ARCH)
1140 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1143 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1145 # Default kernel image to build when no specific target is given.
1158 # INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots.
1166 # relocations required by build roots. This is not defined in the
1177 build-dir := .
1178 clean-dirs := $(sort . Documentation \
1179 $(patsubst %/,%,$(filter %/, $(core-) \
1180 $(drivers-) $(libs-))))
1182 export ARCH_CORE := $(core-y)
1183 export ARCH_LIB := $(filter %/, $(libs-y))
1184 export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
1185 # Externally visible symbols (used by link-vmlinux.sh)
1187 KBUILD_VMLINUX_OBJS := ./built-in.a
1189 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1190 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1192 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
1200 # we have to build modules as well to determine what those symbols are.
1204 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
1207 rm -f $@; \
1209 …$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object
1212 vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
1217 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
1236 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
1253 # Carefully list dependencies so we do not try to build scripts twice
1257 $(Q)$(MAKE) $(build)=$(@)
1261 # A multi level approach is used. prepareN is processed before prepareN-1.
1268 asm-generic $(version_h) include/generated/utsrelease.h \
1270 include/generated/rustc_cfg remove-stale-files
1273 $(Q)$(MAKE) $(build)=scripts/mod
1274 $(Q)$(MAKE) $(build)=. prepare
1280 $(Q)$(MAKE) $(build)=rust
1283 PHONY += remove-stale-files
1284 remove-stale-files:
1285 $(Q)$(srctree)/scripts/remove-stale-files
1287 # Support for using generic headers in asm-generic
1288 asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj
1290 PHONY += asm-generic uapi-asm-generic
1291 asm-generic: uapi-asm-generic
1292 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1293 generic=include/asm-generic
1294 uapi-asm-generic:
1295 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1296 generic=include/uapi/asm-generic
1299 # ---------------------------------------------------------------------------
1306 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1314 if [ $(SUBLEVEL) -gt 255 ]; then \
1344 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1345 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1347 # ---------------------------------------------------------------------------
1355 mkdir -p $(INSTALL_HDR_PATH); \
1356 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1365 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1368 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1370 $(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
1372 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1373 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1382 $(Q)$(MAKE) $(build)=scripts scripts/unifdef
1386 $(Q)$(MAKE) $(build)=scripts scripts/gen_packed_field_checks
1388 # ---------------------------------------------------------------------------
1393 # to this Makefile to build and install external modules.
1399 # ---------------------------------------------------------------------------
1403 vdso_install: export INSTALL_FILES = $(vdso-install-y)
1405 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
1407 # ---------------------------------------------------------------------------
1420 # The tools build system is not a part of Kbuild and tends to introduce
1434 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1438 $(Q)mkdir -p $(objtree)/tools
1439 $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1442 $(Q)mkdir -p $(objtree)/tools
1443 $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1445 # ---------------------------------------------------------------------------
1450 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1452 kselftest-%: headers FORCE
1453 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1455 PHONY += kselftest-merge
1456 kselftest-merge:
1458 $(Q)find $(srctree)/tools/testing/selftests -name config -o -name config.$(UTS_MACHINE) | \
1459 xargs $(srctree)/scripts/kconfig/merge_config.sh -y -m $(objtree)/.config
1460 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1462 # ---------------------------------------------------------------------------
1472 $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
1475 $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
1479 $(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
1497 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=$(dtstree)
1511 $(Q)$(MAKE) $(build)=scripts/dtc
1519 $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings $@
1522 $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
1526 $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings $@
1528 # ---------------------------------------------------------------------------
1533 # By default, build modules as well
1538 # the built-in objects during the descend as well, in order to
1544 # Build modules
1558 $(Q)$(MAKE) $(build)=scripts scripts/module.lds
1565 # Leave enough to build external modules
1570 CLEAN_FILES += vmlinux.symvers modules-only.symvers \
1574 rust-project.json .vmlinux.objs .vmlinux.export.c \
1575 .builtin-dtbs-list .builtin-dtb.S
1580 debian snap tar-install PKGBUILD pacman \
1585 vmlinux-gdb.py \
1589 # clean - Delete most, but leave enough to build external modules
1591 clean: private rm-files := $(CLEAN_FILES)
1596 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1597 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1601 # mrproper - Delete all generated files, including .config
1603 mrproper: private rm-files := $(MRPROPER_FILES)
1604 mrproper-dirs := $(addprefix _mrproper_,scripts)
1606 PHONY += $(mrproper-dirs) mrproper
1607 $(mrproper-dirs):
1610 mrproper: clean $(mrproper-dirs)
1613 \( -name '*.rmeta' \) \
1614 -type f -print | xargs rm -f
1622 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1623 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1624 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1625 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1626 -type f -print | xargs rm -f
1630 # ---------------------------------------------------------------------------
1632 %src-pkg: FORCE
1633 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1635 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1638 # ---------------------------------------------------------------------------
1642 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1643 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1648 @echo ' clean - Remove most generated files but keep the config and'
1649 @echo ' enough build support to build external modules'
1650 @echo ' mrproper - Remove all generated files + config + various backup files'
1651 @echo ' distclean - mrproper + remove editor backup and patch files'
1653 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1656 @echo ' all - Build all targets marked with [*]'
1657 @echo '* vmlinux - Build the bare kernel'
1658 @echo '* modules - Build all modules'
1659 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1660 @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
1661 @echo ' dir/ - Build all files in dir and below'
1662 @echo ' dir/file.[ois] - Build specified target only'
1663 @echo ' dir/file.ll - Build the LLVM assembly file'
1665 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1666 @echo ' (requires a recent binutils and recent build (System.map))'
1667 @echo ' dir/file.ko - Build module including final link'
1668 @echo ' modules_prepare - Set up for building external modules'
1669 @echo ' tags/TAGS - Generate tags file for editors'
1670 @echo ' cscope - Generate cscope index'
1671 @echo ' gtags - Generate GNU GLOBAL index'
1672 @echo ' kernelrelease - Output the release version string (use with make -s)'
1673 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1674 @echo ' image_name - Output the image name (use with make -s)'
1675 @echo ' headers - Build ready-to-install UAPI headers in usr/include'
1676 @echo ' headers_install - Install sanitised kernel UAPI headers to INSTALL_HDR_PATH'; \
1680 @echo ' checkstack - Generate a list of stack hogs and consider all functions'
1682 @echo ' versioncheck - Sanity check on version.h usage'
1683 @echo ' includecheck - Check for duplicate included header files'
1684 @echo ' headerdep - Detect inclusion cycles in headers'
1685 @echo ' coccicheck - Check with Coccinelle'
1686 @echo ' clang-analyzer - Check with clang static analyzer'
1687 @echo ' clang-tidy - Check with clang-tidy'
1690 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1693 @echo ' kselftest - Build and run kernel selftest'
1694 @echo ' Build, install, and boot kernel before'
1697 @echo ' kselftest-all - Build kernel selftest'
1698 @echo ' kselftest-install - Build and install kernel selftest'
1699 @echo ' kselftest-clean - Remove all generated kselftest files'
1700 @echo ' kselftest-merge - Merge all the config dependencies of'
1704 @echo ' rustavailable - Checks whether the Rust toolchain is'
1706 @echo ' rustfmt - Reformat all the Rust code in the kernel'
1707 @echo ' rustfmtcheck - Checks if all the Rust code in the kernel'
1709 @echo ' rustdoc - Generate Rust documentation'
1711 @echo ' rusttest - Runs the Rust tests'
1713 @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1715 @echo ' dir/file.[os] - Build specified target only'
1716 @echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
1719 @echo ' dir/file.ll - Build the LLVM assembly file'
1723 echo '* dtbs - Build device tree blobs for enabled boards'; \
1724 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1725 echo ' dt_binding_check - Validate device tree binding documents and examples'; \
1726 echo ' dt_binding_schemas - Build processed device tree binding schemas'; \
1727 echo ' dtbs_check - Validate device tree source files';\
1735 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1738 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1740 @echo 'Architecture-specific targets ($(SRCARCH)):'
1742 echo ' No architecture-specific help defined for $(SRCARCH)')
1746 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1748 @$(if $(board-dirs), \
1749 $(foreach b, $(board-dirs), \
1750 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1751 printf " %-16s - Show all of the above\\n" help-boards; \
1754 @echo ' make V=n [targets] 1: verbose build'
1758 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1762 @echo ' make W=n [targets] Enable extra build checks, n=1,2,3,c,e where'
1774 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
1778 help-board-dirs := $(addprefix help-,$(board-dirs))
1780 help-boards: $(help-board-dirs)
1782 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1784 $(help-board-dirs): help-%:
1785 @echo 'Architecture-specific targets ($(SRCARCH) $*):'
1786 @$(if $(boards-per-dir), \
1787 $(foreach b, $(boards-per-dir), \
1788 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1793 # ---------------------------------------------------------------------------
1798 $(Q)$(MAKE) $(build)=Documentation $@
1802 # ---------------------------------------------------------------------------
1811 # Using the singular to avoid running afoul of `no-dot-config-targets`.
1814 $(Q)$(MAKE) $(build)=rust $@
1816 # Testing target
1819 $(Q)$(MAKE) $(build)=rust $@
1826 -type f -a -name '*.rs' -a ! -name '*generated*' -print \
1829 rustfmtcheck: rustfmt_flags = --check
1833 # ---------------------------------------------------------------------------
1835 PHONY += misc-check
1836 misc-check:
1837 $(Q)$(srctree)/scripts/misc-check
1839 all: misc-check
1843 $(Q)$(MAKE) $(build)=scripts/gdb
1844 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1857 # read-only, and no consistency checks are made and the make
1865 build-dir := .
1867 clean-dirs := .
1868 clean: private rm-files := Module.symvers modules.nsdeps compile_commands.json
1875 echo >&2 "warning: the compiler differs from the one used to build the kernel"; \
1883 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1885 @echo ' modules - default target, build the module(s)'
1886 @echo ' modules_install - install the module'
1887 @echo ' clean - remove generated files in module directory only'
1888 @echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
1896 @echo >&2 '*** You cannot build or install external modules.'
1903 # ---------------------------------------------------------------------------
1909 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
1910 sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
1927 modules.order: $(build-dir)
1934 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1939 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1951 modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
1953 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1956 # ---------------------------------------------------------------------------
1957 # To build individual files in subdirectories, you can do like this:
1961 # The supported suffixes for single-target are listed in 'single-targets'
1963 # To build only under specific subdirectories, you can do like this:
1967 ifdef single-build
1970 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1971 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
1972 $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
1974 $(single-ko): single_modules
1976 $(single-no-ko): $(build-dir)
1981 single_modules: $(single-no-ko) modules_prepare
1982 $(Q){ $(foreach m, $(single-ko), echo $(m:%.ko=%.o);) } > modules.order
1983 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1985 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1987 $(Q)rm -f modules.order
1989 single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
1997 # Preset locale variables to speed up the build process. Limit locale
2001 PHONY += $(build-dir)
2002 $(build-dir): prepare
2003 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
2005 clean-dirs := $(addprefix _clean_, $(clean-dirs))
2006 PHONY += $(clean-dirs) clean
2007 $(clean-dirs):
2010 clean: $(clean-dirs)
2013 \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
2014 -o -name '*.ko.*' \
2015 -o -name '*.dtb' -o -name '*.dtbo' \
2016 -o -name '*.dtb.S' -o -name '*.dtbo.S' \
2017 -o -name '*.dt.yaml' -o -name 'dtbs-list' \
2018 -o -name '*.dwo' -o -name '*.lst' \
2019 -o -name '*.su' -o -name '*.mod' \
2020 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2021 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
2022 -o -name '*.asn1.[ch]' \
2023 -o -name '*.symtypes' -o -name 'modules.order' \
2024 -o -name '*.c.[012]*.*' \
2025 -o -name '*.ll' \
2026 -o -name '*.gcno' \
2027 \) -type f -print \
2028 -o -name '.tmp_*' -print \
2029 | xargs rm -rf
2032 # ---------------------------------------------------------------------------
2039 # Generate rust-project.json (a file that describes the structure of non-Cargo
2040 # Rust projects) for rust-analyzer (an implementation of the Language Server
2042 PHONY += rust-analyzer
2043 rust-analyzer:
2046 # FIXME: external modules must not descend into a sub-directory of the kernel
2047 $(Q)$(MAKE) $(build)=$(objtree)/rust src=$(srctree)/rust $@
2049 $(Q)$(MAKE) $(build)=rust $@
2053 # ---------------------------------------------------------------------------
2061 # ---------------------------------------------------------------------------
2064 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
2066 compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
2073 PHONY += clang-tidy clang-analyzer
2077 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
2079 clang-tidy clang-analyzer: compile_commands.json
2082 clang-tidy clang-analyzer:
2088 # ---------------------------------------------------------------------------
2094 -name '*.[hcS]' -type f -print | sort \
2095 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2099 -name '*.[hcS]' -type f -print | sort \
2100 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2109 # else wants $(ARCH), including people doing cross-builds, which means
2118 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2130 PHONY += run-command
2131 run-command:
2134 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2135 cmd_rmfiles = rm -rf $(rm-files)
2138 existing-targets := $(wildcard $(sort $(targets)))
2140 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2142 endif # config-build
2143 endif # mixed-build
2144 endif # need-sub-make