Debian Codegraph @

Kbuild

raw
1 # SPDX-License-Identifier: GPL-2.0
2 #
3 # Kbuild for top-level directory of the kernel
4
5 # Prepare global headers and check sanity before descending into sub-directories
6 # ---------------------------------------------------------------------------
7
8 # Generate bounds.h
9
10 bounds-file := include/generated/bounds.h
11
12 targets := kernel/bounds.s
13
14 $(bounds-file): kernel/bounds.s FORCE
15 $(call filechk,offsets,__LINUX_BOUNDS_H__)
16
17 # Generate timeconst.h
18
19 timeconst-file := include/generated/timeconst.h
20
21 filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
22
23 $(timeconst-file): kernel/time/timeconst.bc FORCE
24 $(call filechk,gentimeconst)
25
26 # Generate asm-offsets.h
27
28 offsets-file := include/generated/asm-offsets.h
29
30 targets += arch/$(SRCARCH)/kernel/asm-offsets.s
31
32 arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
33
34 $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
35 $(call filechk,offsets,__ASM_OFFSETS_H__)
36
37 # Generate rq-offsets.h
38
39 rq-offsets-file := include/generated/rq-offsets.h
40
41 targets += kernel/sched/rq-offsets.s
42
43 kernel/sched/rq-offsets.s: $(offsets-file)
44
45 $(rq-offsets-file): kernel/sched/rq-offsets.s FORCE
46 $(call filechk,offsets,__RQ_OFFSETS_H__)
47
48 # Check for missing system calls
49
50 quiet_cmd_syscalls = CALL $<
51 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
52
53 PHONY += missing-syscalls
54 missing-syscalls: scripts/checksyscalls.sh $(rq-offsets-file)
55 $(call cmd,syscalls)
56
57 # Check the manual modification of atomic headers
58
59 quiet_cmd_check_sha1 = CHKSHA1 $<
60 cmd_check_sha1 = \
61 if ! command -v sha1sum >/dev/null; then \
62 echo "warning: cannot check the header due to sha1sum missing"; \
63 exit 0; \
64 fi; \
65 if [ "$$(sed -n '$$s:// ::p' $<)" != \
66 "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \
67 echo "error: $< has been modified." >&2; \
68 exit 1; \
69 fi; \
70 touch $@
71
72 atomic-checks += $(addprefix $(obj)/.checked-, \
73 atomic-arch-fallback.h \
74 atomic-instrumented.h \
75 atomic-long.h)
76
77 targets += $(atomic-checks)
78 $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE
79 $(call if_changed,check_sha1)
80
81 # A phony target that depends on all the preparation targets
82
83 PHONY += prepare
84 prepare: $(offsets-file) missing-syscalls $(atomic-checks)
85 @:
86
87 # Ordinary directory descending
88 # ---------------------------------------------------------------------------
89
90 obj-y += init/
91 obj-y += usr/
92 obj-y += arch/$(SRCARCH)/
93 obj-y += $(ARCH_CORE)
94 obj-y += kernel/
95 obj-y += certs/
96 obj-y += mm/
97 obj-y += fs/
98 obj-y += ipc/
99 obj-y += security/
100 obj-y += crypto/
101 obj-$(CONFIG_BLOCK) += block/
102 obj-$(CONFIG_IO_URING) += io_uring/
103 obj-$(CONFIG_RUST) += rust/
104 obj-y += $(ARCH_LIB)
105 obj-y += drivers/
106 obj-y += sound/
107 obj-$(CONFIG_SAMPLES) += samples/
108 obj-$(CONFIG_NET) += net/
109 obj-y += virt/
110 obj-y += $(ARCH_DRIVERS)
111 obj-$(CONFIG_DRM_HEADER_TEST) += include/