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))),)
108 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
129 # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
131 abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
143 MAKEFLAGS += --no-print-directory
145 need-sub-make := 1
157 # This does not become effective immediately because MAKEFLAGS is re-parsed
158 # once after the Makefile is read. We need to invoke sub-make.
159 MAKEFLAGS += --include-dir=$(abs_srctree)
160 need-sub-make := 1
163 this-makefile := $(lastword $(MAKEFILE_LIST))
166 # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
167 # We need to invoke sub-make to avoid implicit rules in the top Makefile.
168 need-sub-make := 1
170 $(this-makefile): ;
176 ifeq ($(need-sub-make),1)
178 PHONY += $(MAKECMDGOALS) __sub-make
180 $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
184 __sub-make:
185 $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
187 endif # need-sub-make
191 ifeq ($(need-sub-make),)
196 MAKEFLAGS += --no-print-directory
201 # Use 'make C=1' to enable checking of only re-compiled files.
203 # of whether they are re-compiled or not.
205 # See the file "Documentation/dev-tools/sparse.rst" for more details,
222 $(error building multiple external modules is not supported))
226 extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
228 # ANDROID: set up mixed-build support. mixed-build allows device kernel modules
234 $(if $(filter-out $(words $(required_mixed_files)), \
235 $(words $(wildcard $(add-prefix $(KBUILD_MIXED_TREE)/,$(required_mixed_files))))),,\
239 mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/)
276 clean-targets := %clean mrproper cleandocs
277 no-dot-config-targets := $(clean-targets) \
280 %asm-generic kernelversion %src-pkg dt_binding_check \
282 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
284 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
286 config-build :=
287 mixed-build :=
288 need-config := 1
289 may-sync-config := 1
290 single-build :=
292 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
293 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
294 need-config :=
298 ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
299 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
300 may-sync-config :=
305 may-sync-config :=
310 config-build := 1
312 mixed-build := 1
318 ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
319 single-build := 1
320 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
321 mixed-build := 1
325 # For "make -j clean all", "make -j mrproper defconfig all", etc.
326 ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
327 ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
328 mixed-build := 1
335 mixed-build := 1
339 ifdef mixed-build
350 $(Q)set -e; \
352 $(MAKE) -f $(srctree)/Makefile $$i; \
355 else # !mixed-build
366 # Cross compiling and selecting different set of gcc/bin-utils
367 # ---------------------------------------------------------------------------
377 # during compilation. Only gcc and related bin-utils executables
380 # make CROSS_COMPILE=ia64-linux-
414 # Default file for 'make defconfig'. This may be overridden by arch-Makefile.
432 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
433 -O2 -fomit-frame-pointer -std=gnu89
438 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
443 CPP = $(CC) -E
447 AR = llvm-ar
448 NM = llvm-nm
449 OBJCOPY = llvm-objcopy
450 OBJDUMP = llvm-objdump
451 READELF = llvm-readelf
452 STRIP = llvm-strip
486 ifneq ($(wildcard $(srctree)/scripts/gcc-wrapper.py),)
487 CC = $(abspath $(srctree)/scripts/gcc-wrapper.py) $(CROSS_COMPILE)gcc
491 PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh)
493 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
494 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
505 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
506 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
507 -I$(srctree)/include/uapi \
508 -I$(objtree)/include/generated/uapi \
509 -include $(srctree)/include/linux/kconfig.h
514 -I$(srctree)/arch/$(SRCARCH)/include \
515 -I$(objtree)/arch/$(SRCARCH)/include/generated \
516 $(if $(building_out_of_srctree),-I$(srctree)/include) \
517 -I$(objtree)/include \
520 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
521 KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
522 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
523 -Werror=implicit-function-declaration -Werror=implicit-int \
524 -Werror=return-type -Wno-format-security \
525 -std=gnu89
526 KBUILD_CPPFLAGS := -D__KERNEL__
529 KBUILD_AFLAGS_MODULE := -DMODULE
530 KBUILD_CFLAGS_MODULE := -DMODULE
551 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
552 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
553 -prune -o
554 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
555 --exclude CVS --exclude .pc --exclude .hg --exclude .git
564 $(Q)rm -f .tmp_quiet_recordmcount
567 # Before starting out-of-tree build, make sure the source tree is clean.
575 $(Q)if [ -f $(srctree)/.config -o \
576 -d $(srctree)/include/config -o \
577 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
584 $(Q)ln -fsn $(srctree) source
586 $(Q)test -e .gitignore || \
590 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
592 CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
594 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
598 CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
601 CLANG_FLAGS += -no-integrated-as
603 CLANG_FLAGS += -Werror=unknown-warning-option
613 CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
615 ifdef config-build
617 # *config targets only - make sure prerequisites are updated, and descend
632 else #!config-build
634 # Build targets only - this includes vmlinux, arch specific targets, clean
638 # but instead __all depend on modules
643 __all: modules
646 # Decide whether to build built-in, modular, or both.
647 # Normally, just do built-in.
652 # If we have only "make modules", don't compile built-in objects.
653 ifeq ($(MAKECMDGOALS),modules)
657 # If we have "make <whatever> modules", compile modules
659 # Just "make" or "make all" shall build modules as well
661 ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
671 ifdef need-config
677 core-y := init/ usr/
678 drivers-y := drivers/ sound/
679 drivers-$(CONFIG_SAMPLES) += samples/
680 drivers-y += net/ virt/
681 libs-y := lib/
687 # This allow a user to issue only 'make' to build a kernel including modules
692 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \
693 $(call cc-option,-fno-tree-loop-im) \
694 $(call cc-disable-warning,maybe-uninitialized,)
699 CC_FLAGS_FTRACE := -pg
703 RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
704 RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix)
705 RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
708 RETPOLINE_CFLAGS := -mretpoline-external-thunk
709 RETPOLINE_VDSO_CFLAGS := -mretpoline
713 RETHUNK_CFLAGS := -mfunction-return=thunk-extern
722 ifdef need-config
723 ifdef may-sync-config
742 # This exploits the 'multi-target pattern rule' trick.
750 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
751 else # !may-sync-config
752 # External modules and some install targets need include/generated/autoconf.h
753 # and include/config/auto.conf but do not care if they are up-to-date.
758 $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
766 endif # may-sync-config
767 endif # need-config
769 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
770 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
771 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
772 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
773 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
776 KBUILD_CFLAGS += -O2
778 KBUILD_CFLAGS += -O3
780 KBUILD_CFLAGS += -Os
783 # Tell gcc to never replace conditional load with a non-conditional one
784 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
785 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
792 KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
793 $(call cc-option,-fno-ipa-cp-clone,) \
794 $(call cc-option,-fno-partial-inlining)
798 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
801 stackp-flags-y := -fno-stack-protector
802 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
803 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
805 KBUILD_CFLAGS += $(stackp-flags-y)
807 KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
808 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
811 KBUILD_CPPFLAGS += -Qunused-arguments
812 KBUILD_CFLAGS += -Wno-format-invalid-specifier
813 KBUILD_CFLAGS += -Wno-gnu
817 KBUILD_CFLAGS += -mno-global-merge
820 # Warn about unmarked fall-throughs in switch statement.
823 KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
828 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
830 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
832 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
836 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
837 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
838 # -fomit-frame-pointer with FUNCTION_TRACER.
840 KBUILD_CFLAGS += -fomit-frame-pointer
846 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
851 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
853 # https://github.com/llvm/llvm-project/issues/44842
854 KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
863 DEBUG_CFLAGS += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
869 DEBUG_CFLAGS += -gsplit-dwarf
871 DEBUG_CFLAGS += -g
875 KBUILD_AFLAGS += -g
877 KBUILD_AFLAGS += -Wa,-gdwarf-2
881 DEBUG_CFLAGS += -gdwarf-4
885 DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
886 $(call cc-option,-fno-var-tracking)
890 DEBUG_CFLAGS += -gz=zlib
891 KBUILD_AFLAGS += -gz=zlib
892 KBUILD_LDFLAGS += --compress-debug-sections=zlib
902 CC_FLAGS_FTRACE += -mrecord-mcount
904 ifeq ($(call cc-option-yn, -mnop-mcount),y)
905 CC_FLAGS_FTRACE += -mnop-mcount
906 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
911 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
920 ifeq ($(call cc-option-yn, -mfentry),y)
921 CC_FLAGS_FTRACE += -mfentry
922 CC_FLAGS_USING += -DCC_USING_FENTRY
932 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
936 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
937 LDFLAGS_vmlinux += --gc-sections
941 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
948 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
949 KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache
951 CC_FLAGS_LTO := -flto
956 CC_FLAGS_LTO += -fvisibility=hidden
958 CC_FLAGS_LTO += -fvisibility=default
962 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
971 CC_FLAGS_CFI := -fsanitize=cfi \
972 -fsanitize-cfi-cross-dso \
973 -fno-sanitize-cfi-canonical-jump-tables \
974 -fno-sanitize-blacklist
977 CC_FLAGS_CFI += -fsanitize-recover=cfi \
978 -fno-sanitize-trap=cfi
981 CC_FLAGS_CFI += -ftrap-function=__ubsan_handle_cfi_check_fail_abort
992 KBUILD_CFLAGS += -falign-functions=32
996 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
999 KBUILD_CFLAGS += -Wdeclaration-after-statement
1002 KBUILD_CFLAGS += -Wvla
1005 KBUILD_CFLAGS += -Wno-pointer-sign
1008 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
1011 KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
1012 KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
1013 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
1016 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
1019 KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
1022 KBUILD_CFLAGS += -fno-strict-overflow
1024 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1025 KBUILD_CFLAGS += -fno-stack-check
1028 KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
1030 # Prohibit date/time macros, which would make the build non-deterministic
1031 KBUILD_CFLAGS += -Werror=date-time
1034 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
1037 KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
1040 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
1043 include-y := scripts/Makefile.extrawarn
1044 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1045 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1046 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1047 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1048 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1050 include $(addprefix $(srctree)/, $(include-y))
1052 # scripts/Makefile.gcc-plugins is intentionally included last.
1053 # Do not add $(call cc-option,...) below this line. When you build the kernel
1061 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1062 LDFLAGS_vmlinux += --build-id=sha1
1064 KBUILD_LDFLAGS += -z noexecstack
1065 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1068 LDFLAGS_vmlinux += $(call ld-option, -X,)
1072 LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
1078 LDFLAGS_vmlinux += --orphan-handling=warn
1082 KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1083 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1086 CHECKFLAGS += --arch=$(ARCH)
1089 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1092 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1119 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
1123 # INSTALL_MOD_STRIP, if defined, will cause modules to be
1125 # the default option --strip-debug will be used. Otherwise,
1130 mod_strip_cmd = $(STRIP) --strip-debug
1146 mod_compress_cmd = $(KGZIP) -n -f
1149 mod_compress_cmd = $(XZ) -f
1157 mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODU…
1163 HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
1165 has_libelf := $(call try-run,\
1167 … $(HOSTCC) $(KBUILD_HOSTCFLAGS) -xc -o /dev/null $(KBUILD_HOSTLDFLAGS) $(HOST_LIBELF_LIBS) -,1,0)
1186 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1201 export MODORDER := $(extmod-prefix)modules.order
1202 export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
1204 # ---------------------------------------------------------------------------
1212 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1213 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1215 hdr-prefix = $(KBUILD_EXTMOD)/
1216 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst dst=$(KBUILD_EXTMOD)/usr/include objtree=$(o…
1219 export INSTALL_HDR_PATH = $(objtree)/$(hdr-prefix)usr
1223 mkdir -p $(INSTALL_HDR_PATH); \
1224 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1225 $(hdr-prefix)usr/include $(INSTALL_HDR_PATH);
1236 $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi
1237 $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi
1240 core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ io_uring/
1242 vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
1243 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
1244 $(libs-y) $(libs-m)))
1246 vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
1247 $(patsubst %/,%,$(filter %/, $(core-) \
1248 $(drivers-) $(libs-))))
1250 build-dirs := $(vmlinux-dirs)
1251 clean-dirs := $(vmlinux-alldirs)
1253 subdir-modorder := $(addsuffix /modules.order, $(build-dirs))
1255 # Externally visible symbols (used by link-vmlinux.sh)
1256 KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
1257 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
1259 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1260 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1262 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
1264 KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
1269 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scrip…
1271 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
1277 # we have to build modules as well to determine what those symbols are.
1281 autoksyms_recursive: descend modules.order
1283 "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
1289 cmd_autoksyms_h = mkdir -p $(dir $@); \
1298 cmd_link-vmlinux = \
1300 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
1303 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
1304 +$(call if_changed,link-vmlinux)
1311 $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
1329 # or the modules are listed in "prepare".
1330 # A multi level approach is used. prepareN is processed before prepareN-1.
1337 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
1345 prepare: prepare0 prepare-objtool prepare-resolve_btfids
1347 # Support for using generic headers in asm-generic
1348 asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
1350 PHONY += asm-generic uapi-asm-generic
1351 asm-generic: uapi-asm-generic
1352 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1353 generic=include/asm-generic
1354 uapi-asm-generic:
1355 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1356 generic=include/uapi/asm-generic
1358 PHONY += prepare-objtool prepare-resolve_btfids
1359 prepare-objtool: $(objtool_target)
1362 …nt_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1366 …metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1369 …nnot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1373 prepare-resolve_btfids: $(resolve_btfids_target)
1375 … BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1379 # ---------------------------------------------------------------------------
1386 UTS_RELEASE=$(KERNELRELEASE)-ab$(BUILD_NUMBER)
1391 if [ `echo -n "$(UTS_RELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1399 if [ $(SUBLEVEL) -gt 255 ]; then \
1414 $(Q)rm -f $(old_version_h)
1421 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1422 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1424 # Deprecated. It is no-op now.
1437 # ---------------------------------------------------------------------------
1442 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1444 kselftest-%: FORCE
1445 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1447 PHONY += kselftest-merge
1448 kselftest-merge:
1450 $(Q)find $(srctree)/tools/testing/selftests -name config | \
1451 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1452 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1454 # ---------------------------------------------------------------------------
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
1516 # A module can be listed more than once in obj-m resulting in
1517 # duplicate lines in modules.order files. Those are removed
1520 PHONY += modules
1522 modules: $(if $(KBUILD_BUILTIN), $(if $(KBUILD_MIXED_TREE),,vmlinux)) target
1523 modules: modules_check modules_prepare target
1524 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1527 modules_check: modules.order
1528 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1530 cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
1532 modules.order: $(subdir-modorder) FORCE
1535 targets += modules.order
1537 # Target to prepare building external modules
1542 # Target to install modules
1548 @rm -rf $(MODLIB)/kernel
1549 @rm -f $(MODLIB)/source
1550 @mkdir -p $(MODLIB)/kernel
1551 @ln -s $(abspath $(srctree)) $(MODLIB)/source
1552 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
1553 rm -f $(MODLIB)/build ; \
1554 ln -s $(CURDIR) $(MODLIB)/build ; \
1556 @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
1557 @cp -f $(mixed-build-prefix)modules.builtin $(MODLIB)/
1558 @cp -f $(or $(mixed-build-prefix),$(objtree)/)modules.builtin.modinfo $(MODLIB)/
1559 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1562 # boot a modules.dep even before / is mounted read-write. However the
1571 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
1576 # Modules not configured
1577 # ---------------------------------------------------------------------------
1579 PHONY += modules modules_install
1580 modules modules_install: target
1582 @echo >&2 "The present kernel configuration has modules disabled."
1593 # Leave enough to build external modules
1598 CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
1599 modules.builtin modules.builtin.modinfo modules.nsdeps \
1600 compile_commands.json .thinlto-cache
1605 debian snap tar-install \
1610 signing_key.x509.signer vmlinux-gdb.py \
1616 # clean - Delete most, but leave enough to build external modules
1618 clean: rm-files := $(CLEAN_FILES)
1623 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1624 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1628 # mrproper - Delete all generated files, including .config
1630 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1631 mrproper-dirs := $(addprefix _mrproper_,scripts)
1633 PHONY += $(mrproper-dirs) mrproper
1634 $(mrproper-dirs):
1637 mrproper: clean $(mrproper-dirs)
1642 distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
1649 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1650 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1651 -o -name 'core' \) \
1652 -type f -print | xargs rm -f
1656 # ---------------------------------------------------------------------------
1658 %src-pkg: FORCE
1659 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1661 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1664 # ---------------------------------------------------------------------------
1668 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1669 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1674 @echo ' clean - Remove most generated files but keep the config and'
1675 @echo ' enough build support to build external modules'
1676 @echo ' mrproper - Remove all generated files + config + various backup files'
1677 @echo ' distclean - mrproper + remove editor backup and patch files'
1680 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1683 @echo ' all - Build all targets marked with [*]'
1684 @echo '* vmlinux - Build the bare kernel'
1685 @echo '* modules - Build all modules'
1686 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1687 @echo ' dir/ - Build all files in dir and below'
1688 @echo ' dir/file.[ois] - Build specified target only'
1689 @echo ' dir/file.ll - Build the LLVM assembly file'
1691 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1693 @echo ' dir/file.ko - Build module including final link'
1694 @echo ' modules_prepare - Set up for building external modules'
1695 @echo ' tags/TAGS - Generate tags file for editors'
1696 @echo ' cscope - Generate cscope index'
1697 @echo ' gtags - Generate GNU GLOBAL index'
1698 @echo ' kernelrelease - Output the release version string (use with make -s)'
1699 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1700 @echo ' image_name - Output the image name (use with make -s)'
1701 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1705 @echo ' checkstack - Generate a list of stack hogs'
1706 @echo ' versioncheck - Sanity check on version.h usage'
1707 @echo ' includecheck - Check for duplicate included header files'
1708 @echo ' export_report - List the usages of all exported symbols'
1709 @echo ' headerdep - Detect inclusion cycles in headers'
1710 @echo ' coccicheck - Check with Coccinelle'
1711 @echo ' clang-analyzer - Check with clang static analyzer'
1712 @echo ' clang-tidy - Check with clang-tidy'
1715 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1718 @echo ' kselftest - Build and run kernel selftest'
1722 @echo ' kselftest-all - Build kernel selftest'
1723 @echo ' kselftest-install - Build and install kernel selftest'
1724 @echo ' kselftest-clean - Remove all generated kselftest files'
1725 @echo ' kselftest-merge - Merge all the config dependencies of'
1730 echo '* dtbs - Build device tree blobs for enabled boards'; \
1731 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1732 echo ' dt_binding_check - Validate device tree binding documents'; \
1733 echo ' dtbs_check - Validate device tree source files';\
1741 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1744 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1752 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1754 @$(if $(board-dirs), \
1755 $(foreach b, $(board-dirs), \
1756 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1757 printf " %-16s - Show all of the above\\n" help-boards; \
1763 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1777 help-board-dirs := $(addprefix help-,$(board-dirs))
1779 help-boards: $(help-board-dirs)
1781 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1783 $(help-board-dirs): help-%:
1785 @$(if $(boards-per-dir), \
1786 $(foreach b, $(boards-per-dir), \
1787 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1792 # ---------------------------------------------------------------------------
1800 # ---------------------------------------------------------------------------
1805 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1815 # When building external modules the kernel used as basis is considered
1816 # read-only, and no consistency checks are made and the make
1822 # modules.
1824 # make M=dir modules Make all modules in specified dir
1825 # make M=dir Same as 'make M=dir modules'
1827 # Install the modules built in the module directory
1830 # We are always building only modules.
1834 build-dirs := $(KBUILD_EXTMOD)
1835 PHONY += modules
1836 modules: $(MODORDER) target
1837 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1845 install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1848 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1849 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1855 compile_commands.json: $(extmod-prefix)compile_commands.json
1858 clean-dirs := $(KBUILD_EXTMOD)
1859 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
1860 $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
1864 @echo ' Building external modules.'
1865 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1867 @echo ' modules - default target, build the module(s)'
1868 @echo ' modules_install - install the module'
1869 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'
1871 @echo ' clean - remove generated files in module directory only'
1874 # no-op for external module builds
1880 # ---------------------------------------------------------------------------
1885 # The supported suffixes for single-target are listed in 'single-targets'
1891 ifdef single-build
1894 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1895 single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS)))
1897 $(single-ko): single_modpost
1899 $(single-no-ko): descend
1903 # For the single build of in-tree modules, use a temporary file to avoid
1904 # the situation of modules_install installing an invalid modules.order.
1905 MODORDER := .modules.tmp
1909 single_modpost: $(single-no-ko) modules_prepare
1910 $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
1911 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1915 export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
1918 build-dirs := $(foreach d, $(build-dirs), \
1927 # Handle descending into subdirectories listed in $(build-dirs)
1932 PHONY += descend $(build-dirs)
1933 descend: $(build-dirs)
1934 $(build-dirs): prepare
1936 single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
1937 $(if $(KBUILD_MIXED_TREE),,need-builtin=1) need-modorder=1
1939 clean-dirs := $(addprefix _clean_, $(clean-dirs))
1940 PHONY += $(clean-dirs) clean
1941 $(clean-dirs):
1944 clean: $(clean-dirs)
1947 \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
1948 -o -name '*.ko.*' \
1949 -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
1950 -o -name '*.dwo' -o -name '*.lst' \
1951 -o -name '*.su' -o -name '*.mod' \
1952 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1953 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
1954 -o -name '*.asn1.[ch]' \
1955 -o -name '*.symtypes' -o -name 'modules.order' \
1956 -o -name '.tmp_*.o.*' \
1957 -o -name '*.c.[012]*.*' \
1958 -o -name '*.ll' \
1959 -o -name '*.gcno' \
1960 -o -name '*.*.symversions' \) -type f -print | xargs rm -f
1963 # ---------------------------------------------------------------------------
1971 # ---------------------------------------------------------------------------
1975 nsdeps: modules
1979 # ---------------------------------------------------------------------------
1982 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
1984 $(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
1989 targets += $(extmod-prefix)compile_commands.json
1991 PHONY += clang-tidy clang-analyzer
1995 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
1997 clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json
2000 clang-tidy clang-analyzer:
2006 # ---------------------------------------------------------------------------
2012 -name '*.[hcS]' -type f -print | sort \
2013 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2017 -name '*.[hcS]' -type f -print | sort \
2018 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2030 # else wants $(ARCH), including people doing cross-builds, which means
2038 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2058 $(Q)mkdir -p $(objtree)/tools
2059 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
2062 $(Q)mkdir -p $(objtree)/tools
2063 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
2065 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2066 cmd_rmfiles = rm -rf $(rm-files)
2071 $(KERNELRELEASE) $(mixed-build-prefix)
2074 existing-targets := $(wildcard $(sort $(targets)))
2076 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2078 endif # config-build
2079 endif # mixed-build
2080 endif # need-sub-make