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
565 $(Q)rm -f .tmp_quiet_recordmcount
568 # Before starting out-of-tree build, make sure the source tree is clean.
576 $(Q)if [ -f $(srctree)/.config -o \
577 -d $(srctree)/include/config -o \
578 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
585 $(Q)ln -fsn $(srctree) source
587 $(Q)test -e .gitignore || \
591 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
593 CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
595 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
599 CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
602 CLANG_FLAGS += -no-integrated-as
604 CLANG_FLAGS += -Werror=unknown-warning-option
614 CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
616 ifdef config-build
618 # *config targets only - make sure prerequisites are updated, and descend
633 else #!config-build
635 # Build targets only - this includes vmlinux, arch specific targets, clean
639 # but instead __all depend on modules
644 __all: modules
647 # Decide whether to build built-in, modular, or both.
648 # Normally, just do built-in.
653 # If we have only "make modules", don't compile built-in objects.
654 ifeq ($(MAKECMDGOALS),modules)
658 # If we have "make <whatever> modules", compile modules
660 # Just "make" or "make all" shall build modules as well
662 ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
672 ifdef need-config
678 core-y := init/ usr/
679 drivers-y := drivers/ sound/
680 drivers-$(CONFIG_SAMPLES) += samples/
681 drivers-y += net/ virt/
682 libs-y := lib/
688 # This allow a user to issue only 'make' to build a kernel including modules
693 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \
694 $(call cc-option,-fno-tree-loop-im) \
695 $(call cc-disable-warning,maybe-uninitialized,)
700 CC_FLAGS_FTRACE := -pg
704 RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
705 RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix)
706 RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
709 RETPOLINE_CFLAGS := -mretpoline-external-thunk
710 RETPOLINE_VDSO_CFLAGS := -mretpoline
714 RETHUNK_CFLAGS := -mfunction-return=thunk-extern
723 ifdef need-config
724 ifdef may-sync-config
743 # This exploits the 'multi-target pattern rule' trick.
751 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
752 else # !may-sync-config
753 # External modules and some install targets need include/generated/autoconf.h
754 # and include/config/auto.conf but do not care if they are up-to-date.
759 $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
767 endif # may-sync-config
768 endif # need-config
770 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
771 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
772 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
773 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
774 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
777 KBUILD_CFLAGS += -O2
779 KBUILD_CFLAGS += -O3
781 KBUILD_CFLAGS += -Os
784 # Tell gcc to never replace conditional load with a non-conditional one
785 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
786 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
793 KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
794 $(call cc-option,-fno-ipa-cp-clone,) \
795 $(call cc-option,-fno-partial-inlining)
799 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
802 stackp-flags-y := -fno-stack-protector
803 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
804 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
806 KBUILD_CFLAGS += $(stackp-flags-y)
808 KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
809 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
812 KBUILD_CPPFLAGS += -Qunused-arguments
813 KBUILD_CFLAGS += -Wno-format-invalid-specifier
814 KBUILD_CFLAGS += -Wno-gnu
818 KBUILD_CFLAGS += -mno-global-merge
821 # Warn about unmarked fall-throughs in switch statement.
824 KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
829 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
831 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
833 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
837 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
838 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
839 # -fomit-frame-pointer with FUNCTION_TRACER.
841 KBUILD_CFLAGS += -fomit-frame-pointer
847 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
852 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
854 # https://github.com/llvm/llvm-project/issues/44842
855 KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
864 DEBUG_CFLAGS += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
870 DEBUG_CFLAGS += -gsplit-dwarf
872 DEBUG_CFLAGS += -g
876 KBUILD_AFLAGS += -g
878 KBUILD_AFLAGS += -Wa,-gdwarf-2
882 DEBUG_CFLAGS += -gdwarf-4
886 DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
887 $(call cc-option,-fno-var-tracking)
891 DEBUG_CFLAGS += -gz=zlib
892 KBUILD_AFLAGS += -gz=zlib
893 KBUILD_LDFLAGS += --compress-debug-sections=zlib
903 CC_FLAGS_FTRACE += -mrecord-mcount
905 ifeq ($(call cc-option-yn, -mnop-mcount),y)
906 CC_FLAGS_FTRACE += -mnop-mcount
907 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
912 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
921 ifeq ($(call cc-option-yn, -mfentry),y)
922 CC_FLAGS_FTRACE += -mfentry
923 CC_FLAGS_USING += -DCC_USING_FENTRY
933 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
937 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
938 LDFLAGS_vmlinux += --gc-sections
942 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
949 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
950 KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache
952 CC_FLAGS_LTO := -flto
957 CC_FLAGS_LTO += -fvisibility=hidden
959 CC_FLAGS_LTO += -fvisibility=default
963 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
972 CC_FLAGS_CFI := -fsanitize=cfi \
973 -fsanitize-cfi-cross-dso \
974 -fno-sanitize-cfi-canonical-jump-tables \
975 -fno-sanitize-blacklist
978 CC_FLAGS_CFI += -fsanitize-recover=cfi \
979 -fno-sanitize-trap=cfi
982 CC_FLAGS_CFI += -ftrap-function=__ubsan_handle_cfi_check_fail_abort
993 KBUILD_CFLAGS += -falign-functions=32
997 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
1000 KBUILD_CFLAGS += -Wdeclaration-after-statement
1003 KBUILD_CFLAGS += -Wvla
1006 KBUILD_CFLAGS += -Wno-pointer-sign
1009 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
1012 KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
1013 KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
1014 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
1017 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
1020 KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
1023 KBUILD_CFLAGS += -fno-strict-overflow
1025 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1026 KBUILD_CFLAGS += -fno-stack-check
1029 KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
1031 # Prohibit date/time macros, which would make the build non-deterministic
1032 KBUILD_CFLAGS += -Werror=date-time
1035 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
1038 KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
1041 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
1044 include-y := scripts/Makefile.extrawarn
1045 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1046 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1047 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1048 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1049 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1051 include $(addprefix $(srctree)/, $(include-y))
1053 # scripts/Makefile.gcc-plugins is intentionally included last.
1054 # Do not add $(call cc-option,...) below this line. When you build the kernel
1062 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1063 LDFLAGS_vmlinux += --build-id=sha1
1065 KBUILD_LDFLAGS += -z noexecstack
1066 KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1069 LDFLAGS_vmlinux += $(call ld-option, -X,)
1073 LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
1079 LDFLAGS_vmlinux += --orphan-handling=warn
1083 KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1084 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1087 CHECKFLAGS += --arch=$(ARCH)
1090 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1093 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1120 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
1124 # INSTALL_MOD_STRIP, if defined, will cause modules to be
1126 # the default option --strip-debug will be used. Otherwise,
1131 mod_strip_cmd = $(STRIP) --strip-debug
1147 mod_compress_cmd = $(KGZIP) -n -f
1150 mod_compress_cmd = $(XZ) -f
1158 mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODU…
1164 HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
1166 has_libelf := $(call try-run,\
1168 … $(HOSTCC) $(KBUILD_HOSTCFLAGS) -xc -o /dev/null $(KBUILD_HOSTLDFLAGS) $(HOST_LIBELF_LIBS) -,1,0)
1187 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1202 export MODORDER := $(extmod-prefix)modules.order
1203 export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
1205 # ---------------------------------------------------------------------------
1213 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1214 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1216 hdr-prefix = $(KBUILD_EXTMOD)/
1217 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst dst=$(KBUILD_EXTMOD)/usr/include objtree=$(o…
1220 export INSTALL_HDR_PATH = $(objtree)/$(hdr-prefix)usr
1224 mkdir -p $(INSTALL_HDR_PATH); \
1225 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1226 $(hdr-prefix)usr/include $(INSTALL_HDR_PATH);
1237 $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi
1238 $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi
1241 core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ io_uring/
1243 vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
1244 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
1245 $(libs-y) $(libs-m)))
1247 vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
1248 $(patsubst %/,%,$(filter %/, $(core-) \
1249 $(drivers-) $(libs-))))
1251 build-dirs := $(vmlinux-dirs)
1252 clean-dirs := $(vmlinux-alldirs)
1254 subdir-modorder := $(addsuffix /modules.order, $(build-dirs))
1256 # Externally visible symbols (used by link-vmlinux.sh)
1257 KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
1258 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
1260 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1261 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1263 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
1265 KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
1270 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scrip…
1272 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
1278 # we have to build modules as well to determine what those symbols are.
1282 autoksyms_recursive: descend modules.order
1284 "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
1290 cmd_autoksyms_h = mkdir -p $(dir $@); \
1299 cmd_link-vmlinux = \
1301 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
1304 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
1305 +$(call if_changed,link-vmlinux)
1312 $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
1330 # or the modules are listed in "prepare".
1331 # A multi level approach is used. prepareN is processed before prepareN-1.
1338 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
1346 prepare: prepare0 prepare-objtool prepare-resolve_btfids
1348 # Support for using generic headers in asm-generic
1349 asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
1351 PHONY += asm-generic uapi-asm-generic
1352 asm-generic: uapi-asm-generic
1353 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1354 generic=include/asm-generic
1355 uapi-asm-generic:
1356 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1357 generic=include/uapi/asm-generic
1359 PHONY += prepare-objtool prepare-resolve_btfids
1360 prepare-objtool: $(objtool_target)
1363 …nt_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1367 …metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1370 …nnot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1374 prepare-resolve_btfids: $(resolve_btfids_target)
1376 … BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-dev…
1380 # ---------------------------------------------------------------------------
1387 UTS_RELEASE=$(KERNELRELEASE)-ab$(BUILD_NUMBER)
1392 if [ `echo -n "$(UTS_RELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1400 if [ $(SUBLEVEL) -gt 255 ]; then \
1415 $(Q)rm -f $(old_version_h)
1422 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1423 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1425 # Deprecated. It is no-op now.
1438 # ---------------------------------------------------------------------------
1443 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1445 kselftest-%: FORCE
1446 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1448 PHONY += kselftest-merge
1449 kselftest-merge:
1451 $(Q)find $(srctree)/tools/testing/selftests -name config | \
1452 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1453 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1455 # ---------------------------------------------------------------------------
1499 # ---------------------------------------------------------------------------
1500 # Modules
1504 # By default, build modules as well
1506 all: modules
1508 # When we're building modules with modversions, we need to consider
1509 # the built-in objects during the descend as well, in order to
1515 # Build modules
1517 # A module can be listed more than once in obj-m resulting in
1518 # duplicate lines in modules.order files. Those are removed
1521 PHONY += modules
1523 modules: $(if $(KBUILD_BUILTIN), $(if $(KBUILD_MIXED_TREE),,vmlinux))
1524 modules: modules_check modules_prepare
1525 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1528 modules_check: modules.order
1529 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1531 cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
1533 modules.order: $(subdir-modorder) FORCE
1536 targets += modules.order
1538 # Target to prepare building external modules
1543 # Target to install modules
1549 @rm -rf $(MODLIB)/kernel
1550 @rm -f $(MODLIB)/source
1551 @mkdir -p $(MODLIB)/kernel
1552 @ln -s $(abspath $(srctree)) $(MODLIB)/source
1553 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
1554 rm -f $(MODLIB)/build ; \
1555 ln -s $(CURDIR) $(MODLIB)/build ; \
1557 @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
1558 @cp -f $(mixed-build-prefix)modules.builtin $(MODLIB)/
1559 @cp -f $(or $(mixed-build-prefix),$(objtree)/)modules.builtin.modinfo $(MODLIB)/
1560 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1563 # boot a modules.dep even before / is mounted read-write. However the
1572 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
1577 # Modules not configured
1578 # ---------------------------------------------------------------------------
1580 PHONY += modules modules_install
1581 modules modules_install:
1583 @echo >&2 "The present kernel configuration has modules disabled."
1594 # Leave enough to build external modules
1599 CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
1600 modules.builtin modules.builtin.modinfo modules.nsdeps \
1601 compile_commands.json .thinlto-cache
1606 debian snap tar-install \
1611 signing_key.x509.signer vmlinux-gdb.py \
1617 # clean - Delete most, but leave enough to build external modules
1619 clean: rm-files := $(CLEAN_FILES)
1624 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1625 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1629 # mrproper - Delete all generated files, including .config
1631 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1632 mrproper-dirs := $(addprefix _mrproper_,scripts)
1634 PHONY += $(mrproper-dirs) mrproper
1635 $(mrproper-dirs):
1638 mrproper: clean $(mrproper-dirs)
1643 distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
1650 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1651 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1652 -o -name 'core' \) \
1653 -type f -print | xargs rm -f
1657 # ---------------------------------------------------------------------------
1659 %src-pkg: FORCE
1660 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1662 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1665 # ---------------------------------------------------------------------------
1669 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1670 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1675 @echo ' clean - Remove most generated files but keep the config and'
1676 @echo ' enough build support to build external modules'
1677 @echo ' mrproper - Remove all generated files + config + various backup files'
1678 @echo ' distclean - mrproper + remove editor backup and patch files'
1681 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1684 @echo ' all - Build all targets marked with [*]'
1685 @echo '* vmlinux - Build the bare kernel'
1686 @echo '* modules - Build all modules'
1687 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1688 @echo ' dir/ - Build all files in dir and below'
1689 @echo ' dir/file.[ois] - Build specified target only'
1690 @echo ' dir/file.ll - Build the LLVM assembly file'
1692 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1694 @echo ' dir/file.ko - Build module including final link'
1695 @echo ' modules_prepare - Set up for building external modules'
1696 @echo ' tags/TAGS - Generate tags file for editors'
1697 @echo ' cscope - Generate cscope index'
1698 @echo ' gtags - Generate GNU GLOBAL index'
1699 @echo ' kernelrelease - Output the release version string (use with make -s)'
1700 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1701 @echo ' image_name - Output the image name (use with make -s)'
1702 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1706 @echo ' checkstack - Generate a list of stack hogs'
1707 @echo ' versioncheck - Sanity check on version.h usage'
1708 @echo ' includecheck - Check for duplicate included header files'
1709 @echo ' export_report - List the usages of all exported symbols'
1710 @echo ' headerdep - Detect inclusion cycles in headers'
1711 @echo ' coccicheck - Check with Coccinelle'
1712 @echo ' clang-analyzer - Check with clang static analyzer'
1713 @echo ' clang-tidy - Check with clang-tidy'
1716 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1719 @echo ' kselftest - Build and run kernel selftest'
1723 @echo ' kselftest-all - Build kernel selftest'
1724 @echo ' kselftest-install - Build and install kernel selftest'
1725 @echo ' kselftest-clean - Remove all generated kselftest files'
1726 @echo ' kselftest-merge - Merge all the config dependencies of'
1731 echo '* dtbs - Build device tree blobs for enabled boards'; \
1732 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1733 echo ' dt_binding_check - Validate device tree binding documents'; \
1734 echo ' dtbs_check - Validate device tree source files';\
1742 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1745 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1753 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1755 @$(if $(board-dirs), \
1756 $(foreach b, $(board-dirs), \
1757 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1758 printf " %-16s - Show all of the above\\n" help-boards; \
1764 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1778 help-board-dirs := $(addprefix help-,$(board-dirs))
1780 help-boards: $(help-board-dirs)
1782 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1784 $(help-board-dirs): help-%:
1786 @$(if $(boards-per-dir), \
1787 $(foreach b, $(boards-per-dir), \
1788 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1793 # ---------------------------------------------------------------------------
1801 # ---------------------------------------------------------------------------
1806 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1816 # When building external modules the kernel used as basis is considered
1817 # read-only, and no consistency checks are made and the make
1823 # modules.
1825 # make M=dir modules Make all modules in specified dir
1826 # make M=dir Same as 'make M=dir modules'
1828 # Install the modules built in the module directory
1831 # We are always building only modules.
1835 build-dirs := $(KBUILD_EXTMOD)
1836 PHONY += modules
1837 modules: $(MODORDER)
1838 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1846 install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1849 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1850 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1856 compile_commands.json: $(extmod-prefix)compile_commands.json
1859 clean-dirs := $(KBUILD_EXTMOD)
1860 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
1861 $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
1865 @echo ' Building external modules.'
1866 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1868 @echo ' modules - default target, build the module(s)'
1869 @echo ' modules_install - install the module'
1870 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'
1872 @echo ' clean - remove generated files in module directory only'
1875 # no-op for external module builds
1881 # ---------------------------------------------------------------------------
1886 # The supported suffixes for single-target are listed in 'single-targets'
1892 ifdef single-build
1895 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1896 single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS)))
1898 $(single-ko): single_modpost
1900 $(single-no-ko): descend
1904 # For the single build of in-tree modules, use a temporary file to avoid
1905 # the situation of modules_install installing an invalid modules.order.
1906 MODORDER := .modules.tmp
1910 single_modpost: $(single-no-ko) modules_prepare
1911 $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
1912 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1916 export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
1919 build-dirs := $(foreach d, $(build-dirs), \
1928 # Handle descending into subdirectories listed in $(build-dirs)
1933 PHONY += descend $(build-dirs)
1934 descend: $(build-dirs)
1935 $(build-dirs): prepare
1937 single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
1938 $(if $(KBUILD_MIXED_TREE),,need-builtin=1) need-modorder=1
1940 clean-dirs := $(addprefix _clean_, $(clean-dirs))
1941 PHONY += $(clean-dirs) clean
1942 $(clean-dirs):
1945 clean: $(clean-dirs)
1948 \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
1949 -o -name '*.ko.*' \
1950 -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
1951 -o -name '*.dwo' -o -name '*.lst' \
1952 -o -name '*.su' -o -name '*.mod' \
1953 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1954 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
1955 -o -name '*.asn1.[ch]' \
1956 -o -name '*.symtypes' -o -name 'modules.order' \
1957 -o -name '.tmp_*.o.*' \
1958 -o -name '*.c.[012]*.*' \
1959 -o -name '*.ll' \
1960 -o -name '*.gcno' \
1961 -o -name '*.*.symversions' \) -type f -print | xargs rm -f
1964 # ---------------------------------------------------------------------------
1972 # ---------------------------------------------------------------------------
1976 nsdeps: modules
1980 # ---------------------------------------------------------------------------
1983 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
1985 $(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
1990 targets += $(extmod-prefix)compile_commands.json
1992 PHONY += clang-tidy clang-analyzer
1996 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
1998 clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json
2001 clang-tidy clang-analyzer:
2007 # ---------------------------------------------------------------------------
2013 -name '*.[hcS]' -type f -print | sort \
2014 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
2018 -name '*.[hcS]' -type f -print | sort \
2019 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
2031 # else wants $(ARCH), including people doing cross-builds, which means
2039 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
2059 $(Q)mkdir -p $(objtree)/tools
2060 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
2063 $(Q)mkdir -p $(objtree)/tools
2064 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
2066 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
2067 cmd_rmfiles = rm -rf $(rm-files)
2072 $(KERNELRELEASE) $(mixed-build-prefix)
2075 existing-targets := $(wildcard $(sort $(targets)))
2077 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
2079 endif # config-build
2080 endif # mixed-build
2081 endif # need-sub-make