xref: /linux/scripts/Makefile (revision b055f4c431e3d0e0508b7541d7c3fa2f9cd2e0ab)
1# SPDX-License-Identifier: GPL-2.0
2###
3# scripts contains sources for various helper programs used throughout
4# the kernel for the build process.
5
6hostprogs-always-$(CONFIG_KALLSYMS)			+= kallsyms
7hostprogs-always-$(BUILD_C_RECORDMCOUNT)		+= recordmcount
8hostprogs-always-$(CONFIG_BUILDTIME_TABLE_SORT)		+= sorttable
9hostprogs-always-$(CONFIG_ASN1)				+= asn1_compiler
10hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT)		+= sign-file
11hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE)	+= insert-sys-cert
12hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS)		+= rustdoc_test_builder
13hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS)		+= rustdoc_test_gen
14
15sorttable-objs := sorttable.o elf-parse.o
16
17ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
18always-$(CONFIG_RUST)					+= target.json
19filechk_rust_target = $< < include/config/auto.conf
20
21$(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE
22	$(call filechk,rust_target)
23endif
24
25hostprogs += generate_rust_target
26generate_rust_target-rust := y
27rustdoc_test_builder-rust := y
28rustdoc_test_gen-rust := y
29
30HOSTCFLAGS_elf-parse.o = -I$(srctree)/tools/include
31HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
32HOSTLDLIBS_sorttable = -lpthread
33HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
34HOSTCFLAGS_sign-file.o = $(shell $(HOSTPKG_CONFIG) --cflags libcrypto 2> /dev/null)
35HOSTLDLIBS_sign-file = $(shell $(HOSTPKG_CONFIG) --libs libcrypto 2> /dev/null || echo -lcrypto)
36
37ifdef CONFIG_UNWINDER_ORC
38ifeq ($(ARCH),x86_64)
39SRCARCH := x86
40endif
41ifeq ($(ARCH),loongarch)
42SRCARCH := loongarch
43endif
44HOSTCFLAGS_sorttable.o += -I$(srctree)/tools/arch/$(SRCARCH)/include
45HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED
46endif
47
48ifdef CONFIG_BUILDTIME_MCOUNT_SORT
49HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
50endif
51
52# The following programs are only built on demand
53hostprogs += unifdef gen_packed_field_checks
54
55# The module linker script is preprocessed on demand
56targets += module.lds
57
58subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
59subdir-$(CONFIG_GENKSYMS) += genksyms
60subdir-$(CONFIG_GENDWARFKSYMS) += gendwarfksyms
61subdir-$(CONFIG_SECURITY_SELINUX) += selinux
62subdir-$(CONFIG_SECURITY_IPE) += ipe
63
64# Let clean descend into subdirs
65subdir-	+= basic dtc gdb kconfig mod
66