Lines Matching +full:sub +full:- +full:modules
1 # SPDX-License-Identifier: GPL-2.0
24 # Most importantly: sub-Makefiles should only ever modify files in
27 # unavoidable when linking the built-in.a targets which finally
28 # turn into vmlinux), we will call a sub make in that other dir, and
39 # Do not use make's built-in rules and variables
40 # (this increases performance and avoids hard-to-debug behaviour)
41 MAKEFLAGS += -rR
53 # ---------------------------------------------------------------------------
60 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
67 # A simple variant is to prefix commands with $(Q) - that's useful
68 # for commands that shall be hidden in non-verbose mode.
94 # If the user is running make -s (silent mode), suppress echoing of
97 ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
107 # Use 'make C=1' to enable checking of only re-compiled files.
109 # of whether they are re-compiled or not.
111 # See the file "Documentation/dev-tools/sparse.rst" for more details,
130 $(error building multiple external modules is not supported))
144 # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
165 # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
167 abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
179 MAKEFLAGS += --no-print-directory
181 need-sub-make := 1
184 this-makefile := $(lastword $(MAKEFILE_LIST))
185 abs_srctree := $(realpath $(dir $(this-makefile)))
194 # --included-dir is added for backward compatibility, but you should not rely on
196 MAKEFLAGS += --include-dir=$(abs_srctree)
200 # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
201 # We need to invoke sub-make to avoid implicit rules in the top Makefile.
202 need-sub-make := 1
204 $(this-makefile): ;
210 ifeq ($(need-sub-make),1)
212 PHONY += $(MAKECMDGOALS) __sub-make
214 $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
218 __sub-make:
219 $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
221 endif # need-sub-make
225 ifeq ($(need-sub-make),)
230 MAKEFLAGS += --no-print-directory
265 clean-targets := %clean mrproper cleandocs
266 no-dot-config-targets := $(clean-targets) \
269 %asm-generic kernelversion %src-pkg dt_binding_check \
273 no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
275 no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
277 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
279 config-build :=
280 mixed-build :=
281 need-config := 1
282 need-compiler := 1
283 may-sync-config := 1
284 single-build :=
286 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
287 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
288 need-config :=
292 ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
293 ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
294 need-compiler :=
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-
434 export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
435 -O2 -fomit-frame-pointer -std=gnu89
439 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
444 CPP = $(CC) -E
448 AR = llvm-ar
449 NM = llvm-nm
450 OBJCOPY = llvm-objcopy
451 OBJDUMP = llvm-objdump
452 READELF = llvm-readelf
453 STRIP = llvm-strip
483 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
484 -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
495 -I$(srctree)/arch/$(SRCARCH)/include/uapi \
496 -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
497 -I$(srctree)/include/uapi \
498 -I$(objtree)/include/generated/uapi \
499 -include $(srctree)/include/linux/compiler-version.h \
500 -include $(srctree)/include/linux/kconfig.h
505 -I$(srctree)/arch/$(SRCARCH)/include \
506 -I$(objtree)/arch/$(SRCARCH)/include/generated \
507 $(if $(building_out_of_srctree),-I$(srctree)/include) \
508 -I$(objtree)/include \
511 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
512 KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
513 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
514 -Werror=implicit-function-declaration -Werror=implicit-int \
515 -Werror=return-type -Wno-format-security \
516 -std=gnu89
517 KBUILD_CPPFLAGS := -D__KERNEL__
520 KBUILD_AFLAGS_MODULE := -DMODULE
521 KBUILD_CFLAGS_MODULE := -DMODULE
540 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
541 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
542 -prune -o
543 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
544 --exclude CVS --exclude .pc --exclude .hg --exclude .git
556 # Before starting out-of-tree build, make sure the source tree is clean.
570 $(Q)if [ -f $(srctree)/.config -o \
571 -d $(srctree)/include/config -o \
572 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
579 $(Q)ln -fsn $(srctree) source
581 $(Q)test -e .gitignore || \
589 CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
596 # cc-cross-prefix to determine CROSS_COMPILE.
597 ifdef need-compiler
601 ifdef config-build
603 # *config targets only - make sure prerequisites are updated, and descend
618 else #!config-build
620 # Build targets only - this includes vmlinux, arch specific targets, clean
624 # but instead __all depend on modules
629 __all: modules
632 # Decide whether to build built-in, modular, or both.
633 # Normally, just do built-in.
638 # If we have only "make modules", don't compile built-in objects.
639 ifeq ($(MAKECMDGOALS),modules)
643 # If we have "make <whatever> modules", compile modules
645 # Just "make" or "make all" shall build modules as well
647 ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
657 ifdef need-config
663 core-y := init/ usr/ arch/$(SRCARCH)/
664 drivers-y := drivers/ sound/
665 drivers-$(CONFIG_SAMPLES) += samples/
666 drivers-$(CONFIG_NET) += net/
667 drivers-y += virt/
668 libs-y := lib/
673 # This allow a user to issue only 'make' to build a kernel including modules
677 CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
679 CFLAGS_GCOV += -fno-tree-loop-im
685 CC_FLAGS_FTRACE := -pg
689 RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
690 RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
693 RETPOLINE_CFLAGS := -mretpoline-external-thunk
694 RETPOLINE_VDSO_CFLAGS := -mretpoline
701 ifdef need-config
702 ifdef may-sync-config
721 # This exploits the 'multi-target pattern rule' trick.
729 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
730 else # !may-sync-config
731 # External modules and some install targets need include/generated/autoconf.h
732 # and include/config/auto.conf but do not care if they are up-to-date.
737 $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
745 endif # may-sync-config
746 endif # need-config
748 KBUILD_CFLAGS += -fno-delete-null-pointer-checks
749 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
750 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
751 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
752 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
755 KBUILD_CFLAGS += -O2
757 KBUILD_CFLAGS += -O3
759 KBUILD_CFLAGS += -Os
762 # Tell gcc to never replace conditional load with a non-conditional one
764 # gcc-10 renamed --param=allow-store-data-races=0 to
765 # -fno-allow-store-data-races.
766 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
767 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
775 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
779 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
782 stackp-flags-y := -fno-stack-protector
783 stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
784 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
786 KBUILD_CFLAGS += $(stackp-flags-y)
788 KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
789 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
792 KBUILD_CPPFLAGS += -Qunused-arguments
793 # The kernel builds with '-std=gnu89' so use of GNU extensions is acceptable.
794 KBUILD_CFLAGS += -Wno-gnu
798 KBUILD_CFLAGS += -mno-global-merge
801 # Warn about unmarked fall-throughs in switch statement.
804 KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=5,)
806 KBUILD_CFLAGS += -Wno-main
811 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
812 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
815 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
819 # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
820 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
821 # -fomit-frame-pointer with FUNCTION_TRACER.
823 KBUILD_CFLAGS += -fomit-frame-pointer
829 KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
837 KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
838 KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
843 KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
847 KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
855 DEBUG_CFLAGS += -gsplit-dwarf
857 DEBUG_CFLAGS += -g
861 KBUILD_AFLAGS += -Wa,-gdwarf-2
865 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
866 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
867 DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y)
871 DEBUG_CFLAGS += -fno-var-tracking
873 DEBUG_CFLAGS += -femit-struct-debug-baseonly
878 DEBUG_CFLAGS += -gz=zlib
879 KBUILD_AFLAGS += -gz=zlib
880 KBUILD_LDFLAGS += --compress-debug-sections=zlib
890 CC_FLAGS_FTRACE += -mrecord-mcount
892 ifeq ($(call cc-option-yn, -mnop-mcount),y)
893 CC_FLAGS_FTRACE += -mnop-mcount
894 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
899 CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
908 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
909 ifeq ($(call cc-option-yn, -mfentry),y)
910 CC_FLAGS_FTRACE += -mfentry
911 CC_FLAGS_USING += -DCC_USING_FENTRY
921 KBUILD_CFLAGS += -fno-inline-functions-called-once
925 KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
926 LDFLAGS_vmlinux += --gc-sections
930 CC_FLAGS_SCS := -fsanitize=shadow-call-stack
937 CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
938 KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod_prefix).thinlto-cache
940 CC_FLAGS_LTO := -flto
942 CC_FLAGS_LTO += -fvisibility=hidden
945 KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
950 ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
951 KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
957 KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
958 KBUILD_AFLAGS += -fno-lto
963 CC_FLAGS_CFI := -fsanitize=cfi \
964 -fsanitize-cfi-cross-dso \
965 -fno-sanitize-cfi-canonical-jump-tables \
966 -fno-sanitize-trap=cfi \
967 -fno-sanitize-blacklist
970 CC_FLAGS_CFI += -fsanitize-recover=cfi
980 KBUILD_CFLAGS += -falign-functions=64
984 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
987 KBUILD_CFLAGS += -Wdeclaration-after-statement
990 KBUILD_CFLAGS += -Wvla
993 KBUILD_CFLAGS += -Wno-pointer-sign
996 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
999 KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
1000 KBUILD_CFLAGS += -Wno-array-bounds
1001 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
1004 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
1008 KBUILD_CFLAGS += -Wno-maybe-uninitialized
1012 KBUILD_CFLAGS += -fno-strict-overflow
1014 # Make sure -fstack-check isn't enabled (like gentoo apparently did)
1015 KBUILD_CFLAGS += -fno-stack-check
1019 KBUILD_CFLAGS += -fconserve-stack
1022 # Prohibit date/time macros, which would make the build non-deterministic
1023 KBUILD_CFLAGS += -Werror=date-time
1026 KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
1029 KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
1032 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
1035 include-y := scripts/Makefile.extrawarn
1036 include-$(CONFIG_KASAN) += scripts/Makefile.kasan
1037 include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
1038 include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
1039 include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1040 include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
1042 include $(addprefix $(srctree)/, $(include-y))
1044 # scripts/Makefile.gcc-plugins is intentionally included last.
1045 # Do not add $(call cc-option,...) below this line. When you build the kernel
1053 KBUILD_LDFLAGS_MODULE += --build-id=sha1
1054 LDFLAGS_vmlinux += --build-id=sha1
1057 LDFLAGS_vmlinux += $(call ld-option, -X,)
1061 LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
1067 LDFLAGS_vmlinux += --orphan-handling=warn
1071 KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1072 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1075 CHECKFLAGS += --arch=$(ARCH)
1078 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
1081 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1108 MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
1114 export MODORDER := $(extmod_prefix)modules.order
1115 export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
1118 core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
1120 vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
1121 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
1122 $(libs-y) $(libs-m)))
1124 vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
1125 $(patsubst %/,%,$(filter %/, $(core-) \
1126 $(drivers-) $(libs-))))
1128 subdir-modorder := $(addsuffix modules.order,$(filter %/, \
1129 $(core-y) $(core-m) $(libs-y) $(libs-m) \
1130 $(drivers-y) $(drivers-m)))
1132 build-dirs := $(vmlinux-dirs)
1133 clean-dirs := $(vmlinux-alldirs)
1135 # Externally visible symbols (used by link-vmlinux.sh)
1136 KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
1137 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
1139 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
1140 KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
1142 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
1144 KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
1149 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scrip…
1151 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
1157 # we have to build modules as well to determine what those symbols are.
1161 autoksyms_recursive: descend modules.order
1163 "$(MAKE) -f $(srctree)/Makefile vmlinux"
1169 cmd_autoksyms_h = mkdir -p $(dir $@); \
1178 cmd_link-vmlinux = \
1180 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
1182 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
1183 +$(call if_changed_dep,link-vmlinux)
1189 $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
1206 # or the modules are listed in "prepare".
1207 # A multi level approach is used. prepareN is processed before prepareN-1.
1214 asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
1215 include/generated/autoconf.h remove-stale-files
1224 PHONY += remove-stale-files
1225 remove-stale-files:
1226 $(Q)$(srctree)/scripts/remove-stale-files
1228 # Support for using generic headers in asm-generic
1229 asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
1231 PHONY += asm-generic uapi-asm-generic
1232 asm-generic: uapi-asm-generic
1233 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
1234 generic=include/asm-generic
1235 uapi-asm-generic:
1236 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
1237 generic=include/uapi/asm-generic
1240 # ---------------------------------------------------------------------------
1247 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
1255 if [ $(SUBLEVEL) -gt 255 ]; then \
1279 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
1280 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
1282 # ---------------------------------------------------------------------------
1290 mkdir -p $(INSTALL_HDR_PATH); \
1291 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1300 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1303 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1306 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1307 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1309 # Deprecated. It is no-op now.
1313 @echo >&2 "Since Linux 5.5, 'make headers_check' is no-op,"
1326 # ---------------------------------------------------------------------------
1331 # to the this Makefile to build and install external modules.
1336 # ---------------------------------------------------------------------------
1357 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
1366 $(Q)mkdir -p $(objtree)/tools
1367 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
1370 $(Q)mkdir -p $(objtree)/tools
1371 … LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdi…
1373 # ---------------------------------------------------------------------------
1378 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
1380 kselftest-%: FORCE
1381 $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
1383 PHONY += kselftest-merge
1384 kselftest-merge:
1386 $(Q)find $(srctree)/tools/testing/selftests -name config | \
1387 xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
1388 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1390 # ---------------------------------------------------------------------------
1437 # ---------------------------------------------------------------------------
1438 # Modules
1442 # By default, build modules as well
1444 all: modules
1446 # When we're building modules with modversions, we need to consider
1447 # the built-in objects during the descend as well, in order to
1453 # Build modules
1455 # A module can be listed more than once in obj-m resulting in
1456 # duplicate lines in modules.order files. Those are removed
1459 PHONY += modules
1460 modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare target
1462 cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
1464 modules.order: $(subdir-modorder) FORCE
1467 targets += modules.order
1469 # Target to prepare building external modules
1496 @rm -rf $(MODLIB)/kernel
1497 @rm -f $(MODLIB)/source
1498 @mkdir -p $(MODLIB)/kernel
1499 @ln -s $(abspath $(srctree)) $(MODLIB)/source
1500 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
1501 rm -f $(MODLIB)/build ; \
1502 ln -s $(CURDIR) $(MODLIB)/build ; \
1504 @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
1505 @cp -f modules.builtin $(MODLIB)/
1506 @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
1513 # Leave enough to build external modules
1518 CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
1519 modules.builtin modules.builtin.modinfo modules.nsdeps \
1520 compile_commands.json .thinlto-cache
1525 debian snap tar-install \
1530 vmlinux-gdb.py \
1533 # clean - Delete most, but leave enough to build external modules
1535 clean: rm-files := $(CLEAN_FILES)
1540 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1541 $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
1545 # mrproper - Delete all generated files, including .config
1547 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1548 mrproper-dirs := $(addprefix _mrproper_,scripts)
1550 PHONY += $(mrproper-dirs) mrproper
1551 $(mrproper-dirs):
1554 mrproper: clean $(mrproper-dirs)
1563 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1564 -o -name '*.bak' -o -name '#*#' -o -name '*%' \
1565 -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
1566 -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
1567 -type f -print | xargs rm -f
1571 # ---------------------------------------------------------------------------
1573 %src-pkg: FORCE
1574 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1576 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
1579 # ---------------------------------------------------------------------------
1583 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1584 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1589 @echo ' clean - Remove most generated files but keep the config and'
1590 @echo ' enough build support to build external modules'
1591 @echo ' mrproper - Remove all generated files + config + various backup files'
1592 @echo ' distclean - mrproper + remove editor backup and patch files'
1595 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1598 @echo ' all - Build all targets marked with [*]'
1599 @echo '* vmlinux - Build the bare kernel'
1600 @echo '* modules - Build all modules'
1601 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1602 @echo ' dir/ - Build all files in dir and below'
1603 @echo ' dir/file.[ois] - Build specified target only'
1604 @echo ' dir/file.ll - Build the LLVM assembly file'
1606 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1608 @echo ' dir/file.ko - Build module including final link'
1609 @echo ' modules_prepare - Set up for building external modules'
1610 @echo ' tags/TAGS - Generate tags file for editors'
1611 @echo ' cscope - Generate cscope index'
1612 @echo ' gtags - Generate GNU GLOBAL index'
1613 @echo ' kernelrelease - Output the release version string (use with make -s)'
1614 @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
1615 @echo ' image_name - Output the image name (use with make -s)'
1616 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1620 @echo ' checkstack - Generate a list of stack hogs'
1621 @echo ' versioncheck - Sanity check on version.h usage'
1622 @echo ' includecheck - Check for duplicate included header files'
1623 @echo ' export_report - List the usages of all exported symbols'
1624 @echo ' headerdep - Detect inclusion cycles in headers'
1625 @echo ' coccicheck - Check with Coccinelle'
1626 @echo ' clang-analyzer - Check with clang static analyzer'
1627 @echo ' clang-tidy - Check with clang-tidy'
1630 @echo ' nsdeps - Generate missing symbol namespace dependencies'
1633 @echo ' kselftest - Build and run kernel selftest'
1637 @echo ' kselftest-all - Build kernel selftest'
1638 @echo ' kselftest-install - Build and install kernel selftest'
1639 @echo ' kselftest-clean - Remove all generated kselftest files'
1640 @echo ' kselftest-merge - Merge all the config dependencies of'
1645 echo '* dtbs - Build device tree blobs for enabled boards'; \
1646 echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
1647 echo ' dt_binding_check - Validate device tree binding documents'; \
1648 echo ' dtbs_check - Validate device tree source files';\
1656 @$(MAKE) -f $(srctree)/scripts/Makefile.package help
1659 @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
1667 printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1669 @$(if $(board-dirs), \
1670 $(foreach b, $(board-dirs), \
1671 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1672 printf " %-16s - Show all of the above\\n" help-boards; \
1678 @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
1692 help-board-dirs := $(addprefix help-,$(board-dirs))
1694 help-boards: $(help-board-dirs)
1696 boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1698 $(help-board-dirs): help-%:
1700 @$(if $(boards-per-dir), \
1701 $(foreach b, $(boards-per-dir), \
1702 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1707 # ---------------------------------------------------------------------------
1715 # ---------------------------------------------------------------------------
1720 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1730 # When building external modules the kernel used as basis is considered
1731 # read-only, and no consistency checks are made and the make
1735 # We are always building only modules.
1739 build-dirs := $(KBUILD_EXTMOD)
1746 clean-dirs := $(KBUILD_EXTMOD)
1747 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
1748 $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
1762 @echo ' Building external modules.'
1763 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
1765 @echo ' modules - default target, build the module(s)'
1766 @echo ' modules_install - install the module'
1767 @echo ' clean - remove generated files in module directory only'
1770 # no-op for external module builds
1775 # ---------------------------------------------------------------------------
1776 # Modules
1778 PHONY += modules modules_install
1782 modules: modules_check target
1783 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1787 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1794 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1799 # Modules not configured
1800 # ---------------------------------------------------------------------------
1802 modules modules_install: target
1804 @echo >&2 '*** The present kernel configuration has modules disabled.'
1813 # ---------------------------------------------------------------------------
1818 # The supported suffixes for single-target are listed in 'single-targets'
1824 ifdef single-build
1827 single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
1828 single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS)))
1830 $(single-ko): single_modpost
1832 $(single-no-ko): descend
1836 # For the single build of in-tree modules, use a temporary file to avoid
1837 # the situation of modules_install installing an invalid modules.order.
1838 MODORDER := .modules.tmp
1842 single_modpost: $(single-no-ko) modules_prepare
1843 $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER)
1844 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1848 export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod_prefix), $(single-no-ko))
1851 build-dirs := $(foreach d, $(build-dirs), \
1860 # Handle descending into subdirectories listed in $(build-dirs)
1865 PHONY += descend $(build-dirs)
1866 descend: $(build-dirs)
1867 $(build-dirs): prepare
1869 single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
1870 need-builtin=1 need-modorder=1
1872 clean-dirs := $(addprefix _clean_, $(clean-dirs))
1873 PHONY += $(clean-dirs) clean
1874 $(clean-dirs):
1877 clean: $(clean-dirs)
1880 \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
1881 -o -name '*.ko.*' \
1882 -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
1883 -o -name '*.dwo' -o -name '*.lst' \
1884 -o -name '*.su' -o -name '*.mod' \
1885 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1886 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
1887 -o -name '*.asn1.[ch]' \
1888 -o -name '*.symtypes' -o -name 'modules.order' \
1889 -o -name '.tmp_*.o.*' \
1890 -o -name '*.c.[012]*.*' \
1891 -o -name '*.ll' \
1892 -o -name '*.gcno' \
1893 -o -name '*.*.symversions' \) -type f -print | xargs rm -f
1896 # ---------------------------------------------------------------------------
1904 # ---------------------------------------------------------------------------
1908 nsdeps: modules
1912 # ---------------------------------------------------------------------------
1915 cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
1917 $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
1924 PHONY += clang-tidy clang-analyzer
1928 cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
1930 clang-tidy clang-analyzer: $(extmod_prefix)compile_commands.json
1933 clang-tidy clang-analyzer:
1939 # ---------------------------------------------------------------------------
1945 -name '*.[hcS]' -type f -print | sort \
1946 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
1950 -name '*.[hcS]' -type f -print | sort \
1951 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
1963 # else wants $(ARCH), including people doing cross-builds, which means
1971 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1983 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1984 cmd_rmfiles = rm -rf $(rm-files)
1987 existing-targets := $(wildcard $(sort $(targets)))
1989 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
1991 endif # config-build
1992 endif # mixed-build
1993 endif # need-sub-make