blob: bc90520a54266cc1d9cd2584ccde4e874f3827a7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002###
3# scripts contains sources for various helper programs used throughout
4# the kernel for the build process.
H. Peter Anvin6520fe52012-05-08 21:22:24 +03005
Masahiro Yamadafaabed22020-08-01 21:27:18 +09006hostprogs-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
Masahiro Yamadafaabed22020-08-01 21:27:18 +090011hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
Miguel Ojedaa66d7332023-07-18 07:27:51 +020012hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder
13hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen
Miguel Ojeda2f7ab122021-07-03 16:42:57 +020014
Jamie Cunliffef82811e2023-10-20 16:50:55 +010015ifneq ($(or $(CONFIG_X86_64),$(CONFIG_LOONGARCH)),)
16always-$(CONFIG_RUST) += target.json
Masahiro Yamadac83b16c2023-01-07 18:45:45 +090017filechk_rust_target = $< < include/config/auto.conf
18
19$(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE
20 $(call filechk,rust_target)
Jamie Cunliffef82811e2023-10-20 16:50:55 +010021endif
Masahiro Yamadac83b16c2023-01-07 18:45:45 +090022
23hostprogs += generate_rust_target
Miguel Ojeda2f7ab122021-07-03 16:42:57 +020024generate_rust_target-rust := y
Miguel Ojedaa66d7332023-07-18 07:27:51 +020025rustdoc_test_builder-rust := y
26rustdoc_test_gen-rust := y
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Shile Zhang10916702019-12-04 08:46:31 +080028HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
Yinan Liu72b39422021-12-12 19:33:58 +080029HOSTLDLIBS_sorttable = -lpthread
David Howells4520c6a2012-09-21 23:31:13 +010030HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
Chun-Tse Shaod5ea4fe2022-04-01 23:18:02 +000031HOSTCFLAGS_sign-file.o = $(shell $(HOSTPKG_CONFIG) --cflags libcrypto 2> /dev/null)
32HOSTLDLIBS_sign-file = $(shell $(HOSTPKG_CONFIG) --libs libcrypto 2> /dev/null || echo -lcrypto)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Shile Zhang57fa1892019-12-04 08:46:32 +080034ifdef CONFIG_UNWINDER_ORC
35ifeq ($(ARCH),x86_64)
Tiezhu Yangcb8a2ef2024-03-11 22:23:47 +080036SRCARCH := x86
Shile Zhang57fa1892019-12-04 08:46:32 +080037endif
Tiezhu Yangcb8a2ef2024-03-11 22:23:47 +080038ifeq ($(ARCH),loongarch)
39SRCARCH := loongarch
40endif
41HOSTCFLAGS_sorttable.o += -I$(srctree)/tools/arch/$(SRCARCH)/include
Shile Zhang57fa1892019-12-04 08:46:32 +080042HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED
Yinan Liu72b39422021-12-12 19:33:58 +080043endif
44
Steven Rostedt (Google)4ed308c2022-01-25 09:19:10 -050045ifdef CONFIG_BUILDTIME_MCOUNT_SORT
Yinan Liu72b39422021-12-12 19:33:58 +080046HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
Shile Zhang57fa1892019-12-04 08:46:32 +080047endif
48
Masahiro Yamada5f2fb522020-02-02 01:49:24 +090049# The following programs are only built on demand
Masahiro Yamada05e96e92023-03-16 00:50:18 +090050hostprogs += unifdef
Sam Ravnborg07aea3a2006-07-23 20:47:50 +020051
Masahiro Yamada596b0472020-09-08 13:27:08 +090052# The module linker script is preprocessed on demand
53targets += module.lds
54
Masahiro Yamadace2fd53a2018-11-29 12:56:31 +090055subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
Linus Torvalds1da177e2005-04-16 15:20:36 -070056subdir-$(CONFIG_MODVERSIONS) += genksyms
Serge E. Hallyn93c06cb2008-08-26 14:47:57 -050057subdir-$(CONFIG_SECURITY_SELINUX) += selinux
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59# Let clean descend into subdirs
Masahiro Yamada46a63d42019-08-21 16:02:02 +090060subdir- += basic dtc gdb kconfig mod