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 10bounds-file := include/generated/bounds.h 11 12targets := kernel/bounds.s 13 14$(bounds-file): kernel/bounds.s FORCE 15 $(call filechk,offsets,__LINUX_BOUNDS_H__) 16 17# Generate timeconst.h 18 19timeconst-file := include/generated/timeconst.h 20 21filechk_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 28offsets-file := include/generated/asm-offsets.h 29 30targets += arch/$(SRCARCH)/kernel/asm-offsets.s 31 32arch/$(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 39rq-offsets-file := include/generated/rq-offsets.h 40 41targets += kernel/sched/rq-offsets.s 42 43kernel/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 50missing-syscalls-file := .tmp_missing-syscalls$(missing_syscalls_instance) 51 52targets += $(missing-syscalls-file) 53 54quiet_cmd_syscalls = CALL $< $(addprefix for ,$(missing_syscalls_instance)) 55 cmd_syscalls = DEPFILE=$(depfile) $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags); touch $@ 56 57$(missing-syscalls-file): scripts/checksyscalls.sh $(rq-offsets-file) FORCE 58 $(call if_changed_dep,syscalls) 59 60PHONY += missing-syscalls 61missing-syscalls: $(missing-syscalls-file) 62 63# Check the manual modification of atomic headers 64 65quiet_cmd_check_sha1 = CHKSHA1 $< 66 cmd_check_sha1 = \ 67 if ! command -v sha1sum >/dev/null; then \ 68 echo "warning: cannot check the header due to sha1sum missing"; \ 69 exit 0; \ 70 fi; \ 71 if [ "$$(sed -n '$$s:// ::p' $<)" != \ 72 "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \ 73 echo "error: $< has been modified." >&2; \ 74 exit 1; \ 75 fi; \ 76 touch $@ 77 78atomic-checks += $(addprefix $(obj)/.checked-, \ 79 atomic-arch-fallback.h \ 80 atomic-instrumented.h \ 81 atomic-long.h) 82 83targets += $(atomic-checks) 84$(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE 85 $(call if_changed,check_sha1) 86 87# A phony target that depends on all the preparation targets 88 89PHONY += prepare 90prepare: $(offsets-file) missing-syscalls $(atomic-checks) 91 @: 92 93# Ordinary directory descending 94# --------------------------------------------------------------------------- 95 96obj-y += init/ 97obj-y += usr/ 98obj-y += arch/$(SRCARCH)/ 99obj-y += $(ARCH_CORE) 100obj-y += kernel/ 101obj-y += certs/ 102obj-y += mm/ 103obj-y += fs/ 104obj-y += ipc/ 105obj-y += security/ 106obj-y += crypto/ 107obj-$(CONFIG_BLOCK) += block/ 108obj-$(CONFIG_IO_URING) += io_uring/ 109obj-$(CONFIG_RUST) += rust/ 110obj-y += $(ARCH_LIB) 111obj-y += drivers/ 112obj-y += sound/ 113obj-$(CONFIG_SAMPLES) += samples/ 114obj-$(CONFIG_NET) += net/ 115obj-y += virt/ 116obj-y += $(ARCH_DRIVERS) 117obj-$(CONFIG_DRM_HEADER_TEST) += include/ 118