Lines Matching +full:sub +full:- +full:modules

1 # SPDX-License-Identifier: GPL-2.0
24 # Most importantly: sub-Makefiles should only ever modify files in
27 # unavoidable when linking the built-in.a targets which finally
28 # turn into vmlinux), we will call a sub make in that other dir, and
39 # Do not use make's built-in rules and variables
40 # (this increases performance and avoids hard-to-debug behaviour)
41 MAKEFLAGS += -rR
53 # ---------------------------------------------------------------------------
60 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
67 # A simple variant is to prefix commands with $(Q) - that's useful
68 # for commands that shall be hidden in non-verbose mode.
94 # If the user is running make -s (silent mode), suppress echoing of
97 ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
107 # Use 'make C=1' to enable checking of only re-compiled files.
109 # of whether they are re-compiled or not.
111 # See the file "Documentation/dev-tools/sparse.rst" for more details,
139 $(error building multiple external modules is not supported))
156 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
177 # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
179 abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
191 MAKEFLAGS += --no-print-directory
193 need-sub-make := 1
196 this-makefile := $(lastword $(MAKEFILE_LIST))
197 abs_srctree := $(realpath $(dir $(this-makefile)))
206 # --included-dir is added for backward compatibility, but you should not rely on
208 MAKEFLAGS += --include-dir=$(abs_srctree)
212 # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
213 # We need to invoke sub-make to avoid implicit rules in the top Makefile.
214 need-sub-make := 1
216 $(this-makefile): ;
222 ifeq ($(need-sub-make),1)
224 PHONY += $(MAKECMDGOALS) __sub-make
226 $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
230 __sub-make:
231 $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
233 endif # need-sub-make
237 ifeq ($(need-sub-make),)
242 MAKEFLAGS += --no-print-directory
277 clean-targets := %clean mrproper cleandocs
278 no-dot-config-targets := $(clean-targets) \
281 %asm-generic kernelversion %src-pkg dt_binding_check \
285 no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
287 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
289 single-targets := %.a %.i %.rsi %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
291 config-build :=
292 mixed-build :=
293 need-config := 1
294 need-compiler := 1
295 may-sync-config := 1
296 single-build :=
298 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
299 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
300 need-config :=
304 ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
305 ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
306 need-compiler :=
310 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
311 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
312 may-sync-config :=
317 may-sync-config :=
322 config-build := 1
324 mixed-build := 1
330 ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
331 single-build := 1
332 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
333 mixed-build := 1
337 # For "make -j clean all", "make -j mrproper defconfig all", etc.
338 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
339 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
340 mixed-build := 1
347 mixed-build := 1
351 ifdef mixed-build
362 $(Q)set -e; \
364 $(MAKE) -f $(srctree)/Makefile $$i; \
367 else # !mixed-build
378 # Cross compiling and selecting different set of gcc/bin-utils
379 # ---------------------------------------------------------------------------
389 # during compilation. Only gcc and related bin-utils executables
392 # make CROSS_COMPILE=ia64-linux-
441 else ifneq ($(filter -%,$(LLVM)),)
452 HOSTPKG_CONFIG = pkg-config
454 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
455 -O2 -fomit-frame-pointer -std=gnu11 \
456 -Wdeclaration-after-statement
462 export rust_common_flags := --edition=2021 \
463 -Zbinary_dep_depinfo=y \
464 -Dunsafe_op_in_unsafe_fn -Drust_2018_idioms \
465 -Dunreachable_pub -Dnon_ascii_idents \
466 -Wmissing_docs \
467 -Drustdoc::missing_crate_level_docs \
468 -Dclippy::correctness -Dclippy::style \
469 -Dclippy::suspicious -Dclippy::complexity \
470 -Dclippy::perf \
471 -Dclippy::let_unit_value -Dclippy::mut_mut \
472 -Dclippy::needless_bitwise_bool \
473 -Dclippy::needless_continue \
474 -Wclippy::dbg_macro
477 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
478 KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
479 -Zallow-features= $(HOSTRUSTFLAGS)
484 CPP = $(CC) -E
488 AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
489 NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
490 OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
491 OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
492 READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
493 STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
507 CLIPPY_DRIVER = clippy-driver
529 PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh)
531 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
532 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
545 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
546 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
547 -I$(srctree)/include/uapi \
548 -I$(objtree)/include/generated/uapi \
549 -include $(srctree)/include/linux/compiler-version.h \
550 -include $(srctree)/include/linux/kconfig.h
555 -I$(srctree)/arch/$(SRCARCH)/include \
556 -I$(objtree)/arch/$(SRCARCH)/include/generated \
557 $(if $(building_out_of_srctree),-I$(srctree)/include) \
558 -I$(objtree)/include \
561 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
562 KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
563 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
564 -Werror=implicit-function-declaration -Werror=implicit-int \
565 -Werror=return-type -Wno-format-security \
566 -std=gnu11
567 KBUILD_CPPFLAGS := -D__KERNEL__
569 --target=$(objtree)/rust/target.json \
570 -Cpanic=abort -Cembed-bitcode=n -Clto=n \
571 -Cforce-unwind-tables=n -Ccodegen-units=1 \
572 -Csymbol-mangling-version=v0 \
573 -Crelocation-model=static \
574 -Zfunction-sections=n \
575 -Dclippy::float_arithmetic
580 KBUILD_AFLAGS_MODULE := -DMODULE
581 KBUILD_CFLAGS_MODULE := -DMODULE
582 KBUILD_RUSTFLAGS_MODULE := --cfg MODULE
621 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
622 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
623 -prune -o
624 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
625 --exclude CVS --exclude .pc --exclude .hg --exclude .git
637 # Before starting out-of-tree build, make sure the source tree is clean.
651 @if [ -f $(srctree)/.config -o \
652 -d $(srctree)/include/config -o \
653 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
660 $(Q)ln -fsn $(srctree) source
662 $(Q)test -e .gitignore || \
670 CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
677 # cc-cross-prefix to determine CROSS_COMPILE.
678 ifdef need-compiler
682 ifdef config-build
684 # *config targets only - make sure prerequisites are updated, and descend
699 else #!config-build
701 # Build targets only - this includes vmlinux, arch specific targets, clean
705 # but instead __all depend on modules
710 __all: modules
715 # Decide whether to build built-in, modular, or both.
716 # Normally, just do built-in.
721 # If we have only "make modules", don't compile built-in objects.
722 ifeq ($(MAKECMDGOALS),modules)
726 # If we have "make <whatever> modules", compile modules
728 # Just "make" or "make all" shall build modules as well
730 ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
740 ifdef need-config
746 core-y :=
747 drivers-y :=
748 libs-y := lib/
753 # This allow a user to issue only 'make' to build a kernel including modules
757 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
759 CFLAGS_GCOV += -fno-tree-loop-im
765 CC_FLAGS_FTRACE := -pg
770 ifdef need-config
771 ifdef may-sync-config
790 # This exploits the 'multi-target pattern rule' trick.
798 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
799 else # !may-sync-config
800 # External modules and some install targets need include/generated/autoconf.h
801 # and include/config/auto.conf but do not care if they are up-to-date.
806 @test -e include/generated/autoconf.h -a -e $@ || ( \
814 endif # may-sync-config
815 endif # need-config
817 KBUILD_CFLAGS += -fno-delete-null-pointer-checks
818 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
819 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
820 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
821 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
824 KBUILD_CFLAGS += -O2
825 KBUILD_RUSTFLAGS += -Copt-level=2
827 KBUILD_CFLAGS += -Os
828 KBUILD_RUSTFLAGS += -Copt-level=s
831 # Always set `debug-assertions` and `overflow-checks` because their default
832 # depends on `opt-level` and `debug-assertions`, respectively.
833 KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
834 KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
836 # Tell gcc to never replace conditional load with a non-conditional one
838 # gcc-10 renamed --param=allow-store-data-races=0 to
839 # -fno-allow-store-data-races.
840 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
841 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
849 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
853 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
856 stackp-flags-y := -fno-stack-protector
857 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
858 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
860 KBUILD_CFLAGS += $(stackp-flags-y)
862 KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
863 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
865 KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
866 KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y)
869 KBUILD_CPPFLAGS += -Qunused-arguments
870 # The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
871 KBUILD_CFLAGS += -Wno-gnu
875 KBUILD_CFLAGS += -Wno-main
880 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
881 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
884 KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
887 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
888 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
892 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
893 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
894 # -fomit-frame-pointer with FUNCTION_TRACER.
895 # In the Rust target specification, "frame-pointer" is set explicitly
896 # to "may-omit".
898 KBUILD_CFLAGS += -fomit-frame-pointer
904 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
909 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
911 # https://github.com/llvm/llvm-project/issues/44842
912 KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
918 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
922 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
927 CC_FLAGS_FTRACE += -mrecord-mcount
929 ifeq ($(call cc-option-yn, -mnop-mcount),y)
930 CC_FLAGS_FTRACE += -mnop-mcount
931 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
936 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
945 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
946 ifeq ($(call cc-option-yn, -mfentry),y)
947 CC_FLAGS_FTRACE += -mfentry
948 CC_FLAGS_USING += -DCC_USING_FENTRY
958 KBUILD_CFLAGS += -fno-inline-functions-called-once
961 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
963 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
964 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
965 LDFLAGS_vmlinux += --gc-sections
969 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
976 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
977 KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod_prefix).thinlto-cache
979 CC_FLAGS_LTO := -flto
981 CC_FLAGS_LTO += -fvisibility=hidden
984 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
989 ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
990 KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
996 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
997 KBUILD_AFLAGS += -fno-lto
1002 CC_FLAGS_CFI := -fsanitize=kcfi
1008 KBUILD_CFLAGS += -falign-functions=64
1012 NOSTDINC_FLAGS += -nostdinc
1015 KBUILD_CFLAGS += -Wdeclaration-after-statement
1018 KBUILD_CFLAGS += -Wvla
1021 KBUILD_CFLAGS += -Wno-pointer-sign
1025 # globally built with -Wcast-function-type.
1026 KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
1029 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
1032 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
1035 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
1039 KBUILD_CFLAGS += -Wno-maybe-uninitialized
1044 # -Wno-alloc-size-larger-than would normally be used here, earlier versions
1046 # warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX
1053 KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
1054 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
1057 KBUILD_CFLAGS += -fno-strict-overflow
1059 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1060 KBUILD_CFLAGS += -fno-stack-check
1064 KBUILD_CFLAGS += -fconserve-stack
1067 # Prohibit date/time macros, which would make the build non-deterministic
1068 KBUILD_CFLAGS += -Werror=date-time
1071 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
1074 KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
1077 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
1080 include-y := scripts/Makefile.extrawarn
1081 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1082 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1083 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1084 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
1085 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1086 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1087 include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
1088 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1090 include $(addprefix $(srctree)/, $(include-y))
1092 # scripts/Makefile.gcc-plugins is intentionally included last.
1093 # Do not add $(call cc-option,...) below this line. When you build the kernel
1102 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1103 LDFLAGS_vmlinux += --build-id=sha1
1105 KBUILD_LDFLAGS += -z noexecstack
1107 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1111 LDFLAGS_vmlinux += -X
1115 LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
1121 LDFLAGS_vmlinux += --orphan-handling=warn
1125 KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1126 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1129 CHECKFLAGS += --arch=$(ARCH)
1132 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1135 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1162 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
1168 export MODORDER := $(extmod_prefix)modules.order
1169 export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
1173 build-dir := .
1174 clean-dirs := $(sort . Documentation \
1175 $(patsubst %/,%,$(filter %/, $(core-) \
1176 $(drivers-) $(libs-))))
1178 export ARCH_CORE := $(core-y)
1179 export ARCH_LIB := $(filter %/, $(libs-y))
1180 export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
1181 # Externally visible symbols (used by link-vmlinux.sh)
1183 KBUILD_VMLINUX_OBJS := ./built-in.a
1185 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1186 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1188 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
1198 # we have to build modules as well to determine what those symbols are.
1202 autoksyms_recursive: $(build-dir) modules.order
1204 "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
1210 cmd_autoksyms_h = mkdir -p $(dir $@); \
1216 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
1219 rm -f $@; \
1221 …$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object
1224 vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE
1229 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
1231 vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o
1236 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
1257 # or the modules are listed in "prepare".
1258 # A multi level approach is used. prepareN is processed before prepareN-1.
1265 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
1266 include/generated/compile.h include/generated/autoconf.h remove-stale-files
1275 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh -v
1279 PHONY += remove-stale-files
1280 remove-stale-files:
1281 $(Q)$(srctree)/scripts/remove-stale-files
1283 # Support for using generic headers in asm-generic
1284 asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
1286 PHONY += asm-generic uapi-asm-generic
1287 asm-generic: uapi-asm-generic
1288 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1289 generic=include/asm-generic
1290 uapi-asm-generic:
1291 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1292 generic=include/uapi/asm-generic
1295 # ---------------------------------------------------------------------------
1302 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1310 if [ $(SUBLEVEL) -gt 255 ]; then \
1340 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1341 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1343 # ---------------------------------------------------------------------------
1351 mkdir -p $(INSTALL_HDR_PATH); \
1352 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1361 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1364 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1366 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1367 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1377 # ---------------------------------------------------------------------------
1382 # to this Makefile to build and install external modules.
1388 # ---------------------------------------------------------------------------
1409 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1418 $(Q)mkdir -p $(objtree)/tools
1419 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
1422 $(Q)mkdir -p $(objtree)/tools
1423 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
1425 # ---------------------------------------------------------------------------
1430 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1432 kselftest-%: headers FORCE
1433 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1435 PHONY += kselftest-merge
1436 kselftest-merge:
1438 $(Q)find $(srctree)/tools/testing/selftests -name config | \
1439 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1440 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1442 # ---------------------------------------------------------------------------
1498 # ---------------------------------------------------------------------------
1499 # Modules
1503 # By default, build modules as well
1505 all: modules
1507 # When we're building modules with modversions, we need to consider
1508 # the built-in objects during the descend as well, in order to
1514 # Build modules
1520 modules: vmlinux target
1523 modules: modules_prepare target
1525 # Target to prepare building external modules
1551 @rm -rf $(MODLIB)/kernel
1552 @rm -f $(MODLIB)/source
1553 @mkdir -p $(MODLIB)/kernel
1554 @ln -s $(abspath $(srctree)) $(MODLIB)/source
1555 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
1556 rm -f $(MODLIB)/build ; \
1557 ln -s $(CURDIR) $(MODLIB)/build ; \
1559 @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
1560 @cp -f modules.builtin $(MODLIB)/
1561 @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
1568 # Leave enough to build external modules
1573 CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
1574 modules.builtin modules.builtin.modinfo modules.nsdeps \
1575 compile_commands.json .thinlto-cache rust/test rust/doc \
1581 debian snap tar-install \
1586 vmlinux-gdb.py \
1590 # clean - Delete most, but leave enough to build external modules
1592 clean: rm-files := $(CLEAN_FILES)
1597 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1598 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1602 # mrproper - Delete all generated files, including .config
1604 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1605 mrproper-dirs := $(addprefix _mrproper_,scripts)
1607 PHONY += $(mrproper-dirs) mrproper
1608 $(mrproper-dirs):
1611 mrproper: clean $(mrproper-dirs)
1614 \( -name '*.rmeta' \) \
1615 -type f -print | xargs rm -f
1623 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1624 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1625 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1626 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1627 -type f -print | xargs rm -f
1631 # ---------------------------------------------------------------------------
1633 %src-pkg: FORCE
1634 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1636 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1639 # ---------------------------------------------------------------------------
1643 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1644 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1649 @echo ' clean - Remove most generated files but keep the config and'
1650 @echo ' enough build support to build external modules'
1651 @echo ' mrproper - Remove all generated files + config + various backup files'
1652 @echo ' distclean - mrproper + remove editor backup and patch files'
1655 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1658 @echo ' all - Build all targets marked with [*]'
1659 @echo '* vmlinux - Build the bare kernel'
1660 @echo '* modules - Build all modules'
1661 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1662 @echo ' dir/ - Build all files in dir and below'
1663 @echo ' dir/file.[ois] - Build specified target only'
1664 @echo ' dir/file.ll - Build the LLVM assembly file'
1666 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1668 @echo ' dir/file.ko - Build module including final link'
1669 @echo ' modules_prepare - Set up for building external modules'
1670 @echo ' tags/TAGS - Generate tags file for editors'
1671 @echo ' cscope - Generate cscope index'
1672 @echo ' gtags - Generate GNU GLOBAL index'
1673 @echo ' kernelrelease - Output the release version string (use with make -s)'
1674 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1675 @echo ' image_name - Output the image name (use with make -s)'
1676 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1680 @echo ' checkstack - Generate a list of stack hogs'
1681 @echo ' versioncheck - Sanity check on version.h usage'
1682 @echo ' includecheck - Check for duplicate included header files'
1683 @echo ' export_report - List the usages of all exported symbols'
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'
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'; \
1726 echo ' dtbs_check - Validate device tree source files';\
1734 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1737 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1745 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1747 @$(if $(board-dirs), \
1748 $(foreach b, $(board-dirs), \
1749 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1750 printf " %-16s - Show all of the above\\n" help-boards; \
1756 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1771 help-board-dirs := $(addprefix help-,$(board-dirs))
1773 help-boards: $(help-board-dirs)
1775 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1777 $(help-board-dirs): help-%:
1779 @$(if $(boards-per-dir), \
1780 $(foreach b, $(boards-per-dir), \
1781 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1786 # ---------------------------------------------------------------------------
1795 # ---------------------------------------------------------------------------
1800 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh -v && echo "Rust is available!"
1804 # Using the singular to avoid running afoul of `no-dot-config-targets`.
1823 $(Q)find $(abs_srctree) -type f -name '*.rs' \
1824 -o -path $(abs_srctree)/rust/alloc -prune \
1825 -o -path $(abs_objtree)/rust/test -prune \
1826 | grep -Fv $(abs_srctree)/rust/alloc \
1827 | grep -Fv $(abs_objtree)/rust/test \
1828 | grep -Fv generated \
1831 rustfmtcheck: rustfmt_flags = --check
1835 PHONY += rust-analyzer
1836 rust-analyzer:
1840 # ---------------------------------------------------------------------------
1845 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1855 # When building external modules the kernel used as basis is considered
1856 # read-only, and no consistency checks are made and the make
1860 # We are always building only modules.
1864 build-dir := $(KBUILD_EXTMOD)
1869 clean-dirs := $(KBUILD_EXTMOD)
1870 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
1871 $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
1885 @echo ' Building external modules.'
1886 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1888 @echo ' modules - default target, build the module(s)'
1889 @echo ' modules_install - install the module'
1890 @echo ' clean - remove generated files in module directory only'
1895 # ---------------------------------------------------------------------------
1896 # Modules
1898 PHONY += modules modules_install modules_prepare
1902 $(MODORDER): $(build-dir)
1905 # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
1907 modules: modpost target
1909 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1914 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1921 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1926 # Modules not configured
1927 # ---------------------------------------------------------------------------
1929 modules modules_install: target
1931 @echo >&2 '*** The present kernel configuration has modules disabled.'
1942 modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
1944 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1947 # ---------------------------------------------------------------------------
1952 # The supported suffixes for single-target are listed in 'single-targets'
1958 ifdef single-build
1961 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1962 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
1963 $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
1965 $(single-ko): single_modules
1967 $(single-no-ko): $(build-dir)
1972 single_modules: $(single-no-ko) modules_prepare
1973 $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER)
1974 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1976 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1978 $(Q)rm -f $(MODORDER)
1980 single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
1990 PHONY += $(build-dir)
1991 $(build-dir): prepare
1992 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
1994 clean-dirs := $(addprefix _clean_, $(clean-dirs))
1995 PHONY += $(clean-dirs) clean
1996 $(clean-dirs):
1999 clean: $(clean-dirs)
2002 \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
2003 -o -name '*.ko.*' \
2004 -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
2005 -o -name '*.dwo' -o -name '*.lst' \
2006 -o -name '*.su' -o -name '*.mod' -o -name '*.usyms' \
2007 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2008 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
2009 -o -name '*.asn1.[ch]' \
2010 -o -name '*.symtypes' -o -name 'modules.order' \
2011 -o -name '.tmp_*' \
2012 -o -name '*.c.[012]*.*' \
2013 -o -name '*.ll' \
2014 -o -name '*.gcno' \
2015 -o -name '*.*.symversions' \) -type f -print | xargs rm -f
2018 # ---------------------------------------------------------------------------
2026 # ---------------------------------------------------------------------------
2030 nsdeps: modules
2034 # ---------------------------------------------------------------------------
2037 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
2039 $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
2046 PHONY += clang-tidy clang-analyzer
2050 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
2052 clang-tidy clang-analyzer: $(extmod_prefix)compile_commands.json
2055 clang-tidy clang-analyzer:
2061 # ---------------------------------------------------------------------------
2067 -name '*.[hcS]' -type f -print | sort \
2068 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2072 -name '*.[hcS]' -type f -print | sort \
2073 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2085 # else wants $(ARCH), including people doing cross-builds, which means
2093 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2105 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2106 cmd_rmfiles = rm -rf $(rm-files)
2109 existing-targets := $(wildcard $(sort $(targets)))
2111 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2113 endif # config-build
2114 endif # mixed-build
2115 endif # need-sub-make