Lines Matching +full:sub +full:- +full:modules
1 # SPDX-License-Identifier: GPL-2.0
28 # Most importantly: sub-Makefiles should only ever modify files in
31 # unavoidable when linking the built-in.a targets which finally
32 # turn into vmlinux), we will call a sub make in that other dir, and
41 this-makefile := $(lastword $(MAKEFILE_LIST))
42 export 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 # make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
99 short-opts := $(firstword -$(MAKEFLAGS))
101 short-opts := $(filter-out --%,$(MAKEFLAGS))
104 ifneq ($(findstring s,$(short-opts)),)
114 # Use 'make C=1' to enable checking of only re-compiled files.
116 # of whether they are re-compiled or not.
118 # See the file "Documentation/dev-tools/sparse.rst" for more details,
146 $(error building multiple external modules is not supported))
163 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
184 # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
186 abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
199 # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
200 # We need to invoke sub-make to avoid implicit rules in the top Makefile.
201 need-sub-make := 1
203 $(this-makefile): ;
212 no-print-directory := --no-print-directory
215 need-sub-make := 1
218 ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),)
219 # If --no-print-directory is unset, recurse once again to set it.
220 # You may end up recursing into __sub-make twice. This is needed due to the
222 need-sub-make := 1
225 ifeq ($(need-sub-make),1)
227 PHONY += $(MAKECMDGOALS) __sub-make
229 $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
233 __sub-make:
234 $(Q)$(MAKE) $(no-print-directory) -C $(abs_objtree) \
235 -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
237 else # need-sub-make
274 clean-targets := %clean mrproper cleandocs
275 no-dot-config-targets := $(clean-targets) \
278 %asm-generic kernelversion %src-pkg dt_binding_check \
282 no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
284 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
286 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/
288 config-build :=
289 mixed-build :=
290 need-config := 1
291 need-compiler := 1
292 may-sync-config := 1
293 single-build :=
295 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
296 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
297 need-config :=
301 ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
302 ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
303 need-compiler :=
307 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
308 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
309 may-sync-config :=
314 may-sync-config :=
319 config-build := 1
321 mixed-build := 1
327 ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
328 single-build := 1
329 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
330 mixed-build := 1
334 # For "make -j clean all", "make -j mrproper defconfig all", etc.
335 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
336 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
337 mixed-build := 1
344 mixed-build := 1
348 ifdef mixed-build
359 $(Q)set -e; \
361 $(MAKE) -f $(srctree)/Makefile $$i; \
364 else # !mixed-build
369 KERNELRELEASE = $(call read-file, include/config/kernel.release)
375 # Cross compiling and selecting different set of gcc/bin-utils
376 # ---------------------------------------------------------------------------
386 # during compilation. Only gcc and related bin-utils executables
389 # make CROSS_COMPILE=ia64-linux-
438 else ifneq ($(filter -%,$(LLVM)),)
449 HOSTPKG_CONFIG = pkg-config
451 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
452 -O2 -fomit-frame-pointer -std=gnu11
458 export rust_common_flags := --edition=2021 \
459 -Zbinary_dep_depinfo=y \
460 -Dunsafe_op_in_unsafe_fn -Drust_2018_idioms \
461 -Dunreachable_pub -Dnon_ascii_idents \
462 -Wmissing_docs \
463 -Drustdoc::missing_crate_level_docs \
464 -Dclippy::correctness -Dclippy::style \
465 -Dclippy::suspicious -Dclippy::complexity \
466 -Dclippy::perf \
467 -Dclippy::let_unit_value -Dclippy::mut_mut \
468 -Dclippy::needless_bitwise_bool \
469 -Dclippy::needless_continue \
470 -Dclippy::no_mangle_with_rust_abi \
471 -Wclippy::dbg_macro
474 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
475 KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
476 -Zallow-features= $(HOSTRUSTFLAGS)
481 CPP = $(CC) -E
485 AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
486 NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
487 OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
488 OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
489 READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
490 STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
504 CLIPPY_DRIVER = clippy-driver
525 PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh)
527 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
528 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
541 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
542 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
543 -I$(srctree)/include/uapi \
544 -I$(objtree)/include/generated/uapi \
545 -include $(srctree)/include/linux/compiler-version.h \
546 -include $(srctree)/include/linux/kconfig.h
551 -I$(srctree)/arch/$(SRCARCH)/include \
552 -I$(objtree)/arch/$(SRCARCH)/include/generated \
553 $(if $(building_out_of_srctree),-I$(srctree)/include) \
554 -I$(objtree)/include \
557 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
560 KBUILD_CFLAGS += -std=gnu11
561 KBUILD_CFLAGS += -fshort-wchar
562 KBUILD_CFLAGS += -funsigned-char
563 KBUILD_CFLAGS += -fno-common
564 KBUILD_CFLAGS += -fno-PIE
565 KBUILD_CFLAGS += -fno-strict-aliasing
567 KBUILD_CPPFLAGS := -D__KERNEL__
569 --target=$(objtree)/scripts/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
820 KBUILD_CFLAGS += -O2
821 KBUILD_RUSTFLAGS += -Copt-level=2
823 KBUILD_CFLAGS += -Os
824 KBUILD_RUSTFLAGS += -Copt-level=s
827 # Always set `debug-assertions` and `overflow-checks` because their default
828 # depends on `opt-level` and `debug-assertions`, respectively.
829 KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
830 KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
832 # Tell gcc to never replace conditional load with a non-conditional one
834 # gcc-10 renamed --param=allow-store-data-races=0 to
835 # -fno-allow-store-data-races.
836 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
837 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
845 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
848 stackp-flags-y := -fno-stack-protector
849 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
850 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
852 KBUILD_CFLAGS += $(stackp-flags-y)
854 KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
855 KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y)
858 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
859 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
863 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
864 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
865 # -fomit-frame-pointer with FUNCTION_TRACER.
866 # In the Rust target specification, "frame-pointer" is set explicitly
867 # to "may-omit".
869 KBUILD_CFLAGS += -fomit-frame-pointer
875 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
880 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
882 # https://github.com/llvm/llvm-project/issues/44842
883 CC_AUTO_VAR_INIT_ZERO_ENABLER := -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
891 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
895 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
900 CC_FLAGS_FTRACE += -mrecord-mcount
902 ifeq ($(call cc-option-yn, -mnop-mcount),y)
903 CC_FLAGS_FTRACE += -mnop-mcount
904 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
910 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
920 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
921 ifeq ($(call cc-option-yn, -mfentry),y)
922 CC_FLAGS_FTRACE += -mfentry
923 CC_FLAGS_USING += -DCC_USING_FENTRY
933 KBUILD_CFLAGS += -fno-inline-functions-called-once
936 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
938 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
939 KBUILD_RUSTFLAGS_KERNEL += -Zfunction-sections=y
940 LDFLAGS_vmlinux += --gc-sections
945 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
953 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
955 CC_FLAGS_LTO := -flto
957 CC_FLAGS_LTO += -fvisibility=hidden
960 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
965 ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
966 KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
972 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
973 KBUILD_AFLAGS += -fno-lto
978 CC_FLAGS_CFI := -fsanitize=kcfi
984 KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
988 NOSTDINC_FLAGS += -nostdinc
994 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
997 KBUILD_CFLAGS += -fno-strict-overflow
999 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1000 KBUILD_CFLAGS += -fno-stack-check
1004 KBUILD_CFLAGS += -fconserve-stack
1008 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
1011 include-y := scripts/Makefile.extrawarn
1012 include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1013 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1014 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1015 include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan
1016 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1017 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1018 include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
1019 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1021 include $(addprefix $(srctree)/, $(include-y))
1023 # scripts/Makefile.gcc-plugins is intentionally included last.
1024 # Do not add $(call cc-option,...) below this line. When you build the kernel
1033 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1034 LDFLAGS_vmlinux += --build-id=sha1
1036 KBUILD_LDFLAGS += -z noexecstack
1038 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1042 LDFLAGS_vmlinux += -X
1046 # ld.lld before 15 did not support -z pack-relative-relocs.
1047 LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs)
1053 LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
1057 KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
1058 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
1062 KBUILD_USERLDFLAGS += $(call cc-option, --ld-path=$(LD))
1066 CHECKFLAGS += --arch=$(ARCH)
1069 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1072 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1099 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
1105 export MODORDER := $(extmod_prefix)modules.order
1106 export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
1110 build-dir := .
1111 clean-dirs := $(sort . Documentation \
1112 $(patsubst %/,%,$(filter %/, $(core-) \
1113 $(drivers-) $(libs-))))
1115 export ARCH_CORE := $(core-y)
1116 export ARCH_LIB := $(filter %/, $(libs-y))
1117 export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
1118 # Externally visible symbols (used by link-vmlinux.sh)
1120 KBUILD_VMLINUX_OBJS := ./built-in.a
1122 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1123 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1125 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
1133 # we have to build modules as well to determine what those symbols are.
1137 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
1140 rm -f $@; \
1142 $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
1145 vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
1150 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
1152 vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o
1169 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux
1193 # or the modules are listed in "prepare".
1194 # A multi level approach is used. prepareN is processed before prepareN-1.
1201 asm-generic $(version_h) include/generated/utsrelease.h \
1202 include/generated/compile.h include/generated/autoconf.h remove-stale-files
1215 PHONY += remove-stale-files
1216 remove-stale-files:
1217 $(Q)$(srctree)/scripts/remove-stale-files
1219 # Support for using generic headers in asm-generic
1220 asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
1222 PHONY += asm-generic uapi-asm-generic
1223 asm-generic: uapi-asm-generic
1224 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1225 generic=include/asm-generic
1226 uapi-asm-generic:
1227 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1228 generic=include/uapi/asm-generic
1231 # ---------------------------------------------------------------------------
1238 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1246 if [ $(SUBLEVEL) -gt 255 ]; then \
1276 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1277 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1279 # ---------------------------------------------------------------------------
1287 mkdir -p $(INSTALL_HDR_PATH); \
1288 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1297 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1300 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1302 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1303 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1313 # ---------------------------------------------------------------------------
1318 # to this Makefile to build and install external modules.
1324 # ---------------------------------------------------------------------------
1328 vdso_install: export INSTALL_FILES = $(vdso-install-y)
1330 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
1332 # ---------------------------------------------------------------------------
1353 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1357 $(Q)mkdir -p $(objtree)/tools
1358 $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1361 $(Q)mkdir -p $(objtree)/tools
1362 $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1364 # ---------------------------------------------------------------------------
1369 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1371 kselftest-%: headers FORCE
1372 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1374 PHONY += kselftest-merge
1375 kselftest-merge:
1377 $(Q)find $(srctree)/tools/testing/selftests -name config | \
1378 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1379 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1381 # ---------------------------------------------------------------------------
1440 # ---------------------------------------------------------------------------
1441 # Modules
1445 # By default, build modules as well
1447 all: modules
1449 # When we're building modules with modversions, we need to consider
1450 # the built-in objects during the descend as well, in order to
1456 # Build modules
1463 modules: vmlinux
1466 modules: modules_prepare
1468 # Target to prepare building external modules
1477 # Leave enough to build external modules
1482 CLEAN_FILES += vmlinux.symvers modules-only.symvers \
1483 modules.builtin modules.builtin.modinfo modules.nsdeps \
1485 rust-project.json .vmlinux.objs .vmlinux.export.c
1490 debian snap tar-install \
1495 vmlinux-gdb.py \
1499 # clean - Delete most, but leave enough to build external modules
1501 clean: rm-files := $(CLEAN_FILES)
1506 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1507 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1511 # mrproper - Delete all generated files, including .config
1513 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1514 mrproper-dirs := $(addprefix _mrproper_,scripts)
1516 PHONY += $(mrproper-dirs) mrproper
1517 $(mrproper-dirs):
1520 mrproper: clean $(mrproper-dirs)
1523 \( -name '*.rmeta' \) \
1524 -type f -print | xargs rm -f
1532 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1533 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1534 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1535 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1536 -type f -print | xargs rm -f
1540 # ---------------------------------------------------------------------------
1542 %src-pkg: FORCE
1543 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1545 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1548 # ---------------------------------------------------------------------------
1552 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1553 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1558 @echo ' clean - Remove most generated files but keep the config and'
1559 @echo ' enough build support to build external modules'
1560 @echo ' mrproper - Remove all generated files + config + various backup files'
1561 @echo ' distclean - mrproper + remove editor backup and patch files'
1563 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1566 @echo ' all - Build all targets marked with [*]'
1567 @echo '* vmlinux - Build the bare kernel'
1568 @echo '* modules - Build all modules'
1569 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1570 @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
1571 @echo ' dir/ - Build all files in dir and below'
1572 @echo ' dir/file.[ois] - Build specified target only'
1573 @echo ' dir/file.ll - Build the LLVM assembly file'
1575 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1577 @echo ' dir/file.ko - Build module including final link'
1578 @echo ' modules_prepare - Set up for building external modules'
1579 @echo ' tags/TAGS - Generate tags file for editors'
1580 @echo ' cscope - Generate cscope index'
1581 @echo ' gtags - Generate GNU GLOBAL index'
1582 @echo ' kernelrelease - Output the release version string (use with make -s)'
1583 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1584 @echo ' image_name - Output the image name (use with make -s)'
1585 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1589 @echo ' checkstack - Generate a list of stack hogs'
1590 @echo ' versioncheck - Sanity check on version.h usage'
1591 @echo ' includecheck - Check for duplicate included header files'
1592 @echo ' export_report - List the usages of all exported symbols'
1593 @echo ' headerdep - Detect inclusion cycles in headers'
1594 @echo ' coccicheck - Check with Coccinelle'
1595 @echo ' clang-analyzer - Check with clang static analyzer'
1596 @echo ' clang-tidy - Check with clang-tidy'
1599 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1602 @echo ' kselftest - Build and run kernel selftest'
1606 @echo ' kselftest-all - Build kernel selftest'
1607 @echo ' kselftest-install - Build and install kernel selftest'
1608 @echo ' kselftest-clean - Remove all generated kselftest files'
1609 @echo ' kselftest-merge - Merge all the config dependencies of'
1613 @echo ' rustavailable - Checks whether the Rust toolchain is'
1615 @echo ' rustfmt - Reformat all the Rust code in the kernel'
1616 @echo ' rustfmtcheck - Checks if all the Rust code in the kernel'
1618 @echo ' rustdoc - Generate Rust documentation'
1620 @echo ' rusttest - Runs the Rust tests'
1622 @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file'
1624 @echo ' dir/file.[os] - Build specified target only'
1625 @echo ' dir/file.rsi - Build macro expanded source, similar to C preprocessing.'
1628 @echo ' dir/file.ll - Build the LLVM assembly file'
1632 echo '* dtbs - Build device tree blobs for enabled boards'; \
1633 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1634 echo ' dt_binding_check - Validate device tree binding documents'; \
1635 echo ' dtbs_check - Validate device tree source files';\
1643 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1646 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1654 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1656 @$(if $(board-dirs), \
1657 $(foreach b, $(board-dirs), \
1658 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1659 printf " %-16s - Show all of the above\\n" help-boards; \
1666 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1685 help-board-dirs := $(addprefix help-,$(board-dirs))
1687 help-boards: $(help-board-dirs)
1689 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1691 $(help-board-dirs): help-%:
1693 @$(if $(boards-per-dir), \
1694 $(foreach b, $(boards-per-dir), \
1695 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1700 # ---------------------------------------------------------------------------
1709 # ---------------------------------------------------------------------------
1718 # Using the singular to avoid running afoul of `no-dot-config-targets`.
1737 $(Q)find $(abs_srctree) -type f -name '*.rs' \
1738 -o -path $(abs_srctree)/rust/alloc -prune \
1739 -o -path $(abs_objtree)/rust/test -prune \
1740 | grep -Fv $(abs_srctree)/rust/alloc \
1741 | grep -Fv $(abs_objtree)/rust/test \
1742 | grep -Fv generated \
1745 rustfmtcheck: rustfmt_flags = --check
1749 # ---------------------------------------------------------------------------
1751 PHONY += misc-check
1752 misc-check:
1753 $(Q)$(srctree)/scripts/misc-check
1755 all: misc-check
1760 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1772 # When building external modules the kernel used as basis is considered
1773 # read-only, and no consistency checks are made and the make
1777 # We are always building only modules.
1781 build-dir := $(KBUILD_EXTMOD)
1786 clean-dirs := $(KBUILD_EXTMOD)
1787 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
1802 @echo ' Building external modules.'
1803 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1805 @echo ' modules - default target, build the module(s)'
1806 @echo ' modules_install - install the module'
1807 @echo ' clean - remove generated files in module directory only'
1808 @echo ' rust-analyzer - generate rust-project.json rust-analyzer support file'
1812 modules modules_install: __external_modules_error
1816 @echo >&2 '*** You cannot build or install external modules.'
1823 # ---------------------------------------------------------------------------
1824 # Modules
1826 PHONY += modules modules_install modules_sign modules_prepare
1829 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
1830 sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
1840 @echo >&2 '*** CONFIG_MODULE_SIG is disabled. You cannot sign modules.'
1847 $(MODORDER): $(build-dir)
1850 # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
1852 modules: modpost
1854 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1859 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1863 modules:
1871 modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
1873 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1876 # ---------------------------------------------------------------------------
1881 # The supported suffixes for single-target are listed in 'single-targets'
1887 ifdef single-build
1890 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1891 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
1892 $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
1894 $(single-ko): single_modules
1896 $(single-no-ko): $(build-dir)
1901 single_modules: $(single-no-ko) modules_prepare
1902 $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$(m:%.ko=%.o);) } > $(MODORDER)
1903 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1905 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
1907 $(Q)rm -f $(MODORDER)
1909 single-goals := $(addprefix $(build-dir)/, $(single-no-ko))
1919 PHONY += $(build-dir)
1920 $(build-dir): prepare
1921 $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
1923 clean-dirs := $(addprefix _clean_, $(clean-dirs))
1924 PHONY += $(clean-dirs) clean
1925 $(clean-dirs):
1928 clean: $(clean-dirs)
1931 \( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
1932 -o -name '*.ko.*' \
1933 -o -name '*.dtb' -o -name '*.dtbo' \
1934 -o -name '*.dtb.S' -o -name '*.dtbo.S' \
1935 -o -name '*.dt.yaml' \
1936 -o -name '*.dwo' -o -name '*.lst' \
1937 -o -name '*.su' -o -name '*.mod' \
1938 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1939 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
1940 -o -name '*.asn1.[ch]' \
1941 -o -name '*.symtypes' -o -name 'modules.order' \
1942 -o -name '*.c.[012]*.*' \
1943 -o -name '*.ll' \
1944 -o -name '*.gcno' \
1945 -o -name '*.*.symversions' \) -type f -print \
1946 -o -name '.tmp_*' -print \
1947 | xargs rm -rf
1950 # ---------------------------------------------------------------------------
1958 PHONY += rust-analyzer
1959 rust-analyzer:
1963 # ---------------------------------------------------------------------------
1967 nsdeps: modules
1971 # ---------------------------------------------------------------------------
1974 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
1976 $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
1983 PHONY += clang-tidy clang-analyzer
1987 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
1989 clang-tidy clang-analyzer: $(extmod_prefix)compile_commands.json
1992 clang-tidy clang-analyzer:
1998 # ---------------------------------------------------------------------------
2004 -name '*.[hcS]' -type f -print | sort \
2005 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2009 -name '*.[hcS]' -type f -print | sort \
2010 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2022 # else wants $(ARCH), including people doing cross-builds, which means
2030 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2042 PHONY += run-command
2043 run-command:
2046 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2047 cmd_rmfiles = rm -rf $(rm-files)
2050 existing-targets := $(wildcard $(sort $(targets)))
2052 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2054 endif # config-build
2055 endif # mixed-build
2056 endif # need-sub-make