blob: 464b34a08f51ef9d2ae12e6902c92690b5dfa03b [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Sam Ravnborg86feeaa2005-09-09 19:28:28 +02002#
3# Kbuild for top-level directory of the kernel
Sam Ravnborg86feeaa2005-09-09 19:28:28 +02004
Masahiro Yamadaed7ceac2022-08-20 18:15:28 +09005# Prepare global headers and check sanity before descending into sub-directories
6# ---------------------------------------------------------------------------
7
Masahiro Yamada01d509a2019-02-19 18:33:03 +09008# Generate bounds.h
Masahiro Yamada39664e22015-01-05 15:57:15 +09009
10bounds-file := include/generated/bounds.h
11
Masahiro Yamada8a58e162015-03-26 20:59:52 +090012targets := kernel/bounds.s
Masahiro Yamada39664e22015-01-05 15:57:15 +090013
Masahiro Yamada11fda142018-12-22 18:50:35 +090014$(bounds-file): kernel/bounds.s FORCE
Michal Marek70a4fd62015-03-11 11:01:01 +010015 $(call filechk,offsets,__LINUX_BOUNDS_H__)
Masahiro Yamada39664e22015-01-05 15:57:15 +090016
Masahiro Yamada01d509a2019-02-19 18:33:03 +090017# Generate timeconst.h
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020018
19timeconst-file := include/generated/timeconst.h
20
Masahiro Yamadaba97df42019-01-03 10:16:54 +090021filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020022
Masahiro Yamada11fda142018-12-22 18:50:35 +090023$(timeconst-file): kernel/time/timeconst.bc FORCE
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020024 $(call filechk,gentimeconst)
25
Masahiro Yamada01d509a2019-02-19 18:33:03 +090026# Generate asm-offsets.h
Masahiro Yamada39664e22015-01-05 15:57:15 +090027
28offsets-file := include/generated/asm-offsets.h
29
Masahiro Yamada39664e22015-01-05 15:57:15 +090030targets += arch/$(SRCARCH)/kernel/asm-offsets.s
31
Masahiro Yamada11fda142018-12-22 18:50:35 +090032arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020033
Masahiro Yamada11fda142018-12-22 18:50:35 +090034$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
Michal Marek70a4fd62015-03-11 11:01:01 +010035 $(call filechk,offsets,__ASM_OFFSETS_H__)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020036
Masahiro Yamada01d509a2019-02-19 18:33:03 +090037# Check for missing system calls
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020038
39quiet_cmd_syscalls = CALL $<
David Daney44656fa2011-11-08 10:20:10 -080040 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020041
Masahiro Yamadaed7ceac2022-08-20 18:15:28 +090042PHONY += missing-syscalls
43missing-syscalls: scripts/checksyscalls.sh $(offsets-file)
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020044 $(call cmd,syscalls)
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070045
Masahiro Yamadab10fdee2022-08-20 18:15:29 +090046# Check the manual modification of atomic headers
Mark Rutland8d325882018-09-04 11:48:29 +010047
Masahiro Yamadab10fdee2022-08-20 18:15:29 +090048quiet_cmd_check_sha1 = CHKSHA1 $<
49 cmd_check_sha1 = \
50 if ! command -v sha1sum >/dev/null; then \
51 echo "warning: cannot check the header due to sha1sum missing"; \
52 exit 0; \
53 fi; \
54 if [ "$$(sed -n '$$s:// ::p' $<)" != \
55 "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \
56 echo "error: $< has been modified." >&2; \
57 exit 1; \
58 fi; \
59 touch $@
Mark Rutland8d325882018-09-04 11:48:29 +010060
Masahiro Yamadab10fdee2022-08-20 18:15:29 +090061atomic-checks += $(addprefix $(obj)/.checked-, \
62 atomic-arch-fallback.h \
63 atomic-instrumented.h \
64 atomic-long.h)
Mark Rutland8d325882018-09-04 11:48:29 +010065
Masahiro Yamadab10fdee2022-08-20 18:15:29 +090066targets += $(atomic-checks)
67$(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE
68 $(call if_changed,check_sha1)
Masahiro Yamadaed7ceac2022-08-20 18:15:28 +090069
70# A phony target that depends on all the preparation targets
71
72PHONY += prepare
Masahiro Yamadab10fdee2022-08-20 18:15:29 +090073prepare: $(offsets-file) missing-syscalls $(atomic-checks)
Masahiro Yamadaed7ceac2022-08-20 18:15:28 +090074 @:
Masahiro Yamada57501212022-09-25 03:19:10 +090075
76# Ordinary directory descending
77# ---------------------------------------------------------------------------
78
79obj-y += init/
80obj-y += usr/
81obj-y += arch/$(SRCARCH)/
82obj-y += $(ARCH_CORE)
83obj-y += kernel/
84obj-y += certs/
85obj-y += mm/
86obj-y += fs/
87obj-y += ipc/
88obj-y += security/
89obj-y += crypto/
90obj-$(CONFIG_BLOCK) += block/
91obj-$(CONFIG_IO_URING) += io_uring/
Linus Torvalds8afc66e2022-10-10 12:00:45 -070092obj-$(CONFIG_RUST) += rust/
Masahiro Yamada57501212022-09-25 03:19:10 +090093obj-y += $(ARCH_LIB)
94obj-y += drivers/
95obj-y += sound/
96obj-$(CONFIG_SAMPLES) += samples/
97obj-$(CONFIG_NET) += net/
98obj-y += virt/
99obj-y += $(ARCH_DRIVERS)